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
) ?
views:
88answers:
3
+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
2010-09-23 15:43:07
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
2010-09-25 12:49:24
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
2010-09-23 17:18:27
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
2010-09-25 10:42:27
+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
2010-09-23 19:33:19