Adding Common Hook to js-mode

I added the following general hook to automatically indent when returning a return to js-mode;

(add-hook 'js-mode-common-hook '(lambda () (local-set-key (kbd "RET") 'newline-and-indent)))

Why is this not working? I use the exact same thing for C as below and it works:

(add-hook 'c-mode-common-hook '(lambda () (local-set-key (kbd "RET") 'newline-and-indent)))
+5
source share
1 answer

Use js-mode-hook. Languages ​​having based modes cc-modecan use a common hook for all related languages. JavaScript mode is based on prog-mode, so it starts first prog-mode-hook, then js-mode-hook.

If you are viewing mode c documentation C-h m, it will usually tell you which hosts are starting.

+7
source

All Articles