diff options
author | Dmitry Gutov <dgutov@yandex.ru> | 2019-05-03 01:29:59 +0300 |
---|---|---|
committer | Dmitry Gutov <dgutov@yandex.ru> | 2019-05-03 01:53:11 +0300 |
commit | 5ff4bfaeec8f9c18c7dd0c8479b399b83c1e6fc2 (patch) | |
tree | 98f1d11443903284f4ec167c5137fea5fdd20f12 | |
parent | d9f62fceaf2915c67f6917c668af6ff4aacc26a7 (diff) | |
download | emacs-5ff4bfaeec8f9c18c7dd0c8479b399b83c1e6fc2.tar.gz |
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).
-rw-r--r-- | lisp/progmodes/xref.el | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index e5e59721eb3..18e97bd0f64 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -828,20 +828,25 @@ Return an alist of the form ((FILENAME . (XREF ...)) ...)." (defun xref--read-identifier (prompt) "Return the identifier at point or read it from the minibuffer." (let* ((backend (xref-find-backend)) - (id (xref-backend-identifier-at-point backend))) + (def (xref-backend-identifier-at-point backend))) (cond ((or current-prefix-arg - (not id) + (not def) (xref--prompt-p this-command)) - (completing-read (if id - (format "%s (default %s): " - (substring prompt 0 (string-match - "[ :]+\\'" prompt)) - id) - prompt) - (xref-backend-identifier-completion-table backend) - nil nil nil - 'xref--read-identifier-history id)) - (t id)))) + (let ((id + (completing-read + (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 defailt identifier")) + id))) + (t def)))) ;;; Commands |