all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* regexp-opt-group
@ 2003-01-18 22:21 Johan Bockgård
  2003-01-20  0:50 ` regexp-opt-group Richard Stallman
  0 siblings, 1 reply; 6+ messages in thread
From: Johan Bockgård @ 2003-01-18 22:21 UTC (permalink / raw)



   regexp-opt-group is a compiled Lisp function in `regexp-opt'.
   (regexp-opt-group STRINGS &optional PAREN LAX)
   Return a regexp to match a string in STRINGS.


(regexp-opt-group '("000" "this string is missing" "foo"
		    "0this occurs twice"))
==>

"0\\(?:00\\|this occurs twice\\)\\|foo\\|0this occurs twice"


This isn't correct, is it (GNU Emacs 21.2.1)?


/Johan

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

* Re: regexp-opt-group
  2003-01-18 22:21 regexp-opt-group Johan Bockgård
@ 2003-01-20  0:50 ` Richard Stallman
  2003-01-20 16:54   ` regexp-opt-group Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Stallman @ 2003-01-20  0:50 UTC (permalink / raw)
  Cc: emacs-devel

With this change, does everything work right?
It appears to be the right fix for this bug,
but I didn't have time to study the whole file carefully.

*** regexp-opt.el.~1.21.~	Thu Jun 20 10:43:11 2002
--- regexp-opt.el	Sun Jan 19 17:18:58 2003
***************
*** 223,229 ****
  	      ;; particular letter and those that do not, and recurse on them.
  	      (let* ((char (char-to-string (string-to-char (car strings))))
  		     (half1 (all-completions char strings))
! 		     (half2 (nthcdr (length half1) strings)))
  		(concat open-group
  			(regexp-opt-group half1)
  			"\\|" (regexp-opt-group half2)
--- 223,231 ----
  	      ;; particular letter and those that do not, and recurse on them.
  	      (let* ((char (char-to-string (string-to-char (car strings))))
  		     (half1 (all-completions char strings))
! 		     (half2 strings))
! 		(dolist (elt half1)
! 		  (setq half2 (delq elt half2)))
  		(concat open-group
  			(regexp-opt-group half1)
  			"\\|" (regexp-opt-group half2)

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

* Re: regexp-opt-group
  2003-01-20  0:50 ` regexp-opt-group Richard Stallman
@ 2003-01-20 16:54   ` Stefan Monnier
  2003-01-20 17:37     ` regexp-opt-group Johan Bockgård
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2003-01-20 16:54 UTC (permalink / raw)
  Cc: Johan Bockgård

> With this change, does everything work right?
> It appears to be the right fix for this bug,
> but I didn't have time to study the whole file carefully.
> 
> *** regexp-opt.el.~1.21.~	Thu Jun 20 10:43:11 2002
> --- regexp-opt.el	Sun Jan 19 17:18:58 2003
> ***************
> *** 223,229 ****
>   	      ;; particular letter and those that do not, and recurse on them.
>   	      (let* ((char (char-to-string (string-to-char (car strings))))
>   		     (half1 (all-completions char strings))
> ! 		     (half2 (nthcdr (length half1) strings)))
>   		(concat open-group
>   			(regexp-opt-group half1)
>   			"\\|" (regexp-opt-group half2)
> --- 223,231 ----
>   	      ;; particular letter and those that do not, and recurse on them.
>   	      (let* ((char (char-to-string (string-to-char (car strings))))
>   		     (half1 (all-completions char strings))
> ! 		     (half2 strings))
> ! 		(dolist (elt half1)
> ! 		  (setq half2 (delq elt half2)))
>   		(concat open-group
>   			(regexp-opt-group half1)
>   			"\\|" (regexp-opt-group half2)

The `strings' list is expected to always be properly sorted.
I believe that if the list is indeed sorted, then
(nthcdr (length half1) strings) should DTRT (and faster than your loop).
OTOH, if the list is not properly sorted, then it's probably a bug
somewhere else.
Note: I haven't seen the original message from Johan.


	Stefan

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

* Re: regexp-opt-group
  2003-01-20 16:54   ` regexp-opt-group Stefan Monnier
@ 2003-01-20 17:37     ` Johan Bockgård
  2003-01-20 17:42       ` regexp-opt-group Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Johan Bockgård @ 2003-01-20 17:37 UTC (permalink / raw)
  Cc: emacs-devel

"Stefan Monnier" <monnier+gnu/emacs@rum.cs.yale.edu> writes:

> > With this change, does everything work right?
[...]

> The `strings' list is expected to always be properly sorted.
> I believe that if the list is indeed sorted, then
> (nthcdr (length half1) strings) should DTRT (and faster than your loop).
> OTOH, if the list is not properly sorted, then it's probably a bug
> somewhere else.
> Note: I haven't seen the original message from Johan.

It was posted in gnu.emacs.bug.
http://groups.google.com/groups?selm=mailman.537.1042928665.21513.bug-gnu-emacs%40gnu.org

/Johan

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

* Re: regexp-opt-group
  2003-01-20 17:37     ` regexp-opt-group Johan Bockgård
@ 2003-01-20 17:42       ` Stefan Monnier
  2003-01-22 10:00         ` regexp-opt-group Richard Stallman
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2003-01-20 17:42 UTC (permalink / raw)
  Cc: Stefan Monnier

> "Stefan Monnier" <monnier+gnu/emacs@rum.cs.yale.edu> writes:
> 
> > > With this change, does everything work right?
> [...]
> 
> > The `strings' list is expected to always be properly sorted.
> > I believe that if the list is indeed sorted, then
> > (nthcdr (length half1) strings) should DTRT (and faster than your loop).
> > OTOH, if the list is not properly sorted, then it's probably a bug
> > somewhere else.
> > Note: I haven't seen the original message from Johan.
> 
> It was posted in gnu.emacs.bug.
> http://groups.google.com/groups?selm=mailman.537.1042928665.21513.bug-gnu-emacs%40gnu.org

> (regexp-opt-group '("000" "this string is missing" "foo"
> 		    "0this occurs twice"))

So the bug is in the docstring of regexp-opt-group which should say
that the list should be sorted.  And also make it more clear that it's
an internal function.

Why did you use `regexp-opt-group' rather than `regexp-opt' ?


	Stefan

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

* Re: regexp-opt-group
  2003-01-20 17:42       ` regexp-opt-group Stefan Monnier
@ 2003-01-22 10:00         ` Richard Stallman
  0 siblings, 0 replies; 6+ messages in thread
From: Richard Stallman @ 2003-01-22 10:00 UTC (permalink / raw)
  Cc: emacs-devel

    So the bug is in the docstring of regexp-opt-group which should say
    that the list should be sorted.  And also make it more clear that it's
    an internal function.

Ok.  On the other hand, I don't think my change does any harm.

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

end of thread, other threads:[~2003-01-22 10:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-18 22:21 regexp-opt-group Johan Bockgård
2003-01-20  0:50 ` regexp-opt-group Richard Stallman
2003-01-20 16:54   ` regexp-opt-group Stefan Monnier
2003-01-20 17:37     ` regexp-opt-group Johan Bockgård
2003-01-20 17:42       ` regexp-opt-group Stefan Monnier
2003-01-22 10:00         ` regexp-opt-group Richard Stallman

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.