tags:

views:

88

answers:

3

How can I get emacs to highlight the phrase I'm searching for and then keep it highlighted until I search for another phrase? Can it do this transparently i.e. just by searching, not having to run another command afterwards (like isearch-highlight-regexp) ?

+6  A: 

Try this:

(setq lazy-highlight-cleanup nil)

If you want to clear out the highlight manually, do M-x lazy-highlight-cleanup

Trey Jackson
That did the trick. I also had to set:`(setq lazy-highlight-max-at-a-time nil)` and `(setq lazy-highlight-initial-delay 0)` to get the exact effect that I wanted.
MDCore
A: 

Another option is to just use highlight-phrase or highlight-regexp, and not depend on the search system doing the job at all.

NikkiA
That's exactly what I said I didn't want. I want to hook into search because I want to find the next match and highlight all the matches with one command.
MDCore
+1  A: 

Trey's answer seems to work. I thought I'd include one using advice just for the sake of completeness:

(defadvice isearch-exit (after ysph-hl-search activate compile)
  "after isearch, highlight the search term "
  (highlight-regexp (car (if isearch-regexp
                             regexp-search-ring
                           search-ring)) (find-face 'hi-pink)))
Joseph Gay