aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2000-08-09 15:49:33 +0000
committerStefan Monnier2000-08-09 15:49:33 +0000
commit5cda4b07fac74073c254e99a083867fa38e894c4 (patch)
treea1f19f9cfdcf72138996ae520d24c1c8e4361e2d
parent96190aa1cb85d3e01098d2326cb433ea4cd8e30d (diff)
downloademacs-5cda4b07fac74073c254e99a083867fa38e894c4.tar.gz
emacs-5cda4b07fac74073c254e99a083867fa38e894c4.zip
(make-bool-vector): Remove.
(regexp-opt-group): Use a list of chars for `letters'. (regexp-opt-charset): `chars' is now a list of chars. Use a char-table rather than a vector so it works for multibyte chars.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/emacs-lisp/regexp-opt.el36
2 files changed, 26 insertions, 15 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 152d2dab7ac..1dd9be0aab9 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,10 @@
12000-08-09 Stefan Monnier <monnier@cs.yale.edu> 12000-08-09 Stefan Monnier <monnier@cs.yale.edu>
2 2
3 * emacs-lisp/regexp-opt.el (make-bool-vector): Remove.
4 (regexp-opt-group): Use a list of chars for `letters'.
5 (regexp-opt-charset): `chars' is now a list of chars.
6 Use a char-table rather than a vector so it works for multibyte chars.
7
3 * pcvs.el (cvs-menu): Don't move point. Use popup-menu. 8 * pcvs.el (cvs-menu): Don't move point. Use popup-menu.
4 Set cvs-minor-current-files to the selected fileinfo. 9 Set cvs-minor-current-files to the selected fileinfo.
5 (cvs-get-marked): Accept fileinfos in cvs-minor-current-files. 10 (cvs-get-marked): Accept fileinfos in cvs-minor-current-files.
diff --git a/lisp/emacs-lisp/regexp-opt.el b/lisp/emacs-lisp/regexp-opt.el
index a7ff7b54a58..e07e15db6f1 100644
--- a/lisp/emacs-lisp/regexp-opt.el
+++ b/lisp/emacs-lisp/regexp-opt.el
@@ -122,9 +122,6 @@ in REGEXP."
122(eval-when-compile 122(eval-when-compile
123 (require 'cl)) 123 (require 'cl))
124 124
125(unless (fboundp 'make-bool-vector)
126 (defalias 'make-bool-vector 'make-vector))
127
128(defun regexp-opt-group (strings &optional paren lax) 125(defun regexp-opt-group (strings &optional paren lax)
129 "Return a regexp to match a string in STRINGS. 126 "Return a regexp to match a string in STRINGS.
130If PAREN non-nil, output regexp parentheses around returned regexp. 127If PAREN non-nil, output regexp parentheses around returned regexp.
@@ -169,7 +166,7 @@ so we can use character sets rather than grouping parenthesis."
169 (let (letters rest) 166 (let (letters rest)
170 ;; Collect one-char strings 167 ;; Collect one-char strings
171 (dolist (s strings) 168 (dolist (s strings)
172 (if (= (length s) 1) (push s letters) (push s rest))) 169 (if (= (length s) 1) (push (string-to-char s) letters) (push s rest)))
173 170
174 (if rest 171 (if rest
175 ;; several one-char strings: take them and recurse 172 ;; several one-char strings: take them and recurse
@@ -227,13 +224,13 @@ so we can use character sets rather than grouping parenthesis."
227 ;; The basic idea is to find character ranges. Also we take care in the 224 ;; The basic idea is to find character ranges. Also we take care in the
228 ;; position of character set meta characters in the character set regexp. 225 ;; position of character set meta characters in the character set regexp.
229 ;; 226 ;;
230 (let* ((charwidth 256) ; Yeah, right. 227 (let* ((charmap (make-char-table 'case-table))
231 (charmap (make-bool-vector charwidth nil)) 228 (start -1) (end -2)
232 (charset "") 229 (charset "")
233 (bracket "") (dash "") (caret "")) 230 (bracket "") (dash "") (caret ""))
234 ;; 231 ;;
235 ;; Make a character map but extract character set meta characters. 232 ;; Make a character map but extract character set meta characters.
236 (dolist (char (mapcar 'string-to-char chars)) 233 (dolist (char chars)
237 (case char 234 (case char
238 (?\] 235 (?\]
239 (setq bracket "]")) 236 (setq bracket "]"))
@@ -245,14 +242,23 @@ so we can use character sets rather than grouping parenthesis."
245 (aset charmap char t)))) 242 (aset charmap char t))))
246 ;; 243 ;;
247 ;; Make a character set from the map using ranges where applicable. 244 ;; Make a character set from the map using ranges where applicable.
248 (dotimes (char charwidth) 245 (map-char-table
249 (let ((start char)) 246 (lambda (c v)
250 (while (and (< char charwidth) (aref charmap char)) 247 (when v
251 (incf char)) 248 (if (= (1- c) end) (setq end c)
252 (cond ((> char (+ start 3)) 249 (if (> end (+ start 2))
253 (setq charset (format "%s%c-%c" charset start (1- char)))) 250 (setq charset (format "%s%c-%c" charset start end))
254 ((> char start) 251 (while (>= end start)
255 (setq charset (format "%s%c" charset (setq char start))))))) 252 (setq charset (format "%s%c" charset start))
253 (incf start)))
254 (setq start c end c))))
255 charmap)
256 (when (>= end start)
257 (if (> end (+ start 2))
258 (setq charset (format "%s%c-%c" charset start end))
259 (while (>= end start)
260 (setq charset (format "%s%c" charset start))
261 (incf start))))
256 ;; 262 ;;
257 ;; Make sure a caret is not first and a dash is first or last. 263 ;; Make sure a caret is not first and a dash is first or last.
258 (if (and (string-equal charset "") (string-equal bracket "")) 264 (if (and (string-equal charset "") (string-equal bracket ""))