oc: Make `org-cite-get-processor' public

* lisp/oc.el (org-cite--get-processor): rename to...
(org-cite-get-processor): ... this.
(org-cite-unregister-processor):
(org-cite-processor-has-capability-p):
(org-cite-supported-styles):
(org-cite-activate):
(org-cite-store-export-processor):
(org-cite-export-citation):
(org-cite-export-bibliography):
(org-cite-finalize-export):
(org-cite-follow):
(org-cite-insert): Apply renaming.
This commit is contained in:
Nicolas Goaziou 2021-11-30 13:32:06 +01:00
parent 5d2e2cd1bc
commit 3744713b8a
1 changed files with 21 additions and 21 deletions

View File

@ -323,15 +323,6 @@ place note numbers according to rules defined in `org-cite-note-rules'."
See `org-cite-register-processor' for more information about See `org-cite-register-processor' for more information about
processors.") 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))
(defun org-cite-register-processor (name &rest body) (defun org-cite-register-processor (name &rest body)
"Mark citation processor NAME as available. "Mark citation processor NAME as available.
@ -427,13 +418,22 @@ Return a non-nil value on a successful operation."
(seq-remove (lambda (p) (eq name (org-cite-processor-name p))) (seq-remove (lambda (p) (eq name (org-cite-processor-name p)))
org-cite--processors)))) org-cite--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))
(defun org-cite-unregister-processor (name) (defun org-cite-unregister-processor (name)
"Unregister citation processor NAME. "Unregister citation processor NAME.
NAME is a symbol. Raise an error if processor is not registered. NAME is a symbol. Raise an error if processor is not registered.
Return a non-nil value on a successful operation." Return a non-nil value on a successful operation."
(unless (and name (symbolp name)) (unless (and name (symbolp name))
(error "Invalid processor name: %S" name)) (error "Invalid processor name: %S" name))
(pcase (org-cite--get-processor name) (pcase (org-cite-get-processor name)
('nil (error "Processor %S not registered" name)) ('nil (error "Processor %S not registered" name))
(processor (processor
(setq org-cite--processors (delete processor org-cite--processors)))) (setq org-cite--processors (delete processor org-cite--processors))))
@ -443,7 +443,7 @@ Return a non-nil value on a successful operation."
"Return non-nil if PROCESSOR is able to handle CAPABILITY. "Return non-nil if PROCESSOR is able to handle CAPABILITY.
PROCESSOR is the name of a cite processor, as a symbol. CAPABILITY is PROCESSOR is the name of a cite processor, as a symbol. CAPABILITY is
`activate', `export', `follow', or `insert'." `activate', `export', `follow', or `insert'."
(let ((p (org-cite--get-processor processor))) (let ((p (org-cite-get-processor processor)))
(pcase capability (pcase capability
((guard (not p)) nil) ;undefined processor ((guard (not p)) nil) ;undefined processor
('activate (functionp (org-cite-processor-activate p))) ('activate (functionp (org-cite-processor-activate p)))
@ -676,7 +676,7 @@ strings."
(let ((collection (let ((collection
(seq-mapcat (seq-mapcat
(lambda (name) (lambda (name)
(org-cite-processor-cite-styles (org-cite--get-processor name))) (org-cite-processor-cite-styles (org-cite-get-processor name)))
(or processors (or processors
(mapcar (pcase-lambda (`(,_ . (,name . ,_))) name) (mapcar (pcase-lambda (`(,_ . (,name . ,_))) name)
org-cite-export-processors)))) org-cite-export-processors))))
@ -1200,7 +1200,7 @@ from the processor set in `org-cite-activate-processor'."
(activate (activate
(or (and name (or (and name
(org-cite-processor-has-capability-p name 'activate) (org-cite-processor-has-capability-p name 'activate)
(org-cite-processor-activate (org-cite--get-processor name))) (org-cite-processor-activate (org-cite-get-processor name)))
#'org-cite-fontify-default))) #'org-cite-fontify-default)))
(when (re-search-forward org-element-citation-prefix-re limit t) (when (re-search-forward org-element-citation-prefix-re limit t)
(let ((cite (org-with-point-at (match-beginning 0) (let ((cite (org-with-point-at (match-beginning 0)
@ -1280,7 +1280,7 @@ side-effect."
('nil nil) ('nil nil)
(`(,name . ,_) (`(,name . ,_)
(cond (cond
((not (org-cite--get-processor name)) ((not (org-cite-get-processor name))
(user-error "Unknown processor %S" name)) (user-error "Unknown processor %S" name))
((not (org-cite-processor-has-capability-p name 'export)) ((not (org-cite-processor-has-capability-p name 'export))
(user-error "Processor %S is unable to handle citation export" name))))) (user-error "Processor %S is unable to handle citation export" name)))))
@ -1293,7 +1293,7 @@ selected citation processor."
(pcase (plist-get info :cite-export) (pcase (plist-get info :cite-export)
('nil nil) ('nil nil)
(`(,p ,_ ,_) (`(,p ,_ ,_)
(funcall (org-cite-processor-export-citation (org-cite--get-processor p)) (funcall (org-cite-processor-export-citation (org-cite-get-processor p))
citation citation
(org-cite-citation-style citation info) (org-cite-citation-style citation info)
(plist-get info :back-end) (plist-get info :back-end)
@ -1309,7 +1309,7 @@ used as a communication channel."
(`(,p ,_ ,_) (`(,p ,_ ,_)
(let ((export-bibilography (let ((export-bibilography
(org-cite-processor-export-bibliography (org-cite-processor-export-bibliography
(org-cite--get-processor p)))) (org-cite-get-processor p))))
(when export-bibilography (when export-bibilography
(funcall export-bibilography (funcall export-bibilography
(org-cite-list-keys info) (org-cite-list-keys info)
@ -1410,7 +1410,7 @@ channel, as a property list."
('nil output) ('nil output)
(`(,p ,_ ,_) (`(,p ,_ ,_)
(let ((finalizer (let ((finalizer
(org-cite-processor-export-finalizer (org-cite--get-processor p)))) (org-cite-processor-export-finalizer (org-cite-get-processor p))))
(if (not finalizer) (if (not finalizer)
output output
(funcall finalizer (funcall finalizer
@ -1432,12 +1432,12 @@ ARG is the prefix argument received when calling `org-open-at-point', or nil."
(cond (cond
((null name) ((null name)
(user-error "No processor set to follow citations")) (user-error "No processor set to follow citations"))
((not (org-cite--get-processor name)) ((not (org-cite-get-processor name))
(user-error "Unknown processor %S" name)) (user-error "Unknown processor %S" name))
((not (org-cite-processor-has-capability-p name 'follow)) ((not (org-cite-processor-has-capability-p name 'follow))
(user-error "Processor %S cannot follow citations" name)) (user-error "Processor %S cannot follow citations" name))
(t (t
(let ((follow (org-cite-processor-follow (org-cite--get-processor name)))) (let ((follow (org-cite-processor-follow (org-cite-get-processor name))))
(funcall follow datum arg)))))) (funcall follow datum arg))))))
@ -1653,13 +1653,13 @@ ARG is the prefix argument received when calling interactively the function."
(cond (cond
((null name) ((null name)
(user-error "No processor set to insert citations")) (user-error "No processor set to insert citations"))
((not (org-cite--get-processor name)) ((not (org-cite-get-processor name))
(user-error "Unknown processor %S" name)) (user-error "Unknown processor %S" name))
((not (org-cite-processor-has-capability-p name 'insert)) ((not (org-cite-processor-has-capability-p name 'insert))
(user-error "Processor %S cannot insert citations" name)) (user-error "Processor %S cannot insert citations" name))
(t (t
(let ((context (org-element-context)) (let ((context (org-element-context))
(insert (org-cite-processor-insert (org-cite--get-processor name)))) (insert (org-cite-processor-insert (org-cite-get-processor name))))
(cond (cond
((memq (org-element-type context) '(citation citation-reference)) ((memq (org-element-type context) '(citation citation-reference))
(funcall insert context arg)) (funcall insert context arg))