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

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

bug#23179: 25.0.92; Restore `M-,' to continue etags search


From: Juri Linkov
Subject: bug#23179: 25.0.92; Restore `M-,' to continue etags search
Date: Thu, 11 Apr 2019 23:40:04 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu)

>>    M-x project-find-regexp
>>
>>      4. shouldn't it support an optional more compact grep-like output
>>         layout as well (where file names are on the same line with matches)?
>
> You can implement that via a custom xref-show-xrefs-function. Not trivial,
> but not a huge amount of work either.

Currently xref uses grep-like color palette, but its output layout is more like
multi-occur.  I tried to customize xref colors to match occur-like palette, but
found that colors are hard-coded, therefore the patch below.

Another problem:

  5. Files in the output of project-find-regexp are not sorted alphabetically,
     so currently the result is a mess in random order.

diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index aed92f8db6..e5e59721eb 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -448,6 +448,18 @@ xref--pop-to-location
 (defconst xref-buffer-name "*xref*"
   "The name of the buffer to show xrefs.")
 
+(defface xref-file-header '((t :inherit compilation-info))
+  "Face used to highlight file header in the xref buffer."
+  :version "27.1")
+
+(defface xref-line-number '((t :inherit compilation-line-number))
+  "Face for displaying line numbers in the xref buffer."
+  :version "27.1")
+
+(defface xref-match '((t :inherit highlight))
+  "Face used to highlight matches in the xref buffer."
+  :version "27.1")
+
 (defmacro xref--with-dedicated-window (&rest body)
   `(let* ((xref-w (get-buffer-window xref-buffer-name))
           (xref-w-dedicated (window-dedicated-p xref-w)))
@@ -737,18 +749,17 @@ xref--insert-xrefs
            for line-format = (and max-line-width
                                   (format "%%%dd: " max-line-width))
            do
-           (xref--insert-propertized '(face compilation-info) group "\n")
+           (xref--insert-propertized '(face xref-file-header) group "\n")
            (cl-loop for (xref . more2) on xrefs do
                     (with-slots (summary location) xref
                       (let* ((line (xref-location-line location))
                              (prefix
                               (if line
                                   (propertize (format line-format line)
-                                              'face 'compilation-line-number)
+                                              'face 'xref-line-number)
                                 "  ")))
                         (xref--insert-propertized
                          (list 'xref-item xref
-                               ;; 'face 'font-lock-keyword-face
                                'mouse-face 'highlight
                                'keymap xref--button-map
                                'help-echo
@@ -1159,7 +1170,7 @@ xref--collect-matches-1
              (end-column (- (match-end 0) line-beg))
              (loc (xref-make-file-location file line beg-column))
              (summary (buffer-substring line-beg line-end)))
-        (add-face-text-property beg-column end-column 'highlight
+        (add-face-text-property beg-column end-column 'xref-match
                                 t summary)
         (push (xref-make-match summary loc (- end-column beg-column))
               matches)))

reply via email to

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