aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2003-01-20 21:37:02 +0000
committerStefan Monnier2003-01-20 21:37:02 +0000
commit94abe30b0c2af5beab44647fa0f4c32bc7592ad6 (patch)
tree994620eee555ebffa8ea3268b22168dc9bd89edd
parent945e6102fedb22aa5d200d9b60ceb7a6a256c0a9 (diff)
downloademacs-94abe30b0c2af5beab44647fa0f4c32bc7592ad6.tar.gz
emacs-94abe30b0c2af5beab44647fa0f4c32bc7592ad6.zip
(regexp-opt-group): Undo last change. Fix the docstring instead.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/emacs-lisp/regexp-opt.el25
2 files changed, 16 insertions, 14 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 17625ee3655..3737daf998f 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12003-01-20 Stefan Monnier <monnier@cs.yale.edu>
2
3 * emacs-lisp/regexp-opt.el (regexp-opt-group): Undo last change.
4 Fix the docstring instead.
5
12003-01-20 Glenn Morris <gmorris@ast.cam.ac.uk> 62003-01-20 Glenn Morris <gmorris@ast.cam.ac.uk>
2 7
3 * calendar/calendar.el (calendar-only-one-frame-setup): Autoload it. 8 * calendar/calendar.el (calendar-only-one-frame-setup): Autoload it.
diff --git a/lisp/emacs-lisp/regexp-opt.el b/lisp/emacs-lisp/regexp-opt.el
index ea80801b610..8ac4849d896 100644
--- a/lisp/emacs-lisp/regexp-opt.el
+++ b/lisp/emacs-lisp/regexp-opt.el
@@ -133,18 +133,18 @@ in REGEXP."
133 (require 'cl)) 133 (require 'cl))
134 134
135(defun regexp-opt-group (strings &optional paren lax) 135(defun regexp-opt-group (strings &optional paren lax)
136 "Return a regexp to match a string in STRINGS. 136 ;; Return a regexp to match a string in the sorted list STRINGS.
137If PAREN non-nil, output regexp parentheses around returned regexp. 137 ;; If PAREN non-nil, output regexp parentheses around returned regexp.
138If LAX non-nil, don't output parentheses if it doesn't require them. 138 ;; If LAX non-nil, don't output parentheses if it doesn't require them.
139Merges keywords to avoid backtracking in Emacs' regexp matcher. 139 ;; Merges keywords to avoid backtracking in Emacs' regexp matcher.
140 140
141The basic idea is to find the shortest common prefix or suffix, remove it 141 ;; The basic idea is to find the shortest common prefix or suffix, remove it
142and recurse. If there is no prefix, we divide the list into two so that 142 ;; and recurse. If there is no prefix, we divide the list into two so that
143\(at least) one half will have at least a one-character common prefix. 143 ;; \(at least) one half will have at least a one-character common prefix.
144 144
145Also we delay the addition of grouping parenthesis as long as possible 145 ;; Also we delay the addition of grouping parenthesis as long as possible
146until we're sure we need them, and try to remove one-character sequences 146 ;; until we're sure we need them, and try to remove one-character sequences
147so we can use character sets rather than grouping parenthesis." 147 ;; so we can use character sets rather than grouping parenthesis.
148 (let* ((open-group (cond ((stringp paren) paren) (paren "\\(?:") (t ""))) 148 (let* ((open-group (cond ((stringp paren) paren) (paren "\\(?:") (t "")))
149 (close-group (if paren "\\)" "")) 149 (close-group (if paren "\\)" ""))
150 (open-charset (if lax "" open-group)) 150 (open-charset (if lax "" open-group))
@@ -223,10 +223,7 @@ so we can use character sets rather than grouping parenthesis."
223 ;; particular letter and those that do not, and recurse on them. 223 ;; particular letter and those that do not, and recurse on them.
224 (let* ((char (char-to-string (string-to-char (car strings)))) 224 (let* ((char (char-to-string (string-to-char (car strings))))
225 (half1 (all-completions char strings)) 225 (half1 (all-completions char strings))
226 (half2 strings)) 226 (half2 (nthcdr (length half1) strings)))
227 ;; Remove from HALF2 whatever is in HALF1.
228 (dolist (elt half1)
229 (setq half2 (delq elt half2)))
230 (concat open-group 227 (concat open-group
231 (regexp-opt-group half1) 228 (regexp-opt-group half1)
232 "\\|" (regexp-opt-group half2) 229 "\\|" (regexp-opt-group half2)