GNU bug report logs - #76167
31.0.50; view-mode un-expected jump-overs

Previous Next

Package: emacs;

Reported by: Tomas Nordin <tomasn <at> posteo.net>

Date: Sun, 9 Feb 2025 22:10:01 UTC

Severity: normal

Tags: confirmed, patch

Found in version 31.0.50

Fixed in version 31.1

Done: Stefan Kangas <stefankangas <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 76167 in the body.
You can then email your comments to 76167 AT debbugs.gnu.org in the normal way.

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#76167; Package emacs. (Sun, 09 Feb 2025 22:10:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Tomas Nordin <tomasn <at> posteo.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 09 Feb 2025 22:10:02 GMT) Full text and rfc822 format available.

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

From: Tomas Nordin <tomasn <at> posteo.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 31.0.50; view-mode un-expected jump-overs
Date: Sun, 09 Feb 2025 22:09:42 +0000
[Message part 1 (text/plain, inline)]
Hello

View-mode has less like features like View-search-regexp-forward (/) and
View-search-last-regexp-forward (n). Using them I do some un-expected
observations. Here is a repro:

$ echo 1 word > words
$ echo 2 >> words
$ for n in $(seq 3 6); do echo $n word >> words; done
$ emacs -Q words
M-x view-mode
/ word
n                               ; until on line 6
p                               ; as far up as possible

The observation is that searching backwards jumps over every second
search hit when matches occur on consecutive lines.

Now do

/ !drow

And play with n and p. The bang tells to match every line that does
not match the regex. Again every second expected match is "jumped"
over. In this case also when searching forward. (Expected is that
every line is a search hit).

Maybe not many people use view-mode and it's less-like search
features, and so this was never complained about.

I find that the attached patch solves the problem. What do you think?

In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.38, cairo version 1.16.0) of 2025-02-09 built on fliptop2
Repository revision: 7e60ceeccbca1b9f67297ad7e9f11fd498b28d4d
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101007
System Description: Debian GNU/Linux 12 (bookworm)

[0001-Start-search-from-beginning-or-end-of-line.patch (text/x-diff, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76167; Package emacs. (Sat, 22 Feb 2025 09:30:06 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tomas Nordin <tomasn <at> posteo.net>
Cc: 76167 <at> debbugs.gnu.org
Subject: Re: bug#76167: 31.0.50; view-mode un-expected jump-overs
Date: Sat, 22 Feb 2025 11:29:39 +0200
> From: Tomas Nordin <tomasn <at> posteo.net>
> Date: Sun, 09 Feb 2025 22:09:42 +0000
> 
> View-mode has less like features like View-search-regexp-forward (/) and
> View-search-last-regexp-forward (n). Using them I do some un-expected
> observations. Here is a repro:
> 
> $ echo 1 word > words
> $ echo 2 >> words
> $ for n in $(seq 3 6); do echo $n word >> words; done
> $ emacs -Q words
> M-x view-mode
> / word
> n                               ; until on line 6
> p                               ; as far up as possible
> 
> The observation is that searching backwards jumps over every second
> search hit when matches occur on consecutive lines.
> 
> Now do
> 
> / !drow
> 
> And play with n and p. The bang tells to match every line that does
> not match the regex. Again every second expected match is "jumped"
> over. In this case also when searching forward. (Expected is that
> every line is a search hit).
> 
> Maybe not many people use view-mode and it's less-like search
> features, and so this was never complained about.
> 
> I find that the attached patch solves the problem. What do you think?

Thanks.

I don't use view-mode that much, so I don't have an opinion on this
behavior change.  Could people who use view-mode please chime in and
voice their opinions?




Added tag(s) patch. Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Sat, 22 Feb 2025 23:57:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76167; Package emacs. (Mon, 24 Feb 2025 20:31:02 GMT) Full text and rfc822 format available.

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

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>, Tomas Nordin <tomasn <at> posteo.net>
Cc: 76167 <at> debbugs.gnu.org
Subject: Re: bug#76167: 31.0.50; view-mode un-expected jump-overs
Date: Mon, 24 Feb 2025 14:30:15 -0600
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Tomas Nordin <tomasn <at> posteo.net>
>> Date: Sun, 09 Feb 2025 22:09:42 +0000
>>
>> View-mode has less like features like View-search-regexp-forward (/) and
>> View-search-last-regexp-forward (n). Using them I do some un-expected
>> observations. Here is a repro:
>>
>> $ echo 1 word > words
>> $ echo 2 >> words
>> $ for n in $(seq 3 6); do echo $n word >> words; done
>> $ emacs -Q words
>> M-x view-mode
>> / word
>> n                               ; until on line 6
>> p                               ; as far up as possible
>>
>> The observation is that searching backwards jumps over every second
>> search hit when matches occur on consecutive lines.
>>
>> Now do
>>
>> / !drow
>>
>> And play with n and p. The bang tells to match every line that does
>> not match the regex. Again every second expected match is "jumped"
>> over. In this case also when searching forward. (Expected is that
>> every line is a search hit).
>>
>> Maybe not many people use view-mode and it's less-like search
>> features, and so this was never complained about.
>>
>> I find that the attached patch solves the problem. What do you think?
>
> Thanks.
>
> I don't use view-mode that much, so I don't have an opinion on this
> behavior change.  Could people who use view-mode please chime in and
> voice their opinions?

I agree that it just looks like a bug.  It does seem strange that we
didn't catch it before.

The patch works here, and I don't see anything obviously wrong with it.




Added tag(s) confirmed. Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Mon, 24 Feb 2025 22:06:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76167; Package emacs. (Tue, 25 Feb 2025 20:40:01 GMT) Full text and rfc822 format available.

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

From: Tomas Nordin <tomasn <at> posteo.net>
To: Stefan Kangas <stefankangas <at> gmail.com>, Eli Zaretskii <eliz <at> gnu.org>
Cc: 76167 <at> debbugs.gnu.org
Subject: Re: bug#76167: 31.0.50; view-mode un-expected jump-overs
Date: Tue, 25 Feb 2025 20:39:16 +0000
[Message part 1 (text/plain, inline)]
Stefan Kangas <stefankangas <at> gmail.com> writes:

> Eli Zaretskii <eliz <at> gnu.org> writes:
>
>>> From: Tomas Nordin <tomasn <at> posteo.net>
>>> Date: Sun, 09 Feb 2025 22:09:42 +0000
>>>
>>> View-mode has less like features like View-search-regexp-forward (/) and
>>> View-search-last-regexp-forward (n). Using them I do some un-expected
>>> observations. Here is a repro:
>>>
>>> $ echo 1 word > words
>>> $ echo 2 >> words
>>> $ for n in $(seq 3 6); do echo $n word >> words; done
>>> $ emacs -Q words
>>> M-x view-mode
>>> / word
>>> n                               ; until on line 6
>>> p                               ; as far up as possible
>>>
>>> The observation is that searching backwards jumps over every second
>>> search hit when matches occur on consecutive lines.
>>>
>>> Now do
>>>
>>> / !drow
>>>
>>> And play with n and p. The bang tells to match every line that does
>>> not match the regex. Again every second expected match is "jumped"
>>> over. In this case also when searching forward. (Expected is that
>>> every line is a search hit).
>>>
>>> Maybe not many people use view-mode and it's less-like search
>>> features, and so this was never complained about.
>>>
>>> I find that the attached patch solves the problem. What do you think?
>>
>> Thanks.
>>
>> I don't use view-mode that much, so I don't have an opinion on this
>> behavior change.  Could people who use view-mode please chime in and
>> voice their opinions?
>
> I agree that it just looks like a bug.  It does seem strange that we
> didn't catch it before.

My estimation is that it was a mistake not discovered because matches
are rarely expected on every line in combination with the mode not being
super popular (maybe).  I don't think that the behavior described
by the recipe was ever intended.

> The patch works here, and I don't see anything obviously wrong with it.

I tried also with an even smaller patch, just changing the -1 to 0, like
this (forward-line (if (< times 0) 0 1)).  But starting the forward
search on the beginning of next line is a problem when doing inverted
searches.  (Control is propagated to `view-search-no-match-lines' which
makes its own line movements)

Attached is a patch amended with the bug number.

[0001-Start-search-from-beginning-or-end-of-line.patch (text/x-diff, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76167; Package emacs. (Tue, 25 Feb 2025 22:47:02 GMT) Full text and rfc822 format available.

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

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Tomas Nordin <tomasn <at> posteo.net>, Eli Zaretskii <eliz <at> gnu.org>
Cc: 76167 <at> debbugs.gnu.org
Subject: Re: bug#76167: 31.0.50; view-mode un-expected jump-overs
Date: Tue, 25 Feb 2025 22:46:00 +0000
Tomas Nordin <tomasn <at> posteo.net> writes:

> Stefan Kangas <stefankangas <at> gmail.com> writes:
>
>> Eli Zaretskii <eliz <at> gnu.org> writes:
>>
>>> I don't use view-mode that much, so I don't have an opinion on this
>>> behavior change.  Could people who use view-mode please chime in and
>>> voice their opinions?
>>
>> I agree that it just looks like a bug.  It does seem strange that we
>> didn't catch it before.
>
> My estimation is that it was a mistake not discovered because matches
> are rarely expected on every line in combination with the mode not being
> super popular (maybe).  I don't think that the behavior described
> by the recipe was ever intended.

Sounds plausible.

> Attached is a patch amended with the bug number.

Thanks!  If no one objects within a couple of days, I intend to push it
to master.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76167; Package emacs. (Thu, 06 Mar 2025 18:27:01 GMT) Full text and rfc822 format available.

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

From: Tomas Nordin <tomasn <at> posteo.net>
To: Stefan Kangas <stefankangas <at> gmail.com>, Eli Zaretskii <eliz <at> gnu.org>
Cc: 76167 <at> debbugs.gnu.org
Subject: Re: bug#76167: 31.0.50; view-mode un-expected jump-overs
Date: Thu, 06 Mar 2025 18:26:38 +0000
Stefan Kangas <stefankangas <at> gmail.com> writes:

> Tomas Nordin <tomasn <at> posteo.net> writes:
>
>> Stefan Kangas <stefankangas <at> gmail.com> writes:
>>
>>> Eli Zaretskii <eliz <at> gnu.org> writes:
>>>
>>>> I don't use view-mode that much, so I don't have an opinion on this
>>>> behavior change.  Could people who use view-mode please chime in and
>>>> voice their opinions?
>>>
>>> I agree that it just looks like a bug.  It does seem strange that we
>>> didn't catch it before.
>>
>> My estimation is that it was a mistake not discovered because matches
>> are rarely expected on every line in combination with the mode not being
>> super popular (maybe).  I don't think that the behavior described
>> by the recipe was ever intended.
>
> Sounds plausible.
>
>> Attached is a patch amended with the bug number.
>
> Thanks!  If no one objects within a couple of days, I intend to push it
> to master.

Friendly ping to possible objectors.  A couple of days has passed and
installation of the patch might be near.




Reply sent to Stefan Kangas <stefankangas <at> gmail.com>:
You have taken responsibility. (Fri, 07 Mar 2025 08:44:02 GMT) Full text and rfc822 format available.

Notification sent to Tomas Nordin <tomasn <at> posteo.net>:
bug acknowledged by developer. (Fri, 07 Mar 2025 08:44:02 GMT) Full text and rfc822 format available.

Message #29 received at 76167-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Tomas Nordin <tomasn <at> posteo.net>
Cc: 76167-done <at> debbugs.gnu.org
Subject: Re: bug#76167: 31.0.50; view-mode un-expected jump-overs
Date: Fri, 7 Mar 2025 08:42:49 +0000
Version: 31.1

Tomas Nordin <tomasn <at> posteo.net> writes:

> Stefan Kangas <stefankangas <at> gmail.com> writes:
>
>> Thanks!  If no one objects within a couple of days, I intend to push it
>> to master.
>
> Friendly ping to possible objectors.  A couple of days has passed and
> installation of the patch might be near.

Thanks for the ping, and thanks again for the patch!

Pushed to master and closing.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 04 Apr 2025 11:24:13 GMT) Full text and rfc822 format available.

This bug report was last modified 74 days ago.

Previous Next


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