unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Detlev Zundel <dzu@akk.org>
To: rms@gnu.org
Cc: paul@wolfbone.ath.cx, emacs-devel@gnu.org
Subject: Re: [paul@wolfbone.ath.cx: Re: re-builder bug(s)]
Date: Fri, 09 Mar 2007 17:38:46 +0100	[thread overview]
Message-ID: <m2fy8e74o9.fsf@magrathea.dnsalias.org> (raw)
In-Reply-To: <E1HOiH6-0000vO-1N@fencepost.gnu.org> (Richard Stallman's message of "Tue\, 06 Mar 2007 17\:36\:52 -0500")

[-- 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

  reply	other threads:[~2007-03-09 16:38 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-06 22:36 [paul@wolfbone.ath.cx: Re: re-builder bug(s)] Richard Stallman
2007-03-09 16:38 ` Detlev Zundel [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2fy8e74o9.fsf@magrathea.dnsalias.org \
    --to=dzu@akk.org \
    --cc=emacs-devel@gnu.org \
    --cc=paul@wolfbone.ath.cx \
    --cc=rms@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).