最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Adding Common Hook to js-mode - Stack Overflow

programmeradmin4浏览0评论

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
Add a ment  | 

1 Answer 1

Reset to default 10

Use 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.

发布评论

评论列表(0)

  1. 暂无评论