[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/xref-find-extra 963ccb4a1fe 2/7: Xref: make xref-find-extra usef
From: |
Dmitry Gutov |
Subject: |
feature/xref-find-extra 963ccb4a1fe 2/7: Xref: make xref-find-extra useful for non-interactive use |
Date: |
Fri, 24 Nov 2023 21:13:00 -0500 (EST) |
branch: feature/xref-find-extra
commit 963ccb4a1fe9397bf02674fe42990eb9f1ba2a11
Author: João Távora <joaotavora@gmail.com>
Commit: Dmitry Gutov <dmitry@gutov.dev>
Xref: make xref-find-extra useful for non-interactive use
* lisp/progmodes/xref.el (xref-find-extra): Put interactive parts
inside interactive spec. Make versatile for non-interactive use.
---
lisp/progmodes/xref.el | 44 +++++++++++++++++++++++---------------------
1 file changed, 23 insertions(+), 21 deletions(-)
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index e1e3862256c..f7059c9f08c 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -1637,33 +1637,35 @@ Use \\[xref-go-back] to return back to where you
invoked this command."
(xref--find-definitions identifier 'frame))
;;;###autoload
-(defun xref-find-extra (identifier)
- "Find some specific kind of definition of the identifier at point.
-With prefix argument or when there's no identifier at point,
-prompt for the identifier.
+(defun xref-find-extra (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
+prompt for KIND.
If only one location is found, display it in the selected window.
Otherwise, display the list of the possible definitions in a
buffer where the user can select from the list.
Use \\[xref-go-back] to return back to where you invoked this command."
- (interactive (list
- ;; XXX: Choose kind of "extra" first? That would fail
- ;; to take advantage of the symbol-at-point, though.
- (xref--read-identifier "Find definitions of: ")))
- (let* ((kinds (xref-backend-extra-kinds (xref-find-backend) identifier))
- ;; 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"))
- (xref--show-defs
- (xref--create-fetcher identifier 'extra-defs identifier kind)
- nil)))
+ (interactive
+ (let* ((id (xref--read-identifier "Find definitions of: "))
+ ;; XXX: Choose kind of "extra" first? That would fail
+ ;; to take advantage of the symbol-at-point, though.
+ (kinds (xref-backend-extra-kinds (xref-find-backend) id))
+ ;; 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"))
+ (list id kind)))
+ (xref--show-defs
+ (xref--create-fetcher identifier 'extra-defs identifier kind)
+ nil))
;;;###autoload
(defun xref-find-references (identifier)
- 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, 2023/11/24
- 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 <=
- 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