diff --git a/lisp/oc.el b/lisp/oc.el index 17b577571..85e1b6815 100644 --- a/lisp/oc.el +++ b/lisp/oc.el @@ -1436,7 +1436,11 @@ CONTEXT is the element or object at point, as returned by `org-element-context'. (skip-chars-backward " \r\t\n") (if (eq (org-element-class context) 'object) (point) (line-beginning-position 2))))) - ;; At the start of a list item is fine, as long as the bullet is unaffected. + ;; At the beginning of a footnote definition, right after the + ;; label, is OK. + ((eq type 'footnote-definition) (looking-at (rx space))) + ;; At the start of a list item is fine, as long as the bullet is + ;; unaffected. ((eq type 'item) (> (point) (+ (org-element-property :begin context) (current-indentation) diff --git a/testing/lisp/test-oc.el b/testing/lisp/test-oc.el index 995559b9c..80d74be95 100644 --- a/testing/lisp/test-oc.el +++ b/testing/lisp/test-oc.el @@ -1792,6 +1792,49 @@ arguments. Replace citation with \"@\" character in the output." (org-cite-register-processor 'foo :insert (lambda (_ _) (throw :exit 'success))) (call-interactively #'org-cite-insert)))) + ;; Allow inserting citations at the beginning of a footnote + ;; definition, right after the label. + (should + (eq 'success + (catch :exit + (org-test-with-temp-text "[fn:1]" + (let ((org-cite--processors nil) + (org-cite-insert-processor 'foo)) + (org-cite-register-processor 'foo + :insert (lambda (_ _) (throw :exit 'success))) + (call-interactively #'org-cite-insert)))))) + (should + (eq 'success + (catch :exit + (org-test-with-temp-text "[fn:1] " + (let ((org-cite--processors nil) + (org-cite-insert-processor 'foo)) + (org-cite-register-processor 'foo + :insert (lambda (_ _) (throw :exit 'success))) + (call-interactively #'org-cite-insert)))))) + (should + (eq 'success + (catch :exit + (org-test-with-temp-text "[fn:1]\nParagraph" + (let ((org-cite--processors nil) + (org-cite-insert-processor 'foo)) + (org-cite-register-processor 'foo + :insert (lambda (_ _) (throw :exit 'success))) + (call-interactively #'org-cite-insert)))))) + (should-error + (org-test-with-temp-text "[fn:1]" + (let ((org-cite--processors nil) + (org-cite-insert-processor 'foo)) + (org-cite-register-processor 'foo + :insert (lambda (_ _) (throw :exit 'success))) + (call-interactively #'org-cite-insert)))) + (should-error + (org-test-with-temp-text "[fn:1]" + (let ((org-cite--processors nil) + (org-cite-insert-processor 'foo)) + (org-cite-register-processor 'foo + :insert (lambda (_ _) (throw :exit 'success))) + (call-interactively #'org-cite-insert)))) ;; Allow inserting citations in captions. (should (eq 'success