Subject: bug#76167: 31.0.50; view-mode un-expected jump-overs

From: Stefan Kangas <[email-masked]>
Date: Mon, 24 Feb 2025 14:30:15 -0600

Eli Zaretskii <[email-masked]> writes:

>> From: Tomas Nordin <[email-masked]>
>> 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.