问题
I installed SML Mode in Emacs and the indentation is messed up. I disabled all my .emacs customizations, but that didn't make any difference. At the end of each line in the code below, I used C-j
, which is mapped to newline-and-indent
.


If I highlight everything and reindent (C-M-\
), the result makes more sense:


I'm using Emacs 24.1.1 and SML Mode 6.2 on Ubuntu 12.10. What should I do?
回答1:
Don't use newline-and-indent
.
You can use reindent-then-new-and-indent
or electric-indent-mode
instead.
回答2:
try in the .emacs file:
(setq default-tab-width 4);
(setq-default indent-tabs-mode nil);
(global-set-key (kbd "TAB") 'self-insert-command);
I'm no wizard but that worked for me. http://www.pement.org/emacs_tabs.htm
回答3:
Following up on Stefan's (now 4 year old...) suggestion, you can auto-enable the minor mode electric-indent-mode
for sml-mode
by putting this:
(push (lambda () electric-indent-local-mode 1) sml-mode-hook)
somewhere in your emacs initialization code.
Or, you might prefer:
(use-package sml-mode
:config
(push (lambda () electric-indent-local-mode 1) sml-mode-hook))
This seems to me to produce reasonably sane behavior for indenting code in sml-mode
.
来源:https://stackoverflow.com/questions/14374127/funky-indentation-in-sml-mode