unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [paul@wolfbone.ath.cx: Re: re-builder bug(s)]
@ 2007-03-06 22:36 Richard Stallman
  2007-03-09 16:38 ` Detlev Zundel
  2007-03-09 16:55 ` Oliver Scholz
  0 siblings, 2 replies; 11+ messages in thread
From: Richard Stallman @ 2007-03-06 22:36 UTC (permalink / raw)
  To: Detlev Zundel; +Cc: emacs-devel

This is the bug report.  Can you fix it for us?

I don't know whether Detlev Zundel is still available,
so I cc'd this to emacs-devel.  If Detlev doesn't fix this,
I hope that someone else will do so.

------- Start of forwarded message -------
To: rms@gnu.org
Cc: emacs-pretest-bug@gnu.org
Subject: Re: re-builder bug(s)
From: paul@wolfbone.ath.cx (P.L.Hayes)
Date: Tue, 06 Mar 2007 07:33:44 +0000
In-Reply-To: <E1HOL51-0005fh-ON@fencepost.gnu.org> (Richard Stallman's message of "Mon\, 05 Mar 2007 16\:50\:51 -0500")
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO 
	autolearn=failed version=3.0.4

Richard Stallman <rms@gnu.org> writes:

> I fixed the bug in the custom type, I think.
>
>     I also find (and I'm not quite sure whether it's a real bug or just
>     something I haven't understood about regexps or re-builder) that
>     expressions such as "\\>" and "$" in the re-builder buffer don't work
>     (and are flagged as "*invalid*" in the modeline) but ".\\>" and ".$",
>
> Would you please send a precise, complete test case for this?

Open a new buffer, put it in text mode and insert a line of text into it:

     C-x b *reb-test* RET M-x text-mode RET
     Kidman's publicist, Catherine Olim, said the star was trying to shake zombies off the bonnet of her Jaguar when the car spun off the road. RET

Try to use re-builder to count the number of words in the buffer:

    M-x re-builder RET
    \\>

As soon as the first `\' is entered between the `"'s, in the
*RE-Builder* buffer, "*invalid*" appears in the modeline.
Now replace the regexp in the *RE-Builder* buffer with another:

    DEL DEL DEL
    .\\>

Success! - the last character of each word in the *reb-test* buffer
has been highlighted and a message, "25 matches" has appeared in the
minibuffer. Likewise, the regexp, "^" will not find the empty string
at the beginning of the buffer but "^." will and "$" will not find the
end of the buffer but ".$" will.
------- End of forwarded message -------

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [paul@wolfbone.ath.cx: Re: re-builder bug(s)]
  2007-03-06 22:36 [paul@wolfbone.ath.cx: Re: re-builder bug(s)] Richard Stallman
@ 2007-03-09 16:38 ` Detlev Zundel
  2007-03-09 19:48   ` P.L.Hayes
  2007-03-10 15:50   ` Richard Stallman
  2007-03-09 16:55 ` Oliver Scholz
  1 sibling, 2 replies; 11+ messages in thread
From: Detlev Zundel @ 2007-03-09 16:38 UTC (permalink / raw)
  To: rms; +Cc: paul, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 2553 bytes --]

Hi,

> This is the bug report.  Can you fix it for us?
>
> I don't know whether Detlev Zundel is still available,
> so I cc'd this to emacs-devel.  If Detlev doesn't fix this,
> I hope that someone else will do so.
>
> From: paul@wolfbone.ath.cx (P.L.Hayes)
> Subject: Re: re-builder bug(s)
> To: rms@gnu.org
> Cc: emacs-pretest-bug@gnu.org
> Date: Tue, 06 Mar 2007 07:33:44 +0000
>
> Richard Stallman <rms@gnu.org> writes:
>
>> I fixed the bug in the custom type, I think.
>>
>>     I also find (and I'm not quite sure whether it's a real bug or just
>>     something I haven't understood about regexps or re-builder) that
>>     expressions such as "\\>" and "$" in the re-builder buffer don't work
>>     (and are flagged as "*invalid*" in the modeline) but ".\\>" and ".$",
>>
>> Would you please send a precise, complete test case for this?
>
> Open a new buffer, put it in text mode and insert a line of text into it:
>
>      C-x b *reb-test* RET M-x text-mode RET
>      Kidman's publicist, Catherine Olim, said the star was trying to shake zombies off the bonnet of her Jaguar when the car spun off the road. RET
>
> Try to use re-builder to count the number of words in the buffer:
>
>     M-x re-builder RET
>     \\>
>
> As soon as the first `\' is entered between the `"'s, in the
> *RE-Builder* buffer, "*invalid*" appears in the modeline.
> Now replace the regexp in the *RE-Builder* buffer with another:
>
>     DEL DEL DEL
>     .\\>
>
> Success! - the last character of each word in the *reb-test* buffer
> has been highlighted and a message, "25 matches" has appeared in the
> minibuffer. Likewise, the regexp, "^" will not find the empty string
> at the beginning of the buffer but "^." will and "$" will not find the
> end of the buffer but ".$" will.
> ----------

Ok, attached is a patch that changes the behaviour of re-builder when
it comes to what it previously considered empty regexps.  It now
counts words, lines and other zero-width regexps.  

Although I think the new behaviour is consistent in that it now also
counts (up to its defined maximum) the numbers of characters in a
buffer when confronted with an empty regexp (after all
re-search-forward matches), I don't know if that is what users would
expect.

What do you think?

Thanks
  Detlev

-- 
Progress in  mathematics comes from  repeated acts of generalization.
If mathematics is anything, it is the art of chosing the most elegant
generalization for some abstract pattern.  Thus esthetics is central.
                                     -- Douglas Hofstadter

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: re-builder.patch --]
[-- Type: text/x-diff, Size: 662 bytes --]

--- lisp/emacs-lisp/re-builder.el	2007-03-08 15:44:12.000000000 +0100
+++ /tmp/re-builder.el	2007-03-09 16:22:18.000000000 +0100
@@ -639,11 +640,13 @@
       (set-buffer reb-target-buffer)
       (reb-delete-overlays)
       (goto-char (point-min))
-      (while (and (re-search-forward re (point-max) t)
+      (while (and (not (eobp))
+		  (re-search-forward re (point-max) t)
 		  (or (not reb-auto-match-limit)
 		      (< matches reb-auto-match-limit)))
 	(if (= 0 (length (match-string 0)))
-	    (error "Empty regular expression!"))
+	    (unless (eobp) 
+	      (forward-char 1)))
 	(let ((i 0)
 	      suffix max-suffix)
 	  (setq matches (1+ matches))

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [paul@wolfbone.ath.cx: Re: re-builder bug(s)]
  2007-03-06 22:36 [paul@wolfbone.ath.cx: Re: re-builder bug(s)] Richard Stallman
  2007-03-09 16:38 ` Detlev Zundel
@ 2007-03-09 16:55 ` Oliver Scholz
  2007-03-10 15:50   ` Richard Stallman
  1 sibling, 1 reply; 11+ messages in thread
From: Oliver Scholz @ 2007-03-09 16:55 UTC (permalink / raw)
  To: emacs-devel

Richard Stallman <rms@gnu.org> writes:

[...]
> I don't know whether Detlev Zundel is still available,
> so I cc'd this to emacs-devel.  If Detlev doesn't fix this,
> I hope that someone else will do so.

I gave it a shot.


[...]
>>     I also find (and I'm not quite sure whether it's a real bug or just
>>     something I haven't understood about regexps or re-builder) that
>>     expressions such as "\\>" and "$" in the re-builder buffer don't work
>>     (and are flagged as "*invalid*" in the modeline) but ".\\>" and ".$",
>>
>> Would you please send a precise, complete test case for this?
>
> Open a new buffer, put it in text mode and insert a line of text into it:
>
>      C-x b *reb-test* RET M-x text-mode RET
>      Kidman's publicist, Catherine Olim, said the star was trying to shake zombies off the bonnet of her Jaguar when the car spun off the road. RET
>
> Try to use re-builder to count the number of words in the buffer:
>
>     M-x re-builder RET
>     \\>
>
> As soon as the first `\' is entered between the `"'s, in the
> *RE-Builder* buffer, "*invalid*" appears in the modeline.
> Now replace the regexp in the *RE-Builder* buffer with another:
>
>     DEL DEL DEL
>     .\\>
>
> Success! - the last character of each word in the *reb-test* buffer
> has been highlighted and a message, "25 matches" has appeared in the
> minibuffer. Likewise, the regexp, "^" will not find the empty string
> at the beginning of the buffer but "^." will and "$" will not find the
> end of the buffer but ".$" will.

This happens in line 646 and following of re-builder.el.
`reb-update-overlays' `re-search'es the buffer and checks whether the
match is empty, otherwise it updates the match-overlays:

	(if (= 0 (length (match-string 0)))
	    (error "Empty regular expression!"))

So, this "bug" seems to be intentional. I wouldn't know what to do,
anyways. How do you highlight an empty string?


    Oliver
-- 
19 Ventôse an 215 de la Révolution
Liberté, Egalité, Fraternité!

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [paul@wolfbone.ath.cx: Re: re-builder bug(s)]
  2007-03-09 16:38 ` Detlev Zundel
@ 2007-03-09 19:48   ` P.L.Hayes
  2007-03-10 15:50   ` Richard Stallman
  1 sibling, 0 replies; 11+ messages in thread
From: P.L.Hayes @ 2007-03-09 19:48 UTC (permalink / raw)
  To: Detlev Zundel; +Cc: rms, emacs-devel

Detlev Zundel <dzu@akk.org> writes:

> Ok, attached is a patch that changes the behaviour of re-builder when
> it comes to what it previously considered empty regexps.  It now
> counts words, lines and other zero-width regexps.  
>
> Although I think the new behaviour is consistent in that it now also
> counts (up to its defined maximum) the numbers of characters in a
> buffer when confronted with an empty regexp (after all
> re-search-forward matches), I don't know if that is what users would
> expect.
>
> What do you think?

That patch works and (as a user) I think either that behaviour or some
message in the modeline other than "*invalid*" would've been
sufficient to preclude my earlier confusion.

Cheers,

Paul.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [paul@wolfbone.ath.cx: Re: re-builder bug(s)]
  2007-03-09 16:55 ` Oliver Scholz
@ 2007-03-10 15:50   ` Richard Stallman
  0 siblings, 0 replies; 11+ messages in thread
From: Richard Stallman @ 2007-03-10 15:50 UTC (permalink / raw)
  To: Oliver Scholz; +Cc: Detlev Zundel, emacs-devel

    This happens in line 646 and following of re-builder.el.
    `reb-update-overlays' `re-search'es the buffer and checks whether the
    match is empty, otherwise it updates the match-overlays:

	    (if (= 0 (length (match-string 0)))
		(error "Empty regular expression!"))

    So, this "bug" seems to be intentional. I wouldn't know what to do,
    anyways. How do you highlight an empty string?

You could put the cursor there and make it look funny, maybe.
Or use an overlay with an after-string.

Or just display a message in the minibuffer to explain the situation.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [paul@wolfbone.ath.cx: Re: re-builder bug(s)]
  2007-03-09 16:38 ` Detlev Zundel
  2007-03-09 19:48   ` P.L.Hayes
@ 2007-03-10 15:50   ` Richard Stallman
  2007-03-12 13:03     ` Detlev Zundel
  1 sibling, 1 reply; 11+ messages in thread
From: Richard Stallman @ 2007-03-10 15:50 UTC (permalink / raw)
  To: Detlev Zundel; +Cc: eliz, paul, emacs-devel

Can you please send a change log entry for that change?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [paul@wolfbone.ath.cx: Re: re-builder bug(s)]
  2007-03-10 15:50   ` Richard Stallman
@ 2007-03-12 13:03     ` Detlev Zundel
  2007-03-13  2:44       ` Richard Stallman
  0 siblings, 1 reply; 11+ messages in thread
From: Detlev Zundel @ 2007-03-12 13:03 UTC (permalink / raw)
  To: rms; +Cc: eliz, paul, emacs-devel

Hello Richard,

> Can you please send a change log entry for that change?

2007-03-12  Detlev Zundel  <dzu@gnu.org>

        * emacs-lisp/re-builder.el (reb-update-overlays): Do not mark
        zero-width regexps as invalid but rather at least count them
        correctly.

Cheers
  Detlev

-- 
Progress in  mathematics comes from  repeated acts of generalization.
If mathematics is anything, it is the art of chosing the most elegant
generalization for some abstract pattern.  Thus esthetics is central.
                                     -- Douglas Hofstadter

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [paul@wolfbone.ath.cx: Re: re-builder bug(s)]
  2007-03-12 13:03     ` Detlev Zundel
@ 2007-03-13  2:44       ` Richard Stallman
  2007-03-13  4:18         ` Eli Zaretskii
  0 siblings, 1 reply; 11+ messages in thread
From: Richard Stallman @ 2007-03-13  2:44 UTC (permalink / raw)
  To: Detlev Zundel; +Cc: eliz, paul, emacs-devel

Thanks.

Eli, will you be able to install this soon?
If not, would someone else please install it?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [paul@wolfbone.ath.cx: Re: re-builder bug(s)]
  2007-03-13  2:44       ` Richard Stallman
@ 2007-03-13  4:18         ` Eli Zaretskii
  2007-03-14  3:23           ` Richard Stallman
  0 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2007-03-13  4:18 UTC (permalink / raw)
  To: rms; +Cc: dzu, paul, emacs-devel

> From: Richard Stallman <rms@gnu.org>
> CC: paul@wolfbone.ath.cx, emacs-devel@gnu.org, eliz@gnu.org
> Date: Mon, 12 Mar 2007 22:44:01 -0400
> 
> Eli, will you be able to install this soon?

I was waiting for the ChangeLog entry.  Now that it was sent, I will
be able to install by Friday or Saturday.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [paul@wolfbone.ath.cx: Re: re-builder bug(s)]
  2007-03-13  4:18         ` Eli Zaretskii
@ 2007-03-14  3:23           ` Richard Stallman
  2007-03-18 14:36             ` Juanma Barranquero
  0 siblings, 1 reply; 11+ messages in thread
From: Richard Stallman @ 2007-03-14  3:23 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: dzu, paul, emacs-devel

    I was waiting for the ChangeLog entry.  Now that it was sent, I will
    be able to install by Friday or Saturday.

If someone else can install it sooner, please do.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [paul@wolfbone.ath.cx: Re: re-builder bug(s)]
  2007-03-14  3:23           ` Richard Stallman
@ 2007-03-18 14:36             ` Juanma Barranquero
  0 siblings, 0 replies; 11+ messages in thread
From: Juanma Barranquero @ 2007-03-18 14:36 UTC (permalink / raw)
  To: rms; +Cc: Eli Zaretskii, dzu, paul, emacs-devel

On 3/14/07, Richard Stallman <rms@gnu.org> wrote:

> If someone else can install it sooner, please do.

Committed.

             Juanma

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2007-03-18 14:36 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-06 22:36 [paul@wolfbone.ath.cx: Re: re-builder bug(s)] Richard Stallman
2007-03-09 16:38 ` Detlev Zundel
2007-03-09 19:48   ` P.L.Hayes
2007-03-10 15:50   ` Richard Stallman
2007-03-12 13:03     ` Detlev Zundel
2007-03-13  2:44       ` Richard Stallman
2007-03-13  4:18         ` Eli Zaretskii
2007-03-14  3:23           ` Richard Stallman
2007-03-18 14:36             ` Juanma Barranquero
2007-03-09 16:55 ` Oliver Scholz
2007-03-10 15:50   ` Richard Stallman

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).