【问题标题】:How can I disable auto-fill mode in Emacs?如何在 Emacs 中禁用自动填充模式?
【发布时间】:2012-03-26 19:42:59
【问题描述】:

今天我得到了我的新电脑(Windows 7,32 位)并安装了Vincelt Goulets Emacs。我唯一做的另一件事是更新Org-mode

现在,我每次启动新 Emacs 时都被auto-fill-mode 卡住,我讨厌。我想暂时关闭auto-fill-mode,直到永远。我什至删除了我的 .emacs 文件,但 auto-fill-mode 仍然打开。

唯一有效的解决方案是 (a) a nasty workaround 或 (b) 每次我重新启动 Emacs 时总是输入 M-x auto-fill-mode

有解决办法吗?


需要明确的是,当前 .emacs 文件包含的唯一内容是:'(inhibit-startup-screen t)

【问题讨论】:

    标签: emacs word-wrap org-mode


    【解决方案1】:

    添加到您的.emacs

    (auto-fill-mode -1)
    

    如果有特定模式的钩子,您也需要对它们进行 zap。我怀疑您实际上并没有在所有模式下默认启用自动填充模式,但是根据您提供的信息,至少这应该是一个起点。

    一个合理的保护措施是禁用 `text-mode-hook' 的自动填充模式:

    (remove-hook 'text-mode-hook #'turn-on-auto-fill)
    

    对于其他模式,您可能也需要类似的东西。

    【讨论】:

    • text-mode-hook 成功了。不幸的是,只是关闭auto-fill-mode 没有用。因此,Vincent Goulet emacs 通过text-mode 自动加载auto-fill。非常感谢。
    • 您也可以使用M-x customize-variabletext-mode-hook 来修改它。取消选中它,一定要点击“保存以备将来使用”。
    • 这些对 Aquamacs 没有帮助 :( 但是,以下对 Aquamacs 有效:(remove-hook 'text-mode-hook 'auto-detect-wrap) (请注意,设置自动换行可能会产生其他影响?)
    【解决方案2】:

    假设他没有做出根本性的改变,你有几个路径:

    您可以在 .emacs 文件中全局关闭该模式:

    (turn-off-auto-fill)
    ;; ...or (auto-fill-mode -1)
    

    由于那个年代的 Emacs 也为 text-mode 开启了自动填充功能,添加:

    (remove-hook 'text-mode-hook 'turn-on-auto-fill)
    

    这应该说明所有默认位置,但如果您有其他模式自动启用此功能,请检查主要模式挂钩。

    【讨论】:

    • 我将这两个都添加到了我的 ~/.emacs(我正在使用 Aquamacs)中,但它们不起作用,至少在我的设置中是这样。
    • 和上面的人一样的问题。也许是 Aquamacs 特有的
    【解决方案3】:

    如果您希望在大多数 text-mode 中保持开启状态,而在特定模式下禁用 auto-fill,例如org-mode 在我的情况下,您可以使用以下内容:

    ;; turn on auto-fill for text-mode
    (add-hook 'text-mode-hook 'turn-on-auto-fill)
    ;; turn off auto-fill for org-mode
    (add-hook 'org-mode-hook 'turn-off-auto-fill)
    

    【讨论】:

      猜你喜欢
      • 2014-11-13
      • 1970-01-01
      • 2011-04-10
      • 2010-12-06
      • 1970-01-01
      • 2016-07-11
      • 1970-01-01
      • 1970-01-01
      • 2012-09-13
      相关资源
      最近更新 更多