oc: Allow citations at footnote definition start

* lisp/oc.el (org-cite--allowed-p): Allow citations at footnote
definition start.
* testing/lisp/test-oc.el (test-org-cite/insert-capability): Add tests.
This commit is contained in:
Nicolas Goaziou 2021-10-06 14:28:04 +02:00
parent 67b613a115
commit 9b063251cf
2 changed files with 48 additions and 1 deletions

View File

@ -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)

View File

@ -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]<point>"
(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] <point>"
(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]<point>\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<point>]"
(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 "<point>[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