footnote: Allow inserting footnotes at the end of table cells

* lisp/org-footnote.el (org-footnote--allow-reference-p): Allow
inserting footnotes at the end of table cells.
* testing/lisp/test-org-footnote.el (test-org-footnote/new): Add test.
This commit is contained in:
Nicolas Goaziou 2021-07-29 21:15:11 +02:00
parent 7ea9099725
commit c839849aba
2 changed files with 9 additions and 2 deletions

View File

@ -291,7 +291,8 @@ otherwise."
((eq type 'table-cell)
;; :contents-begin is not reliable on empty cells, so special
;; case it.
(<= (point) (org-element-property :contents-end context)))
(<= (save-excursion (skip-chars-backward " \t") (point))
(org-element-property :contents-end context)))
((let ((cbeg (org-element-property :contents-begin context))
(cend (org-element-property :contents-end context)))
(and cbeg (>= (point) cbeg) (<= (point) cend))))))))

View File

@ -90,7 +90,7 @@
(org-test-with-temp-text " *bold*<point>"
(let ((org-footnote-auto-label t)) (org-footnote-new))
(buffer-string))))
;; Arrow new footnotes in empty cells.
;; Arrow new footnotes in table cells.
(should
(string-match-p
" \\[fn:1\\]"
@ -109,6 +109,12 @@
(org-test-with-temp-text "| <point>|"
(let ((org-footnote-auto-label t)) (org-footnote-new))
(buffer-string))))
(should
(string-match-p
" \\[fn:1\\]"
(org-test-with-temp-text "| contents <point>|"
(let ((org-footnote-auto-label t)) (org-footnote-new))
(buffer-string))))
;; When creating a new footnote, move to its definition.
(should
(string=