I added the following mon-hook to automatically indent when hitting return in js-mode;
(add-hook 'js-mode-mon-hook '(lambda () (local-set-key (kbd "RET") 'newline-and-indent)))
Why isn't this working? I use the same exact thing for C, as follows, and it works:
(add-hook 'c-mode-mon-hook '(lambda () (local-set-key (kbd "RET") 'newline-and-indent)))
I added the following mon-hook to automatically indent when hitting return in js-mode;
(add-hook 'js-mode-mon-hook '(lambda () (local-set-key (kbd "RET") 'newline-and-indent)))
Why isn't this working? I use the same exact thing for C, as follows, and it works:
(add-hook 'c-mode-mon-hook '(lambda () (local-set-key (kbd "RET") 'newline-and-indent)))
Share
Improve this question
edited Apr 24, 2012 at 22:37
N.N.
8,51213 gold badges56 silver badges95 bronze badges
asked Apr 24, 2012 at 18:25
darkskydarksky
21.1k64 gold badges171 silver badges257 bronze badges
1 Answer
Reset to default 10Use js-mode-hook
. Languages that have modes based on cc-mode
can use the mon hook for all related languages. The mode for JavaScript is based on prog-mode
, so it runs prog-mode-hook
first, then js-mode-hook
.
If you look up mode documentation with C-h m, it will usually tell you what hooks get run.