Subject: bug#6227: Color isearch regexp submatches differently

From: Juri Linkov <[email-masked]>
Date: Sun, 23 May 2010 02:44:04 +0300

>> We already have highlighting like that: lisp/emacs-lisp/re-builder.el
>> uses faces `reb-match-1', `reb-match-2', `reb-match-3' to highlight
>> regexp subexpressions.  I think this should be used by isearch.
>
> That sounds right to me.
>
> Also Drew suggestion to not color submatches in lazy marking seems right.

(add-hook 'isearch-update-post-hook
          (lambda ()
	    (require 're-builder)
	    (when isearch-regexp
	      (let ((reb-regexp isearch-string)
		    (reb-target-buffer (current-buffer))
		    (reb-target-window (selected-window)))
		(reb-update-overlays)))))

(add-hook 'isearch-mode-end-hook
          (lambda ()
	    (let ((reb-target-buffer (current-buffer)))
	      (reb-delete-overlays))))

-- 
Juri Linkov
http://www.jurta.org/emacs/