* bug#24801: 25.1; Reverse regexp search highlighting
@ 2016-10-26 16:24 Drew Adams
2016-10-26 22:42 ` npostavs
0 siblings, 1 reply; 6+ messages in thread
From: Drew Adams @ 2016-10-26 16:24 UTC (permalink / raw)
To: 24801
[-- Attachment #1: Type: text/plain, Size: 934 bytes --]
emacs -Q
Visit the attached file in text mode.
`C-M-s aa.*' and repeat. highlighting seems fine, and search moves
forward with one search hit per line, with that search hit including all
of the consecutive a's in the line.
`C-M-r' and repeat (same search pattern). Search hits are just _pairs_
of consecutive a's (so more than one hit per line), and lines that have
an odd number of consecutive a's do not include the first a in a search
hit.
This seems wrong. Am I missing something, or is this a bug?
I see this behavior in Emacs 23 and later, but not in Emacs 22 and
before, so I'm guessing this change is maybe intentional. But it's not
clear to me why it would be.
In GNU Emacs 25.1.1 (x86_64-w64-mingw32)
of 2016-09-17 built on LAPHROAIG
Windowing system distributor 'Microsoft Corp.', version 6.1.7601
Configured using:
'configure --without-dbus --without-compress-install CFLAGS=-static'
[-- Attachment #2: throw-C-M-r--aa-dot-star.txt --]
[-- Type: text/plain, Size: 276 bytes --]
a~
a
aa~
aa
aaa
aaaa
aaaaa~
aaaaa
aaaaaa~
aaaaaa
aaaaaaa
aaaaaaaa
aaaaaaaaa
aaaaaaaaaa
aaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaaa
aaaaaaaaaaaaaa
aaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaa
baaaaaaaaaaaaaaaaaaa
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#24801: 25.1; Reverse regexp search highlighting
2016-10-26 16:24 bug#24801: 25.1; Reverse regexp search highlighting Drew Adams
@ 2016-10-26 22:42 ` npostavs
2016-10-26 23:23 ` Drew Adams
2016-10-27 2:33 ` Eli Zaretskii
0 siblings, 2 replies; 6+ messages in thread
From: npostavs @ 2016-10-26 22:42 UTC (permalink / raw)
To: Drew Adams; +Cc: 24801
Drew Adams <drew.adams@oracle.com> writes:
> emacs -Q
>
> Visit the attached file in text mode.
>
> `C-M-s aa.*' and repeat. highlighting seems fine, and search moves
> forward with one search hit per line, with that search hit including all
> of the consecutive a's in the line.
>
> `C-M-r' and repeat (same search pattern). Search hits are just _pairs_
> of consecutive a's (so more than one hit per line), and lines that have
> an odd number of consecutive a's do not include the first a in a search
> hit.
>
> This seems wrong. Am I missing something, or is this a bug?
>
> I see this behavior in Emacs 23 and later, but not in Emacs 22 and
> before, so I'm guessing this change is maybe intentional. But it's not
> clear to me why it would be.
`(elisp) Regexp Search', under `re-search-backward' says:
This function is analogous to `re-search-forward', but they are not
simple mirror images. `re-search-forward' finds the match whose
beginning is as close as possible to the starting point. If
`re-search-backward' were a perfect mirror image, it would find the
match whose end is as close as possible. However, in fact it
finds the match whose beginning is as close as possible (and yet
ends before the starting point). The reason for this is that
matching a regular expression at a given spot always works from
beginning to end, and starts at a specified beginning position.
A true mirror-image of `re-search-forward' would require a special
feature for matching regular expressions from end to beginning.
It's not worth the trouble of implementing that.
And the texi source says the same at tag emacs-22.1; I've only built
Emacs back to 23.4 though, so I can't test it.
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#24801: 25.1; Reverse regexp search highlighting
2016-10-26 22:42 ` npostavs
@ 2016-10-26 23:23 ` Drew Adams
2016-10-26 23:36 ` npostavs
2016-10-27 2:33 ` Eli Zaretskii
1 sibling, 1 reply; 6+ messages in thread
From: Drew Adams @ 2016-10-26 23:23 UTC (permalink / raw)
To: npostavs; +Cc: 24801
> `(elisp) Regexp Search', under `re-search-backward' says:...
That has always been the case. The same node from Emacs 20.7 says
the same thing:
- Command: re-search-backward REGEXP &optional LIMIT NOERROR REPEAT
This function searches backward in the current buffer for a string
of text that is matched by the regular expression REGEXP, leaving
point at the beginning of the first text found.
This function is analogous to `re-search-forward', but they are not
simple mirror images. `re-search-forward' finds the match whose
beginning is as close as possible to the starting point. If
`re-search-backward' were a perfect mirror image, it would find the
match whose end is as close as possible. However, in fact it
finds the match whose beginning is as close as possible. The
reason is that matching a regular expression at a given spot
always works from beginning to end, and starts at a specified
beginning position.
A true mirror-image of `re-search-forward' would require a special
feature for matching regular expressions from end to beginning.
It's not worth the trouble of implementing that.
I don't think that description is germain to this bug report, except
insofar as what it describes is _not_ the behavior reported.
This really looks like a bug to me. But regexp search is so basic
to Emacs, and this has been like this since Emacs 23, so I can only
guess that the change in behavior must have been intentional. But
if so, why? What's the advantage/point of such behavior?
In Emacs 23.4, `C-h n', then `C-s search', shows that there were a
zillion changes in Isearch behavior. But this one is not mentioned
at all.
I have to guess (so far) that this is a bug that was introduced when
implementing one or more of those zillion documented changes. But
if so, why has no one reported it before?
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#24801: 25.1; Reverse regexp search highlighting
2016-10-26 23:23 ` Drew Adams
@ 2016-10-26 23:36 ` npostavs
2016-10-27 1:51 ` Drew Adams
0 siblings, 1 reply; 6+ messages in thread
From: npostavs @ 2016-10-26 23:36 UTC (permalink / raw)
To: Drew Adams; +Cc: 24801
Drew Adams <drew.adams@oracle.com> writes:
>> `(elisp) Regexp Search', under `re-search-backward' says:...
>
[...]
> If
> `re-search-backward' were a perfect mirror image, it would find the
> match whose end is as close as possible. However, in fact it
> finds the match whose beginning is as close as possible.
[...]
>
> I don't think that description is germain to this bug report, except
> insofar as what it describes is _not_ the behavior reported.
>
Isn't it? The match of aa.* "whose beginning is as close as possible"
when point is at the of a line of a's, is "aa". So it seems expected
that searching backwards would match pairs of a's.
> This really looks like a bug to me. But regexp search is so basic
> to Emacs, and this has been like this since Emacs 23, so I can only
> guess that the change in behavior must have been intentional. But
> if so, why? What's the advantage/point of such behavior?
Can you describe exactly how the behaviour is different in Emacs 22?
>
> In Emacs 23.4, `C-h n', then `C-s search', shows that there were a
> zillion changes in Isearch behavior. But this one is not mentioned
> at all.
>
> I have to guess (so far) that this is a bug that was introduced when
> implementing one or more of those zillion documented changes. But
> if so, why has no one reported it before?
Actually, this report looks similar to 9681, although I see no claims
there that it worked in version 22.
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#24801: 25.1; Reverse regexp search highlighting
2016-10-26 23:36 ` npostavs
@ 2016-10-27 1:51 ` Drew Adams
0 siblings, 0 replies; 6+ messages in thread
From: Drew Adams @ 2016-10-27 1:51 UTC (permalink / raw)
To: npostavs; +Cc: 24801
> Isn't it? The match of aa.* "whose beginning is as close as
> possible" when point is at the of a line of a's, is "aa". So it seems
> expected that searching backwards would match pairs of a's.
You are right.
> Can you describe exactly how the behaviour is different in Emacs 22?
I was mistaken. The same search hits are found in 22 (and before)
as now. Somehow I thought I was seeing something different when
I tried 22 and 20 earlier today.
> Actually, this report looks similar to 9681, although I see no
> claims there that it worked in version 22.
Yes, this is the same. I will close this bug.
Funny that I never noticed this before. I guess that in practice
it doesn't bite that often. It is multiple matches in the same
line that makes this really stand out as weird behavior.
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#24801: 25.1; Reverse regexp search highlighting
2016-10-26 22:42 ` npostavs
2016-10-26 23:23 ` Drew Adams
@ 2016-10-27 2:33 ` Eli Zaretskii
1 sibling, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2016-10-27 2:33 UTC (permalink / raw)
To: npostavs; +Cc: 24801
> From: npostavs@users.sourceforge.net
> Date: Wed, 26 Oct 2016 18:42:20 -0400
> Cc: 24801@debbugs.gnu.org
>
> > I see this behavior in Emacs 23 and later, but not in Emacs 22 and
> > before, so I'm guessing this change is maybe intentional. But it's not
> > clear to me why it would be.
>
> `(elisp) Regexp Search', under `re-search-backward' says:
>
> This function is analogous to `re-search-forward', but they are not
> simple mirror images. `re-search-forward' finds the match whose
> beginning is as close as possible to the starting point. If
> `re-search-backward' were a perfect mirror image, it would find the
> match whose end is as close as possible. However, in fact it
> finds the match whose beginning is as close as possible (and yet
> ends before the starting point). The reason for this is that
> matching a regular expression at a given spot always works from
> beginning to end, and starts at a specified beginning position.
>
> A true mirror-image of `re-search-forward' would require a special
> feature for matching regular expressions from end to beginning.
> It's not worth the trouble of implementing that.
>
> And the texi source says the same at tag emacs-22.1; I've only built
> Emacs back to 23.4 though, so I can't test it.
I see the same behavior in all versions, including 22.x and 21.4.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-10-27 2:33 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-26 16:24 bug#24801: 25.1; Reverse regexp search highlighting Drew Adams
2016-10-26 22:42 ` npostavs
2016-10-26 23:23 ` Drew Adams
2016-10-26 23:36 ` npostavs
2016-10-27 1:51 ` Drew Adams
2016-10-27 2:33 ` Eli Zaretskii
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).