]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix an "empty identifier" problem
authorDmitry Gutov <dgutov@yandex.ru>
Thu, 2 May 2019 22:29:59 +0000 (01:29 +0300)
committerDmitry Gutov <dgutov@yandex.ru>
Thu, 2 May 2019 22:53:11 +0000 (01:53 +0300)
* 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).

lisp/progmodes/xref.el

index e5e59721eb311b801a52b1a38b6160058b091ffa..18e97bd0f6479fe4af8600f6786daa5e7bc114b2 100644 (file)
@@ -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))))
 
 \f
 ;;; Commands