Quellcode durchsuchen

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.
Nicolas Goaziou vor 3 Jahren
Ursprung
Commit
c839849aba
2 geänderte Dateien mit 9 neuen und 2 gelöschten Zeilen
  1. 2 1
      lisp/org-footnote.el
  2. 7 1
      testing/lisp/test-org-footnote.el

+ 2 - 1
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))))))))

+ 7 - 1
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=