summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2015-04-12 00:25:33 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2015-04-12 00:25:33 +0200
commit7584200bb88b7995b87f065320886b0813de22dd (patch)
tree40a38d38950dbe7f766cbce7a7a3070a06df7883
parent0865cbb67488b05b6fccde4baafc4a6f5087bbbf (diff)
downloadorg-mode-7584200bb88b7995b87f065320886b0813de22dd.tar.gz
org-footnote: Allow new footnotes in headlines
* lisp/org-footnote.el (org-footnote--allow-reference-p): Allow new footnotes in headlines. * testing/lisp/test-org-footnote.el (test-org-footnote/new): Add test. Reported-by: Thomas S. Dye <tsd@tsdye.com> <http://permalink.gmane.org/gmane.emacs.orgmode/96843>
-rw-r--r--lisp/org-footnote.el12
-rw-r--r--testing/lisp/test-org-footnote.el8
2 files changed, 20 insertions, 0 deletions
diff --git a/lisp/org-footnote.el b/lisp/org-footnote.el
index 7bcaa62..2b04e00 100644
--- a/lisp/org-footnote.el
+++ b/lisp/org-footnote.el
@@ -467,6 +467,18 @@ buffer."
((eq type 'verse-block)
(and (>= (point) (org-element-property :contents-begin context))
(< (point) (org-element-property :contents-end context))))
+ ;; In an headline or inlinetask, point must be either on the
+ ;; heading itself or on the blank lines below.
+ ((memq type '(headline inlinetask))
+ (or (not (org-at-heading-p))
+ (and (save-excursion (beginning-of-line)
+ (and (let ((case-fold-search t))
+ (not (looking-at "\\*+ END[ \t]*$")))
+ (looking-at org-complex-heading-regexp)))
+ (match-beginning 4)
+ (>= (point) (match-beginning 4))
+ (or (not (match-beginning 5))
+ (< (point) (match-beginning 5))))))
;; White spaces after an object or blank lines after an element
;; are OK.
((>= (point)
diff --git a/testing/lisp/test-org-footnote.el b/testing/lisp/test-org-footnote.el
index e73dbf8..1a10faa 100644
--- a/testing/lisp/test-org-footnote.el
+++ b/testing/lisp/test-org-footnote.el
@@ -67,6 +67,14 @@
(org-test-with-temp-text " <point>"
(let ((org-footnote-auto-label t)) (org-footnote-new))
(buffer-string))))
+ ;; In an headline or inlinetask, point must be either on the
+ ;; heading itself or on the blank lines below.
+ (should (org-test-with-temp-text "* H<point>" (org-footnote-new) t))
+ (should
+ (org-test-with-temp-text "* H\n <point>\nParagraph" (org-footnote-new) t))
+ (should-error (org-test-with-temp-text "*<point> H" (org-footnote-new) t))
+ (should-error
+ (org-test-with-temp-text "* H <point>:tag:" (org-footnote-new) t))
;; Allow new footnotes within recursive objects, but not in links.
(should
(string-match-p