[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/xref-find-extra 1de548833d2 5/7: Rename xref-find-definitions-by
From: |
Dmitry Gutov |
Subject: |
feature/xref-find-extra 1de548833d2 5/7: Rename xref-find-definitions-by-kind to xref-find-all-definitions |
Date: |
Fri, 24 Nov 2023 21:13:01 -0500 (EST) |
branch: feature/xref-find-extra
commit 1de548833d2c31afd3afe3180870b3c6d575f00e
Author: Dmitry Gutov <dmitry@gutov.dev>
Commit: Dmitry Gutov <dmitry@gutov.dev>
Rename xref-find-definitions-by-kind to xref-find-all-definitions
* lisp/progmodes/xref.el (xref-find-all-definitions): Rename from
'xref-find-definitions-by-kind' and change accordingly. Meaning
it collects definitions from all "kinds" by default (passing
through 'delete-dups', which only works if the items are
structurally the same) and asks for specific KIND only when called
with a prefix argument.
---
lisp/progmodes/xref.el | 38 ++++++++++++++++++++++++++++----------
1 file changed, 28 insertions(+), 10 deletions(-)
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 5f76ec440b4..59e496cb08c 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -1640,10 +1640,11 @@ Use \\[xref-go-back] to return back to where you
invoked this command."
(xref--find-definitions identifier 'frame))
;;;###autoload
-(defun xref-find-definitions-by-kind (identifier &optional kind)
+(defun xref-find-all-definitions (identifier &optional kind)
"Find definitions of specific KIND for IDENTIFIER.
Interactively with prefix argument, or when there's no identifier
-at point, prompt for the identifier. Interactively, always
+at point, prompt for the identifier. Interactively, show matches
+for all supported kinds. When invoked with prefix argument,
prompt for KIND.
If only one location is found, display it in the selected window.
@@ -1656,18 +1657,35 @@ Use \\[xref-go-back] to return back to where you
invoked this command."
;; XXX: Choose the definition kind first? That would fail
;; to take advantage of the symbol-at-point, though.
(kinds (xref-backend-definition-kinds (xref-find-backend) id))
+ (_ (unless kinds (user-error "No supported kinds")))
;; FIXME: We should probably skip asking when there's just
;; one available kind, but let's keep completing-read while
;; collecting the initial feedback about the interface.
- (kind ;; (if (cdr kinds)
- (completing-read "Definition kind: " kinds nil t nil nil (car
kinds))
- ;; (car kinds)
- ;; )
- ))
- (unless kind (user-error "No supported kinds"))
+ (kind
+ (if current-prefix-arg
+ ;; (if (cdr kinds)
+ (completing-read "Definition kind: " kinds nil t nil nil (car
kinds))
+ ;; (car kinds)
+ 'all)))
(list id kind)))
(xref--show-defs
- (xref--create-fetcher identifier 'definitions-by-kind identifier kind)
+ (if (eq kind 'all)
+ (let ((fetchers
+ (mapcar (lambda (kind)
+ (xref--create-fetcher identifier 'definitions-by-kind
+ identifier kind))
+ (xref-backend-definition-kinds (xref-find-backend)
identifier))))
+ (lambda ()
+ (or
+ (delete-dups
+ (apply #'nconc (mapcar
+ (lambda (fetcher)
+ (condition-case nil
+ (funcall fetcher)
+ (user-error nil)))
+ fetchers)))
+ (user-error "Nothing found"))))
+ (xref--create-fetcher identifier 'definitions-by-kind identifier kind))
nil))
;;;###autoload
@@ -1770,7 +1788,7 @@ output of this command when the backend is etags."
;;;###autoload (define-key esc-map [?\C-,] #'xref-go-forward)
;;;###autoload (define-key esc-map "?" #'xref-find-references)
;;;###autoload (define-key esc-map [?\C-.] #'xref-find-apropos)
-;;;###autoload (define-key esc-map "'" #'xref-find-definitions-by-kind)
+;;;###autoload (define-key esc-map "'" #'xref-find-all-definitions)
;;;###autoload (define-key ctl-x-4-map "."
#'xref-find-definitions-other-window)
;;;###autoload (define-key ctl-x-5-map "." #'xref-find-definitions-other-frame)
- branch feature/xref-find-extra created (now 93ee5cd076e), Dmitry Gutov, 2023/11/24
- feature/xref-find-extra 1de548833d2 5/7: Rename xref-find-definitions-by-kind to xref-find-all-definitions,
Dmitry Gutov <=
- feature/xref-find-extra 55f2657ca4b 6/7: Add per-kind commands with bindings, Dmitry Gutov, 2023/11/24
- feature/xref-find-extra 279203199a2 3/7: Eglot: use new xref-find-extra feature of Xref, Dmitry Gutov, 2023/11/24
- feature/xref-find-extra 963ccb4a1fe 2/7: Xref: make xref-find-extra useful for non-interactive use, Dmitry Gutov, 2023/11/24
- feature/xref-find-extra 26121b4c49a 1/7: Xref: add xref-find-extra command, Dmitry Gutov, 2023/11/24
- feature/xref-find-extra 49c435914e4 4/7: Rename the xref-backend-extra-* methods to use the term definition, Dmitry Gutov, 2023/11/24
- feature/xref-find-extra 93ee5cd076e 7/7: Use the renamed 'xref-find-all-definitions' in Eglot, Dmitry Gutov, 2023/11/24