GNU bug report logs - #60285
xref-query-replace-in-results could show an arrow pointing to the current item being replaced

Previous Next

Package: emacs;

Reported by: Daniel Martín <mardani29 <at> yahoo.es>

Date: Fri, 23 Dec 2022 19:17:02 UTC

Severity: wishlist

To reply to this bug, email your comments to 60285 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#60285; Package emacs. (Fri, 23 Dec 2022 19:17:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Daniel Martín <mardani29 <at> yahoo.es>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 23 Dec 2022 19:17:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Daniel Martín <mardani29 <at> yahoo.es>
To: bug-gnu-emacs <at> gnu.org
Subject: xref-query-replace-in-results could show an arrow pointing to the
 current item being replaced
Date: Fri, 23 Dec 2022 20:16:24 +0100
Severity: wishlist

When you use xref-query-replace-in-results to replace some references,
it'd be great if the xref buffer showed an overlay arrow (see
xref--set-arrow) pointing to the reference being edited.  That'd give
better context about the reference that is being edited and the global
progress of the query replace operation.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60285; Package emacs. (Sat, 24 Dec 2022 17:46:01 GMT) Full text and rfc822 format available.

Message #8 received at 60285 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Daniel Martín <mardani29 <at> yahoo.es>, 60285 <at> debbugs.gnu.org
Subject: Re: bug#60285: xref-query-replace-in-results could show an arrow
 pointing to the current item being replaced
Date: Sat, 24 Dec 2022 19:45:01 +0200
[Message part 1 (text/plain, inline)]
On 23/12/2022 21:16, Daniel Martín via Bug reports for GNU Emacs, the 
Swiss army knife of text editors wrote:
> Severity: wishlist
> 
> When you use xref-query-replace-in-results to replace some references,
> it'd be great if the xref buffer showed an overlay arrow (see
> xref--set-arrow) pointing to the reference being edited.  That'd give
> better context about the reference that is being edited and the global
> progress of the query replace operation.

SGTM.

Here's a patch which seems to work. It's a little tricky, though, and 
I'm at a loss with better variable names in some places.

Wish we had some unit tests here.
[xref-replace-with-arrow.diff (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60285; Package emacs. (Sun, 01 Jan 2023 11:24:01 GMT) Full text and rfc822 format available.

Message #11 received at 60285 <at> debbugs.gnu.org (full text, mbox):

From: Daniel Martín <mardani29 <at> yahoo.es>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 60285 <at> debbugs.gnu.org
Subject: Re: bug#60285: xref-query-replace-in-results could show an arrow
 pointing to the current item being replaced
Date: Sun, 01 Jan 2023 12:23:23 +0100
Dmitry Gutov <dgutov <at> yandex.ru> writes:

> On 23/12/2022 21:16, Daniel Martín via Bug reports for GNU Emacs, the
> Swiss army knife of text editors wrote:
>> Severity: wishlist
>> When you use xref-query-replace-in-results to replace some
>> references,
>> it'd be great if the xref buffer showed an overlay arrow (see
>> xref--set-arrow) pointing to the reference being edited.  That'd give
>> better context about the reference that is being edited and the global
>> progress of the query replace operation.
>
> SGTM.
>
> Here's a patch which seems to work. It's a little tricky, though, and
> I'm at a loss with better variable names in some places.
>
> Wish we had some unit tests here.

Thanks.  It works well, but there are some corner cases.  For example,
as you can undo or go to the previous match during the query replace,
the arrow should point to the previous result, if possible.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60285; Package emacs. (Wed, 04 Jan 2023 23:49:02 GMT) Full text and rfc822 format available.

Message #14 received at 60285 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Daniel Martín <mardani29 <at> yahoo.es>,
 Juri Linkov <juri <at> linkov.net>
Cc: 60285 <at> debbugs.gnu.org
Subject: Re: bug#60285: xref-query-replace-in-results could show an arrow
 pointing to the current item being replaced
Date: Thu, 5 Jan 2023 01:48:21 +0200
On 01/01/2023 13:23, Daniel Martín wrote:
> Dmitry Gutov<dgutov <at> yandex.ru>  writes:
> 
>> On 23/12/2022 21:16, Daniel Martín via Bug reports for GNU Emacs, the
>> Swiss army knife of text editors wrote:
>>> Severity: wishlist
>>> When you use xref-query-replace-in-results to replace some
>>> references,
>>> it'd be great if the xref buffer showed an overlay arrow (see
>>> xref--set-arrow) pointing to the reference being edited.  That'd give
>>> better context about the reference that is being edited and the global
>>> progress of the query replace operation.
>> SGTM.
>>
>> Here's a patch which seems to work. It's a little tricky, though, and
>> I'm at a loss with better variable names in some places.
>>
>> Wish we had some unit tests here.
> Thanks.  It works well, but there are some corner cases.

Thanks for testing.

> For example,
> as you can undo or go to the previous match during the query replace,
> the arrow should point to the previous result, if possible.

Hmm, I'm not sure how to implement that. Some new hook inside 
perform-replace?

Maybe Juri has some ideas.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60285; Package emacs. (Thu, 05 Jan 2023 17:57:03 GMT) Full text and rfc822 format available.

Message #17 received at 60285 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 60285 <at> debbugs.gnu.org,
 Daniel Martín <mardani29 <at> yahoo.es>
Subject: Re: bug#60285: xref-query-replace-in-results could show an arrow
 pointing to the current item being replaced
Date: Thu, 05 Jan 2023 19:55:08 +0200
>> For example,
>> as you can undo or go to the previous match during the query replace,
>> the arrow should point to the previous result, if possible.
>
> Hmm, I'm not sure how to implement that. Some new hook inside
> perform-replace?
>
> Maybe Juri has some ideas.

Indeed, there is a special hook for such cases:
'replace-update-post-hook'.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60285; Package emacs. (Mon, 16 Jan 2023 01:43:02 GMT) Full text and rfc822 format available.

Message #20 received at 60285 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Juri Linkov <juri <at> linkov.net>
Cc: 60285 <at> debbugs.gnu.org, Daniel Martín <mardani29 <at> yahoo.es>
Subject: Re: bug#60285: xref-query-replace-in-results could show an arrow
 pointing to the current item being replaced
Date: Mon, 16 Jan 2023 03:41:56 +0200
On 05/01/2023 19:55, Juri Linkov wrote:
>>> For example,
>>> as you can undo or go to the previous match during the query replace,
>>> the arrow should point to the previous result, if possible.
>> Hmm, I'm not sure how to implement that. Some new hook inside
>> perform-replace?
>>
>> Maybe Juri has some ideas.
> Indeed, there is a special hook for such cases:
> 'replace-update-post-hook'.

That one seems problematic. First of all, I think (?) that we need to 
update the arrow's position when the replacement prompt appears, not 
after a replacement.

Second, it fires in all cases -- whether the replacement is going 
forward, or it being undone, is that right? I suppose this will mean 
we'll need to maintain a reverse mapping: from the markers back to the 
Xref buffer lines. Hopefully they will be in expected position after the 
"undo" actions too.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60285; Package emacs. (Mon, 16 Jan 2023 17:47:02 GMT) Full text and rfc822 format available.

Message #23 received at 60285 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 60285 <at> debbugs.gnu.org,
 Daniel Martín <mardani29 <at> yahoo.es>
Subject: Re: bug#60285: xref-query-replace-in-results could show an arrow
 pointing to the current item being replaced
Date: Mon, 16 Jan 2023 19:39:38 +0200
>> Indeed, there is a special hook for such cases:
>> 'replace-update-post-hook'.
>
> That one seems problematic. First of all, I think (?) that we need to
> update the arrow's position when the replacement prompt appears, not after
> a replacement.

Maybe another pre-hook is needed that will run before the prompt?

> Second, it fires in all cases -- whether the replacement is going forward,
> or it being undone, is that right? I suppose this will mean we'll need to
> maintain a reverse mapping: from the markers back to the Xref buffer
> lines. Hopefully they will be in expected position after the "undo" actions
> too.

This needs more experimentation to see how it works.




This bug report was last modified 1 year and 345 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.