(regexp-opt-depth): Don't count a "//(" which appears inside a character set.
(regexp-opt-not-groupie*-re): New constant.
This commit is contained in:
parent
569236cc98
commit
59b2ee6929
2 changed files with 30 additions and 5 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2003-04-27 Alan Mackenzie <acm@muc.de>
|
||||||
|
|
||||||
|
* emacs-lisp/regexp-opt.el (regexp-opt-depth): Don't count a "//("
|
||||||
|
which appears inside a character set.
|
||||||
|
(regexp-opt-not-groupie*-re): New constant.
|
||||||
|
|
||||||
2003-04-26 John Paul Wallington <jpw@gnu.org>
|
2003-04-26 John Paul Wallington <jpw@gnu.org>
|
||||||
|
|
||||||
* ibuffer.el (ibuffer-name-map, ibuffer-mode-name-map)
|
* ibuffer.el (ibuffer-name-map, ibuffer-mode-name-map)
|
||||||
|
|
|
@ -110,6 +110,24 @@ by \\=\\< and \\>."
|
||||||
(re (regexp-opt-group sorted-strings open)))
|
(re (regexp-opt-group sorted-strings open)))
|
||||||
(if words (concat "\\<" re "\\>") re))))
|
(if words (concat "\\<" re "\\>") re))))
|
||||||
|
|
||||||
|
(defconst regexp-opt-not-groupie*-re
|
||||||
|
(let* ((harmless-ch "[^\\\\[]")
|
||||||
|
(esc-pair-not-lp "\\\\[^(]")
|
||||||
|
(class-harmless-ch "[^][]")
|
||||||
|
(class-lb-harmless "[^]:]")
|
||||||
|
(class-lb-colon-maybe-charclass ":\\([a-z]+:]\\)?")
|
||||||
|
(class-lb (concat "\\[\\(" class-lb-harmless
|
||||||
|
"\\|" class-lb-colon-maybe-charclass "\\)"))
|
||||||
|
(class
|
||||||
|
(concat "\\[^?]?"
|
||||||
|
"\\(" class-harmless-ch
|
||||||
|
"\\|" class-lb "\\)*"
|
||||||
|
"\\[?]")) ; special handling for bare [ at end of re
|
||||||
|
(shy-lp "\\\\(\\?:"))
|
||||||
|
(concat "\\(" harmless-ch "\\|" esc-pair-not-lp
|
||||||
|
"\\|" class "\\|" shy-lp "\\)*"))
|
||||||
|
"Matches any part of a regular expression EXCEPT for non-shy \"\\\\(\"s")
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun regexp-opt-depth (regexp)
|
(defun regexp-opt-depth (regexp)
|
||||||
"Return the depth of REGEXP.
|
"Return the depth of REGEXP.
|
||||||
|
@ -120,11 +138,12 @@ in REGEXP."
|
||||||
(string-match regexp "")
|
(string-match regexp "")
|
||||||
;; Count the number of open parentheses in REGEXP.
|
;; Count the number of open parentheses in REGEXP.
|
||||||
(let ((count 0) start)
|
(let ((count 0) start)
|
||||||
(while (string-match "\\(\\`\\|[^\\]\\)\\\\\\(\\\\\\\\\\)*([^?]"
|
(while
|
||||||
regexp start)
|
(progn
|
||||||
(setq count (1+ count)
|
(string-match regexp-opt-not-groupie*-re regexp start)
|
||||||
;; Go back 2 chars (one for [^?] and one for [^\\]).
|
(setq start ( + (match-end 0) 2)) ; +2 for "\\(" after match-end.
|
||||||
start (- (match-end 0) 2)))
|
(<= start (length regexp)))
|
||||||
|
(setq count (1+ count)))
|
||||||
count)))
|
count)))
|
||||||
|
|
||||||
;;; Workhorse functions.
|
;;; Workhorse functions.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue