branch: externals/org commit 0bf211a3401aad7f6468b10c19d0a5b908212e54 Author: Nicolas Goaziou <m...@nicolasgoaziou.fr> Commit: Nicolas Goaziou <m...@nicolasgoaziou.fr>
oc: Opportunistically load processors * lisp/oc.el (org-cite--get-processor): Try requiring 'oc-NAME where name is the name of the processor used. (org-cite-register-processor): Do not use `org-cite--get-processor' to avoid circular requires. Suggested-by: Timothy <tecos...@gmail.com> <http://lists.gnu.org/r/emacs-orgmode/2021-11/msg00664.html> --- lisp/oc.el | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lisp/oc.el b/lisp/oc.el index c61913c..b31ee92 100644 --- a/lisp/oc.el +++ b/lisp/oc.el @@ -326,6 +326,9 @@ processors.") (defun org-cite--get-processor (name) "Return citation processor named after symbol NAME. Return nil if no such processor is found." + ;; Opportunistically try to load the library providing the + ;; processor. + (require (intern (concat "oc-" (symbol-name name))) nil t) (seq-find (lambda (p) (eq name (org-cite-processor-name p))) org-cite--processors)) @@ -419,10 +422,10 @@ Return a non-nil value on a successful operation." (declare (indent 1)) (unless (and name (symbolp name)) (error "Invalid processor name: %S" name)) - (when (org-cite--get-processor name) - (org-cite-unregister-processor name)) - (push (apply #'org-cite--make-processor :name name body) - org-cite--processors)) + (setq org-cite--processors + (cons (apply #'org-cite--make-processor :name name body) + (seq-remove (lambda (p) (eq name (org-cite-processor-name p))) + org-cite--processors)))) (defun org-cite-unregister-processor (name) "Unregister citation processor NAME.