aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Gutov2019-05-03 01:29:59 +0300
committerDmitry Gutov2019-05-03 01:53:11 +0300
commit5ff4bfaeec8f9c18c7dd0c8479b399b83c1e6fc2 (patch)
tree98f1d11443903284f4ec167c5137fea5fdd20f12
parentd9f62fceaf2915c67f6917c668af6ff4aacc26a7 (diff)
downloademacs-5ff4bfaeec8f9c18c7dd0c8479b399b83c1e6fc2.tar.gz
emacs-5ff4bfaeec8f9c18c7dd0c8479b399b83c1e6fc2.zip
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.el29
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 ...)) ...)."
828(defun xref--read-identifier (prompt) 828(defun xref--read-identifier (prompt)
829 "Return the identifier at point or read it from the minibuffer." 829 "Return the identifier at point or read it from the minibuffer."
830 (let* ((backend (xref-find-backend)) 830 (let* ((backend (xref-find-backend))
831 (id (xref-backend-identifier-at-point backend))) 831 (def (xref-backend-identifier-at-point backend)))
832 (cond ((or current-prefix-arg 832 (cond ((or current-prefix-arg
833 (not id) 833 (not def)
834 (xref--prompt-p this-command)) 834 (xref--prompt-p this-command))
835 (completing-read (if id 835 (let ((id
836 (format "%s (default %s): " 836 (completing-read
837 (substring prompt 0 (string-match 837 (if def
838 "[ :]+\\'" prompt)) 838 (format "%s (default %s): "
839 id) 839 (substring prompt 0 (string-match
840 prompt) 840 "[ :]+\\'" prompt))
841 (xref-backend-identifier-completion-table backend) 841 def)
842 nil nil nil 842 prompt)
843 'xref--read-identifier-history id)) 843 (xref-backend-identifier-completion-table backend)
844 (t id)))) 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))))
845 850
846 851
847;;; Commands 852;;; Commands