Skip to content

Commit 5ff4bfa

Browse files
committed
Fix an "empty identifier" problem
* lisp/progmodes/xref.el (xref--read-identifier): Abort on empty input if there is no default (https://lists.gnu.org/archive/html/help-gnu-emacs/2019-05/msg00012.html).
1 parent d9f62fc commit 5ff4bfa

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

lisp/progmodes/xref.el

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -828,20 +828,25 @@ Return an alist of the form ((FILENAME . (XREF ...)) ...)."
828828
(defun xref--read-identifier (prompt)
829829
"Return the identifier at point or read it from the minibuffer."
830830
(let* ((backend (xref-find-backend))
831-
(id (xref-backend-identifier-at-point backend)))
831+
(def (xref-backend-identifier-at-point backend)))
832832
(cond ((or current-prefix-arg
833-
(not id)
833+
(not def)
834834
(xref--prompt-p this-command))
835-
(completing-read (if id
836-
(format "%s (default %s): "
837-
(substring prompt 0 (string-match
838-
"[ :]+\\'" prompt))
839-
id)
840-
prompt)
841-
(xref-backend-identifier-completion-table backend)
842-
nil nil nil
843-
'xref--read-identifier-history id))
844-
(t id))))
835+
(let ((id
836+
(completing-read
837+
(if def
838+
(format "%s (default %s): "
839+
(substring prompt 0 (string-match
840+
"[ :]+\\'" prompt))
841+
def)
842+
prompt)
843+
(xref-backend-identifier-completion-table backend)
844+
nil nil nil
845+
'xref--read-identifier-history def)))
846+
(if (equal id "")
847+
(or def (user-error "There is no defailt identifier"))
848+
id)))
849+
(t def))))
845850

846851

847852
;;; Commands

0 commit comments

Comments
 (0)