在Emacs中,如何在php模式下禁用自动填充段落模式?

时间:2014-09-19 05:50:48

标签: emacs automation autofill

通常,我需要启用自动填充模式,所以我在.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)))
  ...)

1 个答案:

答案 0 :(得分:1)

某些主要模式从其他模式继承某些设置(例如,text-mode被许多流行的主要模式使用)。以下代码段可用于使用其模式挂钩禁用特定主模式的功能:

(add-hook 'php-mode-hook (lambda ()
  (auto-fill-mode -1) ))

检查并查看特定功能是全局还是本地启用有时很有帮助,这反过来可以提供关于该功能是否已被主要模式继承的线索。在这种情况下,auto-fill-mode的文档说明如下 - https://www.gnu.org/software/emacs/manual/html_node/emacs/Auto-Fill.html

”自动填充模式是缓冲区本地次要模式(请参阅次要模式),当线条变得太宽时,线条会自动断开。只有当您键入<SPC>或{{1 }。

相关问题