I am trying to configure highlight-symbol mode with use-package for only programming modes. This is what I have:

(use-package highlight-symbol
  :ensure t
  (add-hook 'prog-mode-hook
              (highlight-symbol-mode 1)))
  (add-hook 'prog-mode-hook
              (highlight-symbol-nav-mode 1)))
  (setq highlight-symbol-idle-delay 1.0
        highlight-symbol-on-navigation-p t)
  :diminish highlight-symbol-mode)

However, when I open a .cpp file for example, I see that highlighting is not enabled (the minor mode is not enabled). I have also tried using lambda functions in the hooks to pass a non-nil argument, but that does not help. Invoking, M-x highlight-symbol-mode on the buffer works as expected.

Any suggestion is appreciated.

  • 1
    Your Emacs version? By the way, the lambdas are redundant: You can directly add the mode functions to the hooks.
    – user227
    May 19, 2015 at 21:24
  • 24.5. Infact, my snippet is from @lunaryorn's init.el. Okay, I used lambdas since I thought I needed to explicitly pass a positive argument. Not having lambdas does not help. May 19, 2015 at 21:46
  • Indeed, is it? Well, it works for me :). But I don't use C either. Does c-mode-hook instead of prog-mode-hook help? Besides, when you copy from my init file please keep in mind that it's written for Emacs 25, and not everything will work in 24.x.
    – user227
    May 19, 2015 at 21:48
  • @SwarnenduBiswas Check out this answer from one of the emacs.SE questions on how to enable a minor mode. May 20, 2015 at 0:34

1 Answer 1


Found the issue, it was a mistake in my init setup. I have split up my configuration into separate files, and the file where I had clubbed highlighting changes wasn't getting actually invoked. And I noticed it after a few days!

@lunaryorn's setup works for me as well on 24.5.

  • 1
    This does not qualify as an answer. Can you put in more detail as to what was the mistake so that the answer could be helpful to someone else as well? May 20, 2015 at 0:32
  • I know, but the error was silly. Still updated. May 20, 2015 at 2:47

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.