Function: xref--read-identifier

xref--read-identifier is a byte-compiled function defined in xref.el.gz.

Signature

(xref--read-identifier PROMPT)

Documentation

Return the identifier at point or read it from the minibuffer.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/xref.el.gz
(defun xref--read-identifier (prompt)
  "Return the identifier at point or read it from the minibuffer."
  (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)
                   nil nil nil
                   'xref--read-identifier-history def)))
             (if (equal id "")
                 (or def (user-error "There is no default identifier"))
               id)))
          (t def))))