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

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

bug#36967: 27.0.50; Duplicate lines in xref output


From: Juri Linkov
Subject: bug#36967: 27.0.50; Duplicate lines in xref output
Date: Sun, 06 Dec 2020 22:31:02 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

> I'm _slightly_ worried about extra garbage if we do seq-group-by twice
> (with an extra list for every line, even those that don't need it), but
> that's what benchmarking is for (can do that later).

I'm worried about extra garbage too, so this patch doesn't cause extra lists.

diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 9f5fc57142..260623180e 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -832,17 +832,28 @@ xref--insert-xrefs
                                (length (and line (format "%d" line)))))
            for line-format = (and max-line-width
                                   (format "%%%dd: " max-line-width))
+           with prev-line-key = nil
            do
            (xref--insert-propertized '(face xref-file-header xref-group t)
                                      group "\n")
            (cl-loop for (xref . more2) on xrefs do
                     (with-slots (summary location) xref
                       (let* ((line (xref-location-line location))
+                             (line-key (list (xref-location-group location) 
line))
                              (prefix
                               (if line
                                   (propertize (format line-format line)
                                               'face 'xref-line-number)
                                 "  ")))
+                        (when (equal prev-line-key line-key)
+                          (let ((column (xref-file-location-column location)))
+                            (delete-region
+                             (save-excursion
+                               (forward-line -1)
+                               (move-to-column (+ (length prefix) column))
+                               (point))
+                             (point))
+                            (setq summary (substring summary column) prefix 
"")))
                         (xref--insert-propertized
                          (list 'xref-item xref
                                'mouse-face 'highlight
@@ -850,7 +861,8 @@ xref--insert-xrefs
                                'help-echo
                                (concat "mouse-2: display in another window, "
                                        "RET or mouse-1: follow reference"))
-                         prefix summary)))
+                         prefix summary)
+                        (setq prev-line-key line-key)))
                     (insert "\n"))))
 
 (defun xref--analyze (xrefs)
However, there is a problem: when xref--insert-xrefs is called by
'M-.' that uses etags, then it signals an error:

  cl-no-applicable-method xref-file-location-column

And I don't know how to fix etags to add columns.

reply via email to

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