bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#28439: suggestion: support case-independent xref-find-definitions pr


From: Eli Zaretskii
Subject: bug#28439: suggestion: support case-independent xref-find-definitions prompt TAB
Date: Wed, 13 Sep 2017 18:30:44 +0300

> Date: Tue, 12 Sep 2017 18:37 EDT
> From: Winston <wbe@psr.com>
> Cc: Eli Zaretskii <eliz@gnu.org>, Dmitry Gutov <dgutov@yandex.ru>
> 
> xref-find-definitions UI suggestion:
> 
>    Since xref-find-definitions is willing to match names typed in all
>    lower case to mixed case names, TAB (show alternatives) should, too.
>    If there's not already a way to make TAB do so, then a way should be
>    added.

Dmitry, how about the patch below?

--- lisp/progmodes/xref.el~0    2017-06-01 07:00:20.000000000 +0300
+++ lisp/progmodes/xref.el      2017-09-13 07:30:19.779611200 +0300
@@ -762,22 +762,25 @@
           (not (memq command (cdr xref-prompt-for-identifier)))
         (memq command xref-prompt-for-identifier))))
 
-(defun xref--read-identifier (prompt)
-  "Return the identifier at point or read it from the minibuffer."
+(defun xref--read-identifier (prompt &optional caseless)
+  "Return the identifier at point or read it from the minibuffer.
+Optional argument CASELESS means ignore letter-case when completing
+on user input."
   (let* ((backend (xref-find-backend))
          (id (xref-backend-identifier-at-point backend)))
     (cond ((or current-prefix-arg
                (not id)
                (xref--prompt-p this-command))
-           (completing-read (if id
-                                (format "%s (default %s): "
-                                        (substring prompt 0 (string-match
-                                                             "[ :]+\\'" 
prompt))
-                                        id)
-                              prompt)
-                            (xref-backend-identifier-completion-table backend)
-                            nil nil nil
-                            'xref--read-identifier-history id))
+           (let ((completion-ignore-case caseless))
+             (completing-read (if id
+                                  (format "%s (default %s): "
+                                          (substring prompt 0 (string-match
+                                                               "[ :]+\\'" 
prompt))
+                                          id)
+                                prompt)
+                              (xref-backend-identifier-completion-table 
backend)
+                              nil nil nil
+                              'xref--read-identifier-history id)))
           (t id))))
 
 
@@ -804,19 +807,19 @@
 definition for IDENTIFIER, 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."
-  (interactive (list (xref--read-identifier "Find definitions of: ")))
+  (interactive (list (xref--read-identifier "Find definitions of: " t)))
   (xref--find-definitions identifier nil))
 
 ;;;###autoload
 (defun xref-find-definitions-other-window (identifier)
   "Like `xref-find-definitions' but switch to the other window."
-  (interactive (list (xref--read-identifier "Find definitions of: ")))
+  (interactive (list (xref--read-identifier "Find definitions of: " t)))
   (xref--find-definitions identifier 'window))
 
 ;;;###autoload
 (defun xref-find-definitions-other-frame (identifier)
   "Like `xref-find-definitions' but switch to the other frame."
-  (interactive (list (xref--read-identifier "Find definitions of: ")))
+  (interactive (list (xref--read-identifier "Find definitions of: " t)))
   (xref--find-definitions identifier 'frame))
 
 ;;;###autoload





reply via email to

[Prev in Thread] Current Thread [Next in Thread]