xref-find-by-kind cf9f8bd575e: Add :prompt-format to kind-desc plist

Dmitry Gutov <[email protected]>
Newsgroups gmane.emacs.diffs
Message-ID <[email protected]>
branch: xref-find-by-kind
commit cf9f8bd575eb133eb403b46ad0ffff3d857abe68
Author: Dmitry Gutov <[email protected]>
Commit: Dmitry Gutov <[email protected]>

    Add :prompt-format to kind-desc plist
    
    * lisp/progmodes/eglot.el (xref-backend-xref-kinds):
    Add :prompt-format to the entries.
    
    * lisp/progmodes/xref.el (xref-backend-xref-kinds):
    Allow also :prompt-format, optionally.
    (xref-find-by-kind): Use it here.
    
    * lisp/progmodes/xref.el (xref-find-by-kind):
    Also add "by" to the first prompt.
---
 lisp/progmodes/eglot.el |  9 ++++++---
 lisp/progmodes/xref.el  | 10 ++++++----
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 0e526631697..c2850d4f876 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -3831,11 +3831,14 @@ If BUFFER, switch to it before."
    nil
    (list
     (when (eglot-server-capable :declarationProvider)
-      '(:kind declaration :name "declaration" :key ?d))
+      '( :kind declaration :name "declaration" :key ?d
+         :prompt-format "Find %s of"))
     (when (eglot-server-capable :implementationProvider)
-      '(:kind implementation :name "implementation" :key ?i))
+      '( :kind implementation :name "implementation" :key ?i
+         :prompt-format "Find %s of"))
     (when (eglot-server-capable :typeDefinitionProvider)
-      '(:kind type-definition :name "type definition" :key ?t)))))
+      '( :kind type-definition :name "type definition" :key ?t
+         :prompt-format "Find %s of")))))
 
 (cl-defmethod xref-backend-xrefs-by-kind ((_backend (eql eglot)) id kind)
   ;; First check whether ID is an identifier from the workspace.
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index c5d544c137e..5f588f7c893 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -320,8 +320,9 @@ recognize and then delegate the work to an external process."
   "Return list of descriptors for xref kinds supported by BACKEND.
 
 Each descriptor is a plist with properties `:kind', `:name' and `:key'
-where the kind is a symbol value, name is a string and the key
-is a unique character that can be used to choose among them.
+where the kind is a symbol value, name is a string and the key is a
+unique character that can be used to choose among them.  Optionally, it
+can also include `:prompt-format' which defaults to \"Find %s\".
 
 Having a kind in this list means that the backend can try to find such
 xrefs in the current buffer, with no guarantee of success.  These
@@ -1835,13 +1836,14 @@ Use \\[xref-go-back] to return back to where you invoked this command.
 
 When called programmatically, KIND-DESC should be a plist that includes
 properties `:kind' and `:name'."
-  (interactive (let ((desc (xref--read-kind "Find kind")))
+  (interactive (let ((desc (xref--read-kind "Find by kind")))
                  (list
                   ;; For completeness, we can also add a specialized
                   ;; "identifier completion table for kind".  But
                   ;; probably only the elisp backend would have it.
                   (xref-read-identifier
-                   (format-message "Find %s: " (plist-get desc :name)))
+                   (format-message (or (plist-get desc :prompt-format) "Find %s")
+                                   (plist-get desc :name)))
                   desc)))
   (unless kind-desc (user-error "Have to choose the kind"))
   (xref--show-defs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.