aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2006-05-05 13:02:14 +0000
committerEli Zaretskii2006-05-05 13:02:14 +0000
commitfc7d3ac548b9148d7313320c39ae15d0cc35c757 (patch)
treec924feca92b4a78c91550266543ac82014044c82
parenta4336ea0676890d9d3aec0e43dcc8569ce4e10b3 (diff)
downloademacs-fc7d3ac548b9148d7313320c39ae15d0cc35c757.tar.gz
emacs-fc7d3ac548b9148d7313320c39ae15d0cc35c757.zip
(reb-update-overlays): Cycle through provided faces once they all have been
used.
-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 @@
112(if (not (fboundp 'make-overlay)) 112(if (not (fboundp 'make-overlay))
113 (require 'overlay)) 113 (require 'overlay))
114 114
115;; User costomizable variables 115;; User customizable variables
116(defgroup re-builder nil 116(defgroup re-builder nil
117 "Options for the RE Builder." 117 "Options for the RE Builder."
118 :group 'lisp 118 :group 'lisp
@@ -627,11 +627,9 @@ Return t if the (cooked) expression changed."
627 beg (match-end 0))) 627 beg (match-end 0)))
628 i)) 628 i))
629 629
630
631(defun reb-update-overlays (&optional subexp) 630(defun reb-update-overlays (&optional subexp)
632 "Switch to `reb-target-buffer' and mark all matches of `reb-regexp'. 631 "Switch to `reb-target-buffer' and mark all matches of `reb-regexp'.
633If SUBEXP is non-nil mark only the corresponding sub-expressions." 632If SUBEXP is non-nil mark only the corresponding sub-expressions."
634
635 (let* ((re (reb-target-binding reb-regexp)) 633 (let* ((re (reb-target-binding reb-regexp))
636 (subexps (reb-count-subexps re)) 634 (subexps (reb-count-subexps re))
637 (matches 0) 635 (matches 0)
@@ -645,24 +643,35 @@ If SUBEXP is non-nil mark only the corresponding sub-expressions."
645 (or (not reb-auto-match-limit) 643 (or (not reb-auto-match-limit)
646 (< matches reb-auto-match-limit))) 644 (< matches reb-auto-match-limit)))
647 (if (= 0 (length (match-string 0))) 645 (if (= 0 (length (match-string 0)))
648 (error "Empty regular expression!")) 646 (error "Empty regular expression!"))
649 (let ((i 0)) 647 (let ((i 0)
648 suffix max-suffix)
650 (setq matches (1+ matches)) 649 (setq matches (1+ matches))
651 (while (<= i subexps) 650 (while (<= i subexps)
652 (if (and (or (not subexp) (= subexp i)) 651 (if (and (or (not subexp) (= subexp i))
653 (match-beginning i)) 652 (match-beginning i))
654 (let ((overlay (make-overlay (match-beginning i) 653 (let ((overlay (make-overlay (match-beginning i)
655 (match-end i))) 654 (match-end i)))
656 (face-name (format "reb-match-%d" i))) 655 ;; When we have exceeded the number of provided faces,
657 (if (not firstmatch) 656 ;; cycle thru them where `max-suffix' denotes the maximum
658 (setq firstmatch (match-data))) 657 ;; suffix for `reb-match-*' that has been defined and
658 ;; `suffix' the suffix calculated for the current match.
659 (face
660 (cond
661 (max-suffix
662 (if (= suffix max-suffix)
663 (setq suffix 1)
664 (setq suffix (1+ suffix)))
665 (intern-soft (format "reb-match-%d" suffix)))
666 ((intern-soft (format "reb-match-%d" i)))
667 ((setq max-suffix (1- i))
668 (setq suffix 1)
669 ;; `reb-match-1' must exist.
670 'reb-match-1))))
671 (unless firstmatch (setq firstmatch (match-data)))
659 (setq reb-overlays (cons overlay reb-overlays) 672 (setq reb-overlays (cons overlay reb-overlays)
660 submatches (1+ submatches)) 673 submatches (1+ submatches))
661 (overlay-put 674 (overlay-put overlay 'face face)
662 overlay 'face
663 (or (intern-soft face-name)
664 (error "Too many subexpressions - face `%s' not defined"
665 face-name )))
666 (overlay-put overlay 'priority i))) 675 (overlay-put overlay 'priority i)))
667 (setq i (1+ i)))))) 676 (setq i (1+ i))))))
668 (let ((count (if subexp submatches matches))) 677 (let ((count (if subexp submatches matches)))