The following code

(defun nordlow/isearch-previous-symbol-at-point ()
  (cond ((eq last-command 'nordlow/isearch-previous-symbol-at-point)
         (isearch-repeat-backward))    ;avoid flickering
        ((eq last-command 'nordlow/isearch-next-symbol-at-point)
         (isearch-repeat-backward 1))  ;avoid flickering
         (let (case-fold-search)
           (isearch-forward-symbol-at-point -1)))))
(defun nordlow/isearch-next-symbol-at-point ()
  (cond ((eq last-command 'nordlow/isearch-next-symbol-at-point)
         (isearch-repeat-forward))     ;avoid flickering
        ((eq last-command 'nordlow/isearch-previous-symbol-at-point)
         (isearch-repeat-forward 1))   ;avoid flickering
         (let (case-fold-search)
           (isearch-forward-symbol-at-point +1)))))

reuses isearch to provide navigation of all instances of the current symbol at point similar to what the packages https://github.com/nschum/highlight-symbol.el and https://github.com/elp-revive/auto-highlight-symbol does.

It works except that the font overlays are not removed when another command is called after either nordlow/isearch-previous-symbol-at-point or nordlow/isearch-next-symbol-at-point is called. How can I make these overlays be removed in this case?

One solution is to write a new hook similar to isearch-post-command-hook and add it to pre-command-hooks.

I would, btw, be very happy to have these two function be integrated into isearch.el.

  • As you found a solution, please write an Answer to your question -- you can then Accept that answer.
    – phils
    Commented Nov 16, 2023 at 22:01

1 Answer 1


I just found the solution

(defun nordlow/isearch-navigate-symbol-pre-command-hook ()
  (when (memq last-command '(nordlow/isearch-previous-symbol-at-point
(add-hook 'pre-command-hook 'nordlow/isearch-navigate-symbol-pre-command-hook)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.