Function: xref-read-identifier
xref-read-identifier is a byte-compiled function defined in
xref.el.gz.
Signature
(xref-read-identifier PROMPT &optional KIND)
Documentation
Return the identifier at point or read it from the minibuffer.
Reads and returns the identifier to use as input for the command being
executed now. If the current command should prompt, as defined in
xref-prompt-for-identifier, it uses the result of
xref-backend-identifier-at-point. Otherwise, it reads with completion
from the table returned by xref-backend-identifier-completion-table,
together with xref-backend-identifier-completion-predicate.
The argument KIND is passed on to the latter function.
Aliases
xref--read-identifier (obsolete since 32.1)
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/xref.el.gz
(defun xref-read-identifier (prompt &optional kind)
"Return the identifier at point or read it from the minibuffer.
Reads and returns the identifier to use as input for the command being
executed now. If the current command should prompt, as defined in
`xref-prompt-for-identifier', it uses the result of
`xref-backend-identifier-at-point'. Otherwise, it reads with completion
from the table returned by `xref-backend-identifier-completion-table',
together with `xref-backend-identifier-completion-predicate'.
The argument KIND is passed on to the latter function."
(let* ((backend (xref-find-backend))
(def (xref-backend-identifier-at-point backend))
(completion-ignore-case
(xref-backend-identifier-completion-ignore-case backend)))
(cond ((or current-prefix-arg
(not def)
(xref--prompt-p this-command))
(let ((id
(completing-read
;; `format-prompt' is new in Emacs 28.1
(if (fboundp 'format-prompt)
(format-prompt (substring prompt 0 (string-match
"[ :]+\\'" prompt))
def)
(if def
(format "%s (default %s): "
(substring prompt 0 (string-match
"[ :]+\\'" prompt))
def)
prompt))
(xref-backend-identifier-completion-table backend)
(xref-backend-identifier-completion-predicate backend kind)
nil nil
'xref--read-identifier-history def t)))
(if (equal id "")
(or def (user-error "There is no default identifier"))
id)))
(t def))))