Function: org-cite-basic--complete-key
org-cite-basic--complete-key is a byte-compiled function defined in
oc-basic.el.gz.
Signature
(org-cite-basic--complete-key &optional MULTIPLE)
Documentation
Prompt for a reference key and return a citation reference string.
When optional argument MULTIPLE is non-nil, prompt for multiple keys, until one of them is nil. Then return the list of reference strings selected.
Raise an error when no bibliography is set in the buffer.
Source Code
;; Defined in /usr/src/emacs/lisp/org/oc-basic.el.gz
(defun org-cite-basic--complete-key (&optional multiple)
"Prompt for a reference key and return a citation reference string.
When optional argument MULTIPLE is non-nil, prompt for multiple
keys, until one of them is nil. Then return the list of
reference strings selected.
Raise an error when no bibliography is set in the buffer."
(let* ((table
(or (org-cite-basic--key-completion-table)
(user-error "No bibliography set")))
(prompt-single
(lambda (text) (completing-read text table nil t)))
(choice-to-citation
(lambda (choice)
(let ((key (gethash choice table)))
(org-string-nw-p key)))))
(cond
((null multiple)
(funcall choice-to-citation
(completing-read "Key: " table nil t)))
(org-cite-basic-complete-key-crm-separator
(let*
((crm-separator
(pcase org-cite-basic-complete-key-crm-separator
((pred stringp)
org-cite-basic-complete-key-crm-separator)
(`dynamic
(let
((repeated-sep
(regexp-quote
(org-cite-basic--complete-key-dynamic-crm-separator
(hash-table-keys table) ";"))))
(propertize (format "[ \t]*%s[ \t]*" repeated-sep)
'separator
repeated-sep)))))
(prompt (org-cite-basic--crm-indicate-prompt "Keys: ")))
;; FIXME: Use `seq-keep' after we drop Emacs 28 support.
(delq
nil
(seq-map
choice-to-citation
(completing-read-multiple prompt table nil t)))))
(t
(let* ((keys nil)
(build-prompt
(lambda ()
(if keys
(format "Key (empty input exits) %s: "
(mapconcat #'identity (reverse keys) ";"))
"Key (empty input exits): "))))
(let ((key (funcall prompt-single (funcall build-prompt))))
(while (org-string-nw-p key)
(push (gethash key table) keys)
(setq key
(funcall prompt-single (funcall build-prompt)))))
keys)))))