diff -r -c emacs-1/lisp/ChangeLog emacs-2/lisp/ChangeLog *** emacs-1/lisp/ChangeLog 2010-11-22 00:28:12.000000000 -0800 --- emacs-2/lisp/ChangeLog 2010-11-22 00:42:23.000000000 -0800 *************** *** 1,3 **** --- 1,9 ---- + 2010-11-22 Andrew Helsley + + * isearch.el: Added lazy-highlighting of up to 9 sub-expressions of + isearch regexps using different faces for each + (isearch-lazy-highlight-propertize-one-match). + 2010-11-22 Tassilo Horn * textmodes/reftex-ref.el (reftex-goto-label): Use the current diff -r -c emacs-1/lisp/isearch.el emacs-2/lisp/isearch.el *** emacs-1/lisp/isearch.el 2010-11-21 22:57:58.000000000 -0800 --- emacs-2/lisp/isearch.el 2010-11-22 00:37:55.000000000 -0800 *************** *** 2581,2586 **** --- 2581,2590 ---- (defvar isearch-lazy-highlight-regexp nil) (defvar isearch-lazy-highlight-space-regexp nil) (defvar isearch-lazy-highlight-forward nil) + (defvar isearch-lazy-highlight-last-capture-face 9) + (defvar isearch-lazy-highlight-minimum-overlay-priority 1000 + "Minimum priority to assign to `isearch' mode overlays. + 1000 is higher than `ediff's 100+.") (defun lazy-highlight-cleanup (&optional force) "Stop lazy highlighting and remove extra highlighting from current buffer. *************** *** 2717,2729 **** (forward-char -1))) ;; non-zero-length match ! (let ((ov (make-overlay mb me))) ! (push ov isearch-lazy-highlight-overlays) ! ;; 1000 is higher than ediff's 100+, ! ;; but lower than isearch main overlay's 1001 ! (overlay-put ov 'priority 1000) ! (overlay-put ov 'face lazy-highlight-face) ! (overlay-put ov 'window (selected-window)))) (if isearch-lazy-highlight-forward (setq isearch-lazy-highlight-end (point)) (setq isearch-lazy-highlight-start (point))))) --- 2721,2727 ---- (forward-char -1))) ;; non-zero-length match ! (isearch-lazy-highlight-propertize-one-match)) (if isearch-lazy-highlight-forward (setq isearch-lazy-highlight-end (point)) (setq isearch-lazy-highlight-start (point))))) *************** *** 2747,2752 **** --- 2745,2801 ---- (run-at-time lazy-highlight-interval nil 'isearch-lazy-highlight-update))))))))) + (defun isearch-lazy-highlight-propertize-one-match () + "Propertize the groups of the most recent regexp match." + (let* ((matches (match-data)) + (n 0)) + (while (>= (length matches) 2) + (let* ((m (min n isearch-lazy-highlight-last-capture-face)) + (beg (car matches)) + (end (cadr matches)) + (ov (make-overlay beg end))) + (push ov isearch-lazy-highlight-overlays) + (overlay-put ov 'priority (+ isearch-lazy-highlight-minimum-overlay-priority n)) + (overlay-put ov 'face (intern (format "isearch-lazy-highlight-capture-%02d" m))) + (overlay-put ov 'window (selected-window))) + (setq n (1+ n)) + (setq matches (cddr matches))))) + + (eval-when-compile (require 'cl)) + (flet ((isearch-lazy-highlight-define-capture-face + (num foreground-color background-color &rest other-face-attributes) + (custom-declare-face (intern (format "isearch-lazy-highlight-capture-%02d" num)) + `((((background dark)) + (:background ,foreground-color + :foreground ,background-color + :underline ,(> num 0) + :overline ,(> num 1) + ,@other-face-attributes + :inherit lazy-highlight)) + (((background light)) + (:background ,background-color + :foreground ,foreground-color + :underline ,(> num 0) + :overline ,(> num 1) + ,@other-face-attributes + :inherit lazy-highlight)) + (t + (:underline t))) + (concat "Face for lazy highlighting group " + (number-to-string num) + " of a regexp search.") + :group 'lazy-highlight :group 'basic-faces))) + (isearch-lazy-highlight-define-capture-face 0 nil "cyan") + (isearch-lazy-highlight-define-capture-face 1 "blue" "yellow" :weight 'bold) + (isearch-lazy-highlight-define-capture-face 2 "blue" "green" :weight 'bold) + (isearch-lazy-highlight-define-capture-face 3 "white" "magenta" :weight 'bold) + (isearch-lazy-highlight-define-capture-face 4 "yellow" "red" :weight 'bold) + (isearch-lazy-highlight-define-capture-face 5 "yellow" "blue" :weight 'bold) + (isearch-lazy-highlight-define-capture-face 6 "white" "blue" :weight 'bold) + (isearch-lazy-highlight-define-capture-face 7 "cyan" "blue" :weight 'bold) + (isearch-lazy-highlight-define-capture-face 8 "magenta" "blue" :weight 'bold) + (isearch-lazy-highlight-define-capture-face 9 "green" "blue" :weight 'bold)) + (defun isearch-resume (string regexp word forward message case-fold) "Resume an incremental search. STRING is the string or regexp searched for.