emacs.d icon indicating copy to clipboard operation
emacs.d copied to clipboard

how to navigate highlight ?

Open robin2003 opened this issue 6 years ago • 5 comments

when open a file in emacs buffer, i use "M-x highlight-regexp" to highlight some pattern。 how can i navigate through these highlight ?

robin2003 avatar Apr 08 '18 11:04 robin2003

Easy, find the line containng regular expression, double check the highlight text does have hi-xxxx font face.

redguardtoo avatar Apr 08 '18 12:04 redguardtoo

but how can i jump from one highlight text to next highlight text quickly? i know that swiper can help me do that, but swiper do not have highlight.

i want to first make the pattern highlight, then can easily go through these highlight. is there any convenient method to do so?

robin2003 avatar Apr 09 '18 05:04 robin2003

(defun regexp-next()
   (interactive)
    (re-search-forward (car regexp-history)))

Personally I will stick to swiper. What's real world problem you want to solve?

redguardtoo avatar Apr 10 '18 00:04 redguardtoo

Actually I also have the same questions. Given the following scenarios: You have a log file that contains several key words that you're interested, and you highlighted them via hight-regexp, and in investing the logs, you will often want to jump from one highlighted keyword to the next appearance of the same keyword(say to judge when an object is constructed/destructed .etc), while keep other highlighted keywords unchanged so that you can check other status.

For exact keyword match, in the above situation, we have ,ln (highlight-symbol-nav-mode) to enable highlight navigation, and M-n (highlight-symbol-next) or M-p (highlight-symbol-prev) to jump back and forth. However, for regex match, the two commands mentioned above will not work.

Back to when I was using VIM, a vim plugin named mark will do the trick, but I didn't find a counterpart in Emacs (yet).

phye avatar Apr 10 '18 02:04 phye

interesting idea, maybe I can develop some solution

redguardtoo avatar Apr 10 '18 13:04 redguardtoo