I have (global-set-key (kbd "RET") 'newline-and-indent)
in my .emacs which works fi开发者_开发知识库ne in all modes but scala-mode(the newest, revision 19295 from svn).
What do I need to change to get it working?
(add-hook 'scala-mode-hook
(lambda () (local-set-key (kbd "RET") 'reindent-then-newline-and-indent)))
The above somewhat fixes the problem. It now indents the line correctly after pressing Enter once, but still doesn't work if there is a blank line above the newline.
In scala-mode, "RET" is bound to scala-newline by default, and this overrides the global key binding set with global-set-key
, hence the need for the hook specific to scala-mode. Consider using:
(add-hook 'scala-mode-hook
(lambda () (local-set-key (kbd "RET") 'newline-and-indent)))
instead of:
(add-hook 'scala-mode-hook
(lambda () (local-set-key (kbd "RET") 'reindent-then-newline-and-indent)))
If you don't want Emacs to change your indentation after leaving a line.
精彩评论