Created
November 30, 2020 15:00
-
-
Save tttuuu888/ab4bd54785927eb53668b68807809407 to your computer and use it in GitHub Desktop.
Toggle highlighting current word
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'hi-lock) | |
(defun toggle-highlight-word () | |
(interactive) | |
(let ((regex (concat "\\_<" (current-word) "\\_>"))) | |
(if (member regex (mapcar #'car hi-lock-interactive-patterns)) | |
(unhighlight-regexp regex) | |
(highlight-symbol-at-point)))) | |
(defun unhighlight-all-highlighted-words () | |
(interactive) | |
(let ((hi-regexs (mapcar #'car hi-lock-interactive-patterns))) | |
(mapcar (lambda (regex) (unhighlight-regexp regex)) hi-regexs))) | |
(global-set-key [f9] 'toggle-highlight-word) | |
(global-set-key [S-f9] 'unhighlight-all-highlighted-words) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment