我有几个主要模式(例如:Yaml 和 NXML),我不想要电子缩进模式(我想要它用于类似 C 的语言),但如果关闭,我将无法关闭。要启用我有:
(electric-indent-mode 1)
来自文档(用于可变电缩进模式)
如果启用了 Electric-Indent 模式,则为非 nil。参见命令
electric-indent-mode' for a description of this minor mode. Setting this variable directly does not take effect; either customize it (see the info node
“Easy Customization”)或调用函数“electric-indent-mode”。
和一个功能
切换即时重新缩进(电动缩进模式)。使用前缀参数 ARG,如果 ARG 为正则启用 Electric Indent 模式,否则禁用它。如果从 Lisp 调用,如果 ARG 被省略或为零,则启用该模式。
所以我尝试将其关闭:
(add-hook 'yaml-mode-hook (lambda ()
(electric-indent-mode -1)))
(实际上我使用 after-change-major-mode-hook 并检查(memql major-mode '(yaml-mode python-mode nxml-mode))
可以在列表中添加更多模式的位置)。
但它不起作用,我也尝试过:
(set (make-local-variable 'electric-indent-mode) nil)
没有喜悦。但是当我(electric-indent-mode -1)
从 .emacs 文件进行评估时它会起作用。