I've rebound some keys in god-mode so that S
and R
start a forward and backward incremental search and s
and r
repeat but never start incremental searches. This is the approximate division of labor between Vim's /
/?
and n
/N
.
This has some behavior I like, namely that the previous incremental search query is available until I specifically replace it with a new one via S
or R
.
But, it leaves "stray highlighting" when I'm moving around via s
and r
. The stray highlighting seems to last indefinitely.
To reproduce the problem, run the .emacs
file below, it will drop you into the scratch buffer with scratch-mode
already activated.
- hit
g <
to navigate to the top of the buffer - hit
S
+s
+RET
to start a forward incremental search. The cursor should now be immediately afterThis
. - hit
s
+s
+s
, thenr
+r
+r
moving forward three matches and then backward three matches. - wait one second
- All of the
s
characters in the buffer are now highlighted with a greenish color behind them.
How do I clear the greenish color behind all the s
characters without replacing the "current default isearch query"?
;; minimal init.el to represent problem.
(progn
(defun isearch-repeat-forward-command ()
(interactive)
(isearch-repeat-forward))
(defun isearch-repeat-backward-command ()
(interactive)
(isearch-repeat-backward))
(package-initialize)
(require 'god-mode)
(god-mode-all)
(global-set-key (kbd "s-g") #'god-mode-all)
(define-key god-local-mode-map (kbd "i") #'god-local-mode)
(define-key god-local-mode-map (kbd "s") #'isearch-repeat-forward-command)
(define-key god-local-mode-map (kbd "r") #'isearch-repeat-backward-command)
(define-key god-local-mode-map (kbd "S") #'isearch-forward-regexp)
(define-key god-local-mode-map (kbd "R") #'isearch-backward-regexp)
(identity 1))