4

I have highlight-symbol enabled with the delay set to 0. It's great, but unfortunately when I navigate by holding down j or k (evil-mode), the feedback is not great.

So I was wondering if it's possible to temporarily disable highlight-symbol as I'm holding down j or k. I've tried setting the delay to 0.1 or smaller, but it always seems to feel like it's 1 second.

(Now, I know there are better ways in navigating, but that's beside the question)

4

The way highlight-symbol handles itself, IMO, is not ideal. In order to be able to navigate at full speed and still have highlighting applied quickly after a pause I had to make some changes to the core functions of the package.

First, highlight symbol actually checks for a 0 delay and acts differently, this isn't needed, so you can redefine highlight-symbol-post-command to this version which removes the 0 delay check and just always does highlighting via a timer, not directly.

(defun highlight-symbol-mode-post-command ()
  "After a command, change the temporary highlighting.
Remove the temporary symbol highlighting and, unless a timeout is specified,
create the new one."
  (if (eq this-command 'highlight-symbol-jump)
      (when highlight-symbol-on-navigation-p
        (highlight-symbol-temp-highlight))
    (highlight-symbol-update-timer highlight-symbol-idle-delay)))

Second, we need to change how the timers are started for highlighting. There is no need to have the timer repeat and no need to use an idle timer over a standard timer. You can redefined highlight-symbol-update-timer like as this:

(defun highlight-symbol-update-timer (value)
  (when highlight-symbol-timer
    (cancel-timer highlight-symbol-timer))
  (setq highlight-symbol-timer
        (run-with-timer value nil 'highlight-symbol-temp-highlight)))

Finally, set the delay time very small, I used .1 seconds.

(setq highlight-symbol-idle-delay .1)

With these changes I am able to move around the buffer quickly with without unnecessary highlighting occurring and slowing things down along the way. Instead highlighting occurs promptly after I stop moving.

| improve this answer | |
  • 1
    Perfect! This patch should be applied to the default. – john2x Oct 10 '14 at 3:33
0

The default delay for highlight symbol (at least according to this source file) is 1.5 seconds.

If you leave it at the default, or set it back to 1.5 yourself, won't you get the desired effect?

| improve this answer | |
  • 1
    He wants it less than that. He feels like any value he uses leads to a 1 sec delay. – Malabarba Oct 9 '14 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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