[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 3e80653: xref-show-definitions-completing-read: Tune up completio
From: |
Dmitry Gutov |
Subject: |
master 3e80653: xref-show-definitions-completing-read: Tune up completion |
Date: |
Tue, 29 Dec 2020 13:25:18 -0500 (EST) |
branch: master
commit 3e80653d2970872c1b7cbd46cc9c5f7b289ca672
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>
xref-show-definitions-completing-read: Tune up completion
* 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 | 1 +
lisp/progmodes/xref.el | 14 +++++++++++---
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index dc37c5f..441eca2 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -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
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index b8a5d48..6f71256 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -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))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 3e80653: xref-show-definitions-completing-read: Tune up completion,
Dmitry Gutov <=