如何关闭特定主要模式的电气模式?
我有几个主要模式(例如:yaml和nxml),我不想要电气模式(我想要像c一样的语言),但是如果关闭,我无法关闭。为了启用我:
(electric-indent-mode 1)
从文档(用于可变的电气模式)中
非nil如果启用了电动模式。 有关此次要模式的描述,请参见命令
electric-Indent模式'。 直接设置此变量不会生效; 要么自定义(请参阅信息节点
易于自定义') 或调用函数`electric-indent mode'。
并且用于功能
在即时重新注册(电气缩进模式)。有前缀 参数arg,如果ARG为正,则启用电气缩进模式,并且 否则将其禁用。如果是从LISP调用的,则启用模式如果ARG为 省略或零。
因此,我尝试用钩子将其关闭:(
(add-hook 'yaml-mode-hook (lambda ()
(electric-indent-mode -1)))
实际上我使用后修改后模式钩并检查(memql major-mode'(yaml-mode python-mode nxml-mode))我可以在列表中添加更多模式)。
但这不起作用,我也尝试:
(set (make-local-variable 'electric-indent-mode) nil)
没有快乐。但是,当我从.emacs文件中评估(electric-indent-mode -1)
时,它可以正常工作。
I have few Major modes (like: Yaml and NXML) that I don't want electric-indent-mode (I want it for C like languages) but I'm unable to turn if off. To enable I have:
(electric-indent-mode 1)
from documentation (for variable electric-indent-mode)
Non-nil if Electric-Indent mode is enabled.
See the commandelectric-indent-mode' for a description of this minor mode.
Easy Customization')
Setting this variable directly does not take effect;
either customize it (see the info node
or call the function `electric-indent-mode'.
and for a function
Toggle on-the-fly reindentation (Electric Indent mode). With a prefix
argument ARG, enable Electric Indent mode if ARG is positive, and
disable it otherwise. If called from Lisp, enable the mode if ARG is
omitted or nil.
so I try to turn it off in a hook:
(add-hook 'yaml-mode-hook (lambda ()
(electric-indent-mode -1)))
(Actualy I use after-change-major-mode-hook and check (memql major-mode '(yaml-mode python-mode nxml-mode))
where I can add more modes to the list).
But it don't work, I've also try:
(set (make-local-variable 'electric-indent-mode) nil)
No joy. But it work when I eval (electric-indent-mode -1)
from .emacs files.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用最近的emacs(可能仅使用Emacs快照),您可以使用
electry-Indent-Local-Mode
,例如:如果您的emacs缺乏此功能,您仍然可以通过
electry
electry electry
-Indent-funnctions
,例如,无论哪种情况,您都可能想通过
CJ
通过With a recent Emacs (probably Emacs snapshot only) you can use
electric-indent-local-mode
, e.g.:If your Emacs lacks this function, you can still sort of disable the mode via
electric-indent-functions
, e.g.And in either case, you may probably want to restore
C-j
, via电动indent模式
将在24.4中启用。要在本地关闭它,您将能够使用Lunaryorn提到的电气内部模式
。但是要在24.3中将其关闭,您可以做:您提到第一个表格对您不起作用,但应该(即,如果不适合,这是由于其他一些问题)。
electric-indent-mode
will be enabled by default in 24.4. To turn it off locally, you will be able to useelectric-indent-local-mode
as mentioned by lunaryorn. But to turn it off locally in 24.3, you can do:You mentioned that the first form didn't work for you, but it should (i.e. if it doesn't, it's because of the some other problem).
至少在EMACS 24.3上,您不能在本地禁用电气凹痕模式,因为它是
global-mode
。无论如何,yaml模式
的问题是,electric-indent
功能已内置在其中,即使没有exight> exight> electry-code> electry-indent-mode 。该软件包没有提供关闭此行为的方法,也许您应该在其GitHub仓库上提出问题。
尝试以
yaml-mode
中的电动式功能禁用电动性功能,以恢复电动性行为,您可以执行
At least on emacs 24.3 you cannot disable electric indent mode locally, since it is a
global-mode
. Anyways the issue withyaml-mode
is that theelectric-indent
functionality is built into it i.e. it will be enabled even withoutelectric-indent-mode
. The package does not provide a way to turn this behaviour off, maybe you should file an issue on its github repo.Try this to disable the electric-indent functionality in
yaml-mode
To restore the electric-indent behaviour afterwards, you can do