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: Dmitry Gutov
Subject: bug#36967: 27.0.50; Duplicate lines in xref output
Date: Wed, 9 Dec 2020 05:53:55 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

On 06.12.2020 22:31, Juri Linkov wrote:
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.

Thanks! Seems to work well. Especially with this addition:

diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 9f5fc57142..9ad956d496 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -595,7 +595,8 @@ xref-prev-line

 (defun xref--item-at-point ()
   (save-excursion
-    (back-to-indentation)
+    (when (eolp)
+      (forward-char -1))
     (get-text-property (point) 'xref-item)))

 (defun xref-goto-xref (&optional quit)

However, there is a problem: when xref--insert-xrefs is called by
'M-.' that uses etags, then it signals an error:

Does it happen when two symbols do indeed get defined on the same line? Sounds like a rare situation.

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

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

Using xref-file-location-column there kind of breaks the abstraction. I was thinking more along the lines of text-prop search for the column inside the summary string:

(setq column
      (with-temp-buffer
        (insert summary)
        (goto-char (point-min))
        (let ((match
               (text-property-search-forward
                'face 'xref-match
                (lambda (target value)
                  (or (eq target value)
                      (and (listp value)
                           (member target value)))))))
          (and match
               (1- (prop-match-beginning match))))))

That's quite a bit longer, though. And it still will work only with some kinds of xrefs: I'm not sure I know how to add columns to etags either. Not to mention third-party xref backends.

The rest won't get deduplication, but that's probably all right.





reply via email to

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