]> git.eshelyaron.com Git - emacs.git/commitdiff
xref-show-definitions-completing-read: Tune up completion
authorDmitry Gutov <dgutov@yandex.ru>
Tue, 29 Dec 2020 18:24:46 +0000 (20:24 +0200)
committerDmitry Gutov <dgutov@yandex.ru>
Tue, 29 Dec 2020 18:25:03 +0000 (20:25 +0200)
* lisp/minibuffer.el (completion-category-defaults)
Use 'substring' completion style for 'xref-location' category by
default.

* lisp/progmodes/xref.el (xref-show-definitions-completing-read):
Assign the 'xref-location' category to the completions. Pass
REQUIRE-MATCH=t.

lisp/minibuffer.el
lisp/progmodes/xref.el

index dc37c5f44763c7fc5df07cd4c9e0f4c0590bc2ce..441eca214bda3b3e144934b364aafd905b8828bb 100644 (file)
@@ -956,6 +956,7 @@ styles for specific categories, such as files, buffers, etc."
     ;; A new style that combines substring and pcm might be better,
     ;; e.g. one that does not anchor to bos.
     (project-file (styles . (substring)))
+    (xref-location (styles . (substring)))
     (info-menu (styles . (basic substring))))
   "Default settings for specific completion categories.
 Each entry has the shape (CATEGORY . ALIST) where ALIST is
index b8a5d481190e3be14137d167ced16567b3f11592..6f7125670bdd21dc8779d7d196c682a574fc60e1 100644 (file)
@@ -1018,9 +1018,17 @@ between them by typing in the minibuffer with completion."
 
     (setq xref (if (not (cdr xrefs))
                    (car xrefs)
-                 (cdr (assoc (completing-read "Jump to definition: "
-                                              (reverse xref-alist-with-line-info))
-                             xref-alist-with-line-info))))
+                 (let* ((collection (reverse xref-alist-with-line-info))
+                        (ctable
+                         (lambda (string pred action)
+                           (cond
+                            ((eq action 'metadata)
+                             '(metadata . ((category . xref-location))))
+                            (t
+                             (complete-with-action action collection string pred))))))
+                   (cdr (assoc (completing-read "Choose definition: "
+                                                ctable nil t)
+                               collection)))))
 
     (xref-pop-to-location xref (assoc-default 'display-action alist))))