summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2021-07-29 21:15:11 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2021-07-29 21:15:11 +0200
commitc839849abad51c41570a091dd063ef140589a1cb (patch)
tree26391c857fae9b1b9e2d92a60ea5939b98976a28
parent7ea909972557705ed9fa116cfa0086a2bc86a59f (diff)
downloadorg-mode-c839849abad51c41570a091dd063ef140589a1cb.tar.gz
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.
-rw-r--r--lisp/org-footnote.el3
-rw-r--r--testing/lisp/test-org-footnote.el8
2 files changed, 9 insertions, 2 deletions
diff --git a/lisp/org-footnote.el b/lisp/org-footnote.el
index 729a4a9..c8c4dae 100644
--- a/lisp/org-footnote.el
+++ b/lisp/org-footnote.el
@@ -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))))))))
diff --git a/testing/lisp/test-org-footnote.el b/testing/lisp/test-org-footnote.el
index 4ce5b34..6d8ba2f 100644
--- a/testing/lisp/test-org-footnote.el
+++ b/testing/lisp/test-org-footnote.el
@@ -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=