diff lisp/isearch.el @ 96282:40b913a5812c

(isearch-mode-map): Bind `M-s h r' to `isearch-highlight-regexp'. (isearch-highlight-regexp): New function.
author Juri Linkov <juri@jurta.org>
date Wed, 25 Jun 2008 20:21:36 +0000
parents 8dca53338210
children db8569cf5705
line wrap: on
line diff
--- a/lisp/isearch.el	Wed Jun 25 20:17:07 2008 +0000
+++ b/lisp/isearch.el	Wed Jun 25 20:21:36 2008 +0000
@@ -494,6 +494,7 @@
     (define-key map [?\M-%] 'isearch-query-replace)
     (define-key map [?\C-\M-%] 'isearch-query-replace-regexp)
     (define-key map "\M-so" 'isearch-occur)
+    (define-key map "\M-shr" 'isearch-highlight-regexp)
 
     map)
   "Keymap for `isearch-mode'.")
@@ -1364,6 +1365,26 @@
 	(search-upper-case nil))
     (occur regexp nlines)))
 
+(declare-function hi-lock-regexp-okay "hi-lock" (regexp))
+(declare-function hi-lock-read-face-name "hi-lock" ())
+
+(defun isearch-highlight-regexp (regexp &optional face)
+  "Run `highlight-regexp' with regexp from the current search string.
+Interactively, REGEXP is the current search regexp or a quoted search
+string.  FACE has the same meaning as in `highlight-regexp'."
+  (interactive
+   (list
+    (progn
+      (require 'hi-lock nil t)
+      (hi-lock-regexp-okay
+       (if isearch-regexp isearch-string (regexp-quote isearch-string))))
+    (hi-lock-read-face-name)))
+  (isearch-done)
+  (isearch-clean-overlays)
+  ;; (add-to-history 'hi-lock-regexp-history regexp)
+  (let ((case-fold-search isearch-case-fold-search))
+    (hi-lock-face-buffer regexp face)))
+
 
 (defun isearch-delete-char ()
   "Discard last input item and move point back.