【发布时间】:2014-11-13 15:39:08
【问题描述】:
通常,我需要启用自动填充模式,所以我在 .emacs 中将其打开。但是在 php 模式下编辑 PHP 时,我不想使用自动填充模式。有没有办法在 .emacs 中设置它,这样当我处于 PHP 模式时,自动填充段落模式会自动关闭,而当我离开 php 模式时,它会自动打开,除非其他覆盖?
更新:仔细检查.emacs 发现自动填充是由
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(column-number-mode t)
...
'(text-mode-hook (quote (turn-on-auto-fill text-mode-hook-identify)))
...)
【问题讨论】:
-
auto-fill-mode看起来不像是全局的,因此您可能已在用户自定义文件中的某处将其设置为全局。我能想到的控制其行为的最简单方法是对打开auto-fill-mode(即不包括php-mode)的函数放入一个异常(或创建这样的函数),或者只是将其用作缓冲区-使用您通常使用的主要模式挂钩启用的本地次要模式。文档声明它是缓冲区本地次要模式:gnu.org/software/emacs/manual/html_node/emacs/Auto-Fill.html -
如果这是一个继承问题(例如,
php-mode正在借用另一个主模式)而不是全局设置问题,那么也许你可以尝试类似:(add-hook 'php-mode-hook (lambda () (auto-fill-mode -1)))继承问题之一我设置自己的文本模式与普通版本不同的原因 - 即,其他主要模式不会继承某些文本模式设置。-1(负整数)关闭次要模式。 -
@lawlist 你能把你的评论作为正确的答案吗?
标签: emacs automation autofill