@kindex M-s h r @r{(Incremental Search)}
@findex isearch-highlight-regexp
- You can exit the search while leaving the matches for the last
-search string highlighted on display. To this end, type @kbd{M-s h r}
-(@code{isearch-highlight-regexp}), which will run
-@code{highlight-regexp} (@pxref{Highlight Interactively}) passing
-it the regexp derived from the last search string and prompting you
-for the face to use for highlighting. To remove the highlighting,
-type @kbd{M-s h u} (@code{unhighlight-regexp}).
+@kindex M-s h l @r{(Incremental Search)}
+@findex isearch-highlight-lines-matching-regexp
+ You can exit the search while leaving the matches highlighted by
+typing @kbd{M-s h r} (@code{isearch-highlight-regexp}). This runs
+@code{highlight-regexp} (@pxref{Highlight Interactively}), passing it
+the regexp derived from the search string and prompting you for the face
+to use for highlighting. To highlight @emph{whole lines} containing
+matches (rather than @emph{just} the matches), type @kbd{M-s h l}
+(@code{isearch-highlight-lines-matching-regexp}). In either case, to
+remove the highlighting, type @kbd{M-s h u} (@code{unhighlight-regexp}).
@cindex incremental search, help on special keys
@kindex C-h C-h @r{(Incremental Search)}
(define-key map [?\C-\M-%] 'isearch-query-replace-regexp)
(define-key map "\M-so" 'isearch-occur)
(define-key map "\M-shr" 'isearch-highlight-regexp)
+ (define-key map "\M-shl" 'isearch-highlight-lines-matching-regexp)
;; The key translations defined in the C-x 8 prefix should add
;; characters to the search string. See iso-transl.el.
the last search string.
Type \\[isearch-highlight-regexp] to run `highlight-regexp'\
that highlights the last search string.
+Type \\[isearch-highlight-lines-matching-regexp] to run
+ `highlight-lines-matching-regexp'\ that highlights lines
+ matching the last search string.
Type \\[isearch-describe-bindings] to display all Isearch key bindings.
Type \\[isearch-describe-key] to display documentation of Isearch key.
(declare-function hi-lock-read-face-name "hi-lock" ())
-(defun isearch-highlight-regexp ()
- "Run `highlight-regexp' with regexp from the current search string.
-It exits Isearch mode and calls `hi-lock-face-buffer' with its regexp
-argument from the last search regexp or a quoted search string,
-and reads its face argument using `hi-lock-read-face-name'."
- (interactive)
+(defun isearch--highlight-regexp-or-lines (hi-lock-func)
+ "Run HI-LOCK-FUNC to exit isearch, leaving the matches highlighted.
+This is the internal function used by `isearch-highlight-regexp'
+and `isearch-highlight-lines-matching-regexp' to invoke
+HI-LOCK-FUNC (either `highlight-regexp' or
+`highlight-lines-matching-regexp' respectively)."
(let (
;; Set `isearch-recursive-edit' to nil to prevent calling
;; `exit-recursive-edit' in `isearch-done' that terminates
(regexp-quote s))))
isearch-string ""))
(t (regexp-quote isearch-string)))))
- (hi-lock-face-buffer regexp (hi-lock-read-face-name)))
+ (funcall hi-lock-func regexp (hi-lock-read-face-name)))
(and isearch-recursive-edit (exit-recursive-edit)))
+(defun isearch-highlight-regexp ()
+ "Exit Isearch mode, and call `highlight-regexp' with its regexp
+argument from the last search, and the face from
+`hi-lock-read-face-name'."
+ (interactive)
+ (isearch--highlight-regexp-or-lines 'highlight-regexp))
+
+(defun isearch-highlight-lines-matching-regexp ()
+ "Exit Isearch mode, and call `highlight-lines-matching-regexp'
+with its regexp argument from the last search, and the face from
+`hi-lock-read-face-name'."
+ (interactive)
+ (isearch--highlight-regexp-or-lines 'highlight-lines-matching-regexp))
+
\f
(defun isearch-delete-char ()
"Undo last input item during a search.