All I want to do is enable tern-mode
, when I enter js-mode
. I know that a hook called js-mode
is run when I open a javascript file but for some reason tern-mode
is not enabled. In my init.el file I have:
(add-hook 'js2-mode-hook (lambda () ('tern-mode)))
I also tried:
(add-hook 'js2-mode-hook (lambda () (tern-mode t)))
as well as both of those with js-mode-hook
(This was mostly for fun though because it makes no difference, see the comments)
I have also tried:
(add-hook 'js-mode-hook 'tern-mode)
And this does't work. However, tern-mode
does not get enabled when I enter js2-mode
. To enable it, each time I have to press M-x tern-mode
, then it works.
Is there anything I am doing wrong here?
tern-mode
when entering the major mode namedjs-mode
, you can use(add-hook 'js-mode-hook 'tern-mode)
, you usually don't have to wraptern-mode
unless you have very old version of Emacs or some other special reason.js2-mode
andjs-mode
is different thing, figure which you're using. Tern's doc already says how to use it, see ternjs.net/doc/manual.html#emacsjs2-mode
says:In addition to any hooks its parent mode
js-mode' might have run, 15 this mode runs the hookjs2-mode-hook', as the final step 16 during initialization.
I have the newest (24.5) version of emacs and have tried your suggestions and it does not work.(add-hook 'js-mode-hook 'tern-mode)
works fine for me (aside from erroring out because I don't havetern
installed; but the minor mode is enabled as expected).C-h v js-mode-hook RET
isIts value is (tern-mode skewer-mode ac-js2-mode ac-js2-setup-auto-complete-mode)
. but it still does not immediately open.js-mode-hook
. In any case I suspect the*Messages*
might contain some hint.