Disable auto indent globally in Emacs

℡╲_俬逩灬. 提交于 2019-11-30 08:10:03

问题


How to disable auto indent in Emacs globally or only for some modes?

I have a number of packages installed for RubyOnRails (ruby, html, js, css).

Let's say I want to disable autoindent for css-mode.


回答1:


You may want to look for variable names containing the word electric. (This is the common Emacs parlance for actions which occur automatically when particular visible characters are typed.)

In this instance, M-x apropos-variable RET electric RET shows me that there is a css-electric-keys variable containing a list of "Self inserting keys which should trigger re-indentation."

You could use M-x customize-variable RET css-electric-keys RET to set this list to nil, or add (setq css-electric-keys nil) to your init file.

Sometimes a minor mode is used to implement electric behaviours, so that you can switch them on and off more easily. Those would likely be found via M-x apropos-command RET electric RET, and you would probably use a major mode hook to ensure that the electric minor mode was disabled, in a similar fashion to this:

(add-hook 'MAJORMODE-mode-hook 'my-MAJORMODE-mode-hook)
(defun my-MAJORMODE-mode-hook ()
  (ELECTRICMODE-mode 0))



回答2:


For me, on emacs 24.x, M-xelectric-indent-mode toggled the behavior that I wanted to disable.

FWIW, the behavior was that RET was bound to the command newline which is defined in simple.el... Among other things, the behavior of that command is altered by electric-indent-mode.



来源:https://stackoverflow.com/questions/4390238/disable-auto-indent-globally-in-emacs

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