all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Juri Linkov <juri@linkov.net>
Cc: 36967@debbugs.gnu.org
Subject: bug#36967: 27.0.50; Duplicate lines in xref output
Date: Thu, 3 Dec 2020 03:35:19 +0200	[thread overview]
Message-ID: <20e61edd-9ee6-deab-7ff4-94b0ba527dc4@yandex.ru> (raw)
In-Reply-To: <87wnxz6glx.fsf@mail.linkov.net>

On 02.12.2020 23:30, Juri Linkov wrote:
>>> I tried to use project-find-regexp more often than rgrep,
>>> but unfortunately xref still has a fundamental flaw:
>>> 0. emacs -Q
>>> 1. M-x project-find-regexp RET regexp RET
>>> 2. The output buffer *xref* contains duplicate lines
>>>      when regexp is found on the same line several times,
>>>      each duplicate output line has separate highlighting
>>>      for every regexp occurrence.
>>
>> I don't know how "fundamental" it is, but indeed, it's somewhat of
>> a drawback. Suggestions for improving it (API change and/or implementation
>> change) are welcome.
> 
> Here is the patch that makes the broken

Pretty harsh there.

> project-find-regexp usable:

Okay, impressions:

When the line has two matches, the new code only collects the first 
match. So 'matches' is always an list with one element (or nil).

Upside: repetitions are not shown anymore, but the match highlighting is 
still applied.

Downside: xref-query-replace-in-results won't work in those cases 
anymore; it will only replace one match. Because the list only contains 
one location, and not all of them. And that command is pretty nice to have.

Here's an alternative proposal:

Combine the lines inside the rendering code instead.

So each xref will have a separate location, but then xref--insert-xrefs 
will see that xref-location-line value repeats across some consecutive 
locations, and will combine them into single line with some text 
property magic (basically, copying the summary from one of them, and 
then applying 'xref-item and 'face properties appropriately). This 
retains the xref item semantics (as opposed to, say, associating an xref 
item with multiple locations). And _hopefully_ the replace-related code 
won't need any changes.

As a bonus, 'n' and 'p' should then automatically change behavior to 
jump between locations when they are on the same line.





  reply	other threads:[~2020-12-03  1:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-07 21:52 bug#36967: 27.0.50; Duplicate lines in xref output Juri Linkov
2019-08-07 22:13 ` Dmitry Gutov
2020-12-02 21:30   ` Juri Linkov
2020-12-03  1:35     ` Dmitry Gutov [this message]
2020-12-03 21:30       ` Juri Linkov
2020-12-03 23:44         ` Dmitry Gutov
2020-12-06 20:31           ` Juri Linkov
2020-12-09  3:53             ` Dmitry Gutov
2020-12-09 13:57               ` Dmitry Gutov
2020-12-21  1:42                 ` Dmitry Gutov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20e61edd-9ee6-deab-7ff4-94b0ba527dc4@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=36967@debbugs.gnu.org \
    --cc=juri@linkov.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.