在Emacs中全局禁用自动缩进 [英] Disable auto indent globally in Emacs
问题描述
如何在全局或仅某些模式下禁用Emacs中的自动缩进?我有一些为RubyOnRails(ruby,html,js,css)安装的软件包。
我想要禁用css模式的自动缩进。
您可能要查找包含单词 electric
。 (这是针对特定可见字符输入时自动发生的动作的常见Emacs说明。)
在这种情况下, Mx apropos-variable
RET electric
RET 显示我有一个 css-electric-key
变量,其中包含一个自插入键应该触发重新缩进的列表。
你可以使用 Mx customize-variable
RET css-electric-keys
RET 将此列表设置为nil,或将(setq css-electric-keys nil)
添加到您的init文件。
有时,使用次要模式实现电气行为,以便您更轻松地切换它们。那些可能通过 Mx apropos-command
RET 电
RET ,您可能会使用主要模式的钩子来确保电子模式被禁用,与此类似:
(add-hook'MAJORMODE-mode-hook'my-MAJORMODE-mode-hook)
(defun my-MAJORMODE-mode-hook()
电动模式0))
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.
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))
这篇关于在Emacs中全局禁用自动缩进的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!