Funky indentation in SML mode

拈花ヽ惹草 提交于 2019-12-10 18:32:46

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!