mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-29 21:37:50 +00:00
footnote: Allow footnotes at footnote definition start
* lisp/org-footnote.el (org-footnote--allow-reference-p): Allow footnotes at footnote definition start, right after label. * testing/lisp/test-org-footnote.el (test-org-footnote/new): Add tests.
This commit is contained in:
parent
b07c312f28
commit
5f6e199143
|
@ -282,6 +282,9 @@ otherwise."
|
||||||
(skip-chars-backward " \r\t\n")
|
(skip-chars-backward " \r\t\n")
|
||||||
(if (eq (org-element-class context) 'object) (point)
|
(if (eq (org-element-class context) 'object) (point)
|
||||||
(1+ (line-beginning-position 2))))))
|
(1+ (line-beginning-position 2))))))
|
||||||
|
;; At the beginning of a footnote definition, right after the
|
||||||
|
;; label, is OK.
|
||||||
|
((eq type 'footnote-definition) (looking-at (rx (or space buffer-end))))
|
||||||
;; Other elements are invalid.
|
;; Other elements are invalid.
|
||||||
((eq (org-element-class context) 'element) nil)
|
((eq (org-element-class context) 'element) nil)
|
||||||
;; Just before object is fine.
|
;; Just before object is fine.
|
||||||
|
|
|
@ -90,7 +90,34 @@
|
||||||
(org-test-with-temp-text " *bold*<point>"
|
(org-test-with-temp-text " *bold*<point>"
|
||||||
(let ((org-footnote-auto-label t)) (org-footnote-new))
|
(let ((org-footnote-auto-label t)) (org-footnote-new))
|
||||||
(buffer-string))))
|
(buffer-string))))
|
||||||
;; Arrow new footnotes in table cells.
|
;; Allow new footnotes at the start of a footnote definition.
|
||||||
|
(should
|
||||||
|
(string-match-p
|
||||||
|
"\\[fn:1\\]\\[fn:2\\]"
|
||||||
|
(org-test-with-temp-text "[fn:1]<point>"
|
||||||
|
(let ((org-footnote-auto-label t)) (org-footnote-new))
|
||||||
|
(buffer-string))))
|
||||||
|
(should
|
||||||
|
(string-match-p
|
||||||
|
"\\[fn:1\\] \\[fn:2\\]"
|
||||||
|
(org-test-with-temp-text "[fn:1] <point>"
|
||||||
|
(let ((org-footnote-auto-label t)) (org-footnote-new))
|
||||||
|
(buffer-string))))
|
||||||
|
(should
|
||||||
|
(string-match-p
|
||||||
|
"\\[fn:1\\]\\[fn:2\\]"
|
||||||
|
(org-test-with-temp-text "[fn:1]<point> \nParagraph"
|
||||||
|
(let ((org-footnote-auto-label t)) (org-footnote-new))
|
||||||
|
(buffer-string))))
|
||||||
|
(should-error
|
||||||
|
(org-test-with-temp-text "[fn:<point>1]"
|
||||||
|
(let ((org-footnote-auto-label t)) (org-footnote-new))
|
||||||
|
(buffer-string)))
|
||||||
|
(should-error
|
||||||
|
(org-test-with-temp-text "<point>[fn:1]"
|
||||||
|
(let ((org-footnote-auto-label t)) (org-footnote-new))
|
||||||
|
(buffer-string)))
|
||||||
|
;; Allow new footnotes in table cells.
|
||||||
(should
|
(should
|
||||||
(string-match-p
|
(string-match-p
|
||||||
" \\[fn:1\\]"
|
" \\[fn:1\\]"
|
||||||
|
|
Loading…
Reference in a new issue