0

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
  :init 
  (add-hook 'prog-mode-hook
            (lambda()
              (highlight-symbol-mode 1)))
  (add-hook 'prog-mode-hook
            (lambda()
              (highlight-symbol-nav-mode 1)))
  :config
  (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.

Scott Weldon
  • 2,695
  • 1
  • 17
  • 31
Swarnendu Biswas
  • 1,378
  • 1
  • 11
  • 24
  • 1
    Your Emacs version? By the way, the lambdas are redundant: You can directly add the mode functions to the hooks. –  May 19 '15 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. – Swarnendu Biswas May 19 '15 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. –  May 19 '15 at 21:48
  • @SwarnenduBiswas Check out [this answer](http://emacs.stackexchange.com/a/10971/115) from one of the emacs.SE questions on how to enable a minor mode. – Kaushal Modi May 20 '15 at 00:34

1 Answers1

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.

Swarnendu Biswas
  • 1,378
  • 1
  • 11
  • 24