summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2006-05-05 13:02:14 +0000
committerEli Zaretskii <eliz@gnu.org>2006-05-05 13:02:14 +0000
commitfc7d3ac548b9148d7313320c39ae15d0cc35c757 (patch)
treec924feca92b4a78c91550266543ac82014044c82 /lisp/emacs-lisp
parenta4336ea0676890d9d3aec0e43dcc8569ce4e10b3 (diff)
downloademacs-fc7d3ac548b9148d7313320c39ae15d0cc35c757.tar.gz
emacs-fc7d3ac548b9148d7313320c39ae15d0cc35c757.tar.bz2
emacs-fc7d3ac548b9148d7313320c39ae15d0cc35c757.zip
(reb-update-overlays): Cycle through provided faces once they all have been
used.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/re-builder.el35
1 files changed, 22 insertions, 13 deletions
diff --git a/lisp/emacs-lisp/re-builder.el b/lisp/emacs-lisp/re-builder.el
index 827578f694c..5dc67e4ac21 100644
--- a/lisp/emacs-lisp/re-builder.el
+++ b/lisp/emacs-lisp/re-builder.el
@@ -112,7 +112,7 @@
(if (not (fboundp 'make-overlay))
(require 'overlay))
-;; User costomizable variables
+;; User customizable variables
(defgroup re-builder nil
"Options for the RE Builder."
:group 'lisp
@@ -627,11 +627,9 @@ Return t if the (cooked) expression changed."
beg (match-end 0)))
i))
-
(defun reb-update-overlays (&optional subexp)
"Switch to `reb-target-buffer' and mark all matches of `reb-regexp'.
If SUBEXP is non-nil mark only the corresponding sub-expressions."
-
(let* ((re (reb-target-binding reb-regexp))
(subexps (reb-count-subexps re))
(matches 0)
@@ -645,24 +643,35 @@ If SUBEXP is non-nil mark only the corresponding sub-expressions."
(or (not reb-auto-match-limit)
(< matches reb-auto-match-limit)))
(if (= 0 (length (match-string 0)))
- (error "Empty regular expression!"))
- (let ((i 0))
+ (error "Empty regular expression!"))
+ (let ((i 0)
+ suffix max-suffix)
(setq matches (1+ matches))
(while (<= i subexps)
(if (and (or (not subexp) (= subexp i))
(match-beginning i))
(let ((overlay (make-overlay (match-beginning i)
(match-end i)))
- (face-name (format "reb-match-%d" i)))
- (if (not firstmatch)
- (setq firstmatch (match-data)))
+ ;; When we have exceeded the number of provided faces,
+ ;; cycle thru them where `max-suffix' denotes the maximum
+ ;; suffix for `reb-match-*' that has been defined and
+ ;; `suffix' the suffix calculated for the current match.
+ (face
+ (cond
+ (max-suffix
+ (if (= suffix max-suffix)
+ (setq suffix 1)
+ (setq suffix (1+ suffix)))
+ (intern-soft (format "reb-match-%d" suffix)))
+ ((intern-soft (format "reb-match-%d" i)))
+ ((setq max-suffix (1- i))
+ (setq suffix 1)
+ ;; `reb-match-1' must exist.
+ 'reb-match-1))))
+ (unless firstmatch (setq firstmatch (match-data)))
(setq reb-overlays (cons overlay reb-overlays)
submatches (1+ submatches))
- (overlay-put
- overlay 'face
- (or (intern-soft face-name)
- (error "Too many subexpressions - face `%s' not defined"
- face-name )))
+ (overlay-put overlay 'face face)
(overlay-put overlay 'priority i)))
(setq i (1+ i))))))
(let ((count (if subexp submatches matches)))