vim - Emacs + Evil: non incremental search and persistent highlighting? -
i'm trying emacs+evil after 2 decades vim user. i'm moving of vim configuration evil 1 thing i'm having lot of problems set search , highlighting 1 use vim. i'm trying have non-incremental search , highlights remain until clear them manually or make search.
i've set these settings on config file:
;; keep search highlights (setq lazy-highlight-cleanup nil) (setq lazy-highlight-max-at-a-time nil) (setq lazy-highlight-initial-delay 0)
using /
key search evil incremental thing , highlights removed press other movement key (like j
key c-s
(emacs internal i-search) highlights remain. c-s ret
(non incremental search) highlights doesn't remain.
ok, found working solution highlighting:
(defun highlight-remove-all () (interactive) (hi-lock-mode -1) (hi-lock-mode 1)) (defun search-highlight-persist () (highlight-regexp (car-safe (if isearch-regexp regexp-search-ring search-ring)) (facep 'hi-yellow))) (defadvice isearch-exit (after isearch-hl-persist activate) (highlight-remove-all) (search-highlight-persist)) (defadvice evil-search-incrementally (after evil-search-hl-persist activate) (highlight-remove-all) (search-highlight-persist))
this highlight searches done isearch or evil search. highlight remain until make 1 or call highlight-remove-all
. i've mapped leader spc
with:
(evil-leader/set-key "spc" 'highlight-remove-all)
ps: made package, it's on melpa name "evil-search-highlight-persist" and: https://github.com/juanjux/evil-search-highlight-persist
Comments
Post a Comment