【问题标题】:How to set the ispell dictionary for all files below a specific directory如何为特定目录下的所有文件设置 ispell 字典
【发布时间】:2012-01-25 15:44:38
【问题描述】:

我如何(自动)将字典(例如通过自动调用 ispell-change-dictionary)设置为特定目录下每个文件的特定语言?

示例:我希望我的标准目录语言是美式英语(例如,通过在我的 .emacs 文件中设置 (setq ispell-dictionary "en_US-wo_accents"))但我想对以下(或:下)的所有文件使用英式英语目录/home/werner/dissertation/。对于/home/werner/letters/ 下的所有文件,也许是荷兰语。

我知道解决方案规定在文件的第一行使用-*- ispell-dictionary: "english" -*- 来设置该特定文件的字典(在EmacsWiki.org 中描述)。我想避免将这一行放在我制作的每个新文件的顶部。

【问题讨论】:

    标签: emacs ispell


    【解决方案1】:

    你可以使用类似的东西(但是当你想为给定的文件制作复杂的东西时,这种方法更有用):

    (defun set-dictionary-hook ()
      (when (and (stringp buffer-file-name)
         (string-match "/dissertation/" buffer-file-name))
        (setq ispell-local-dictionary "ru")))
    (add-hook 'find-file-hook 'set-dictionary-hook)
    

    或者您可以在.dir-locals.el 中指定它,如Emacs Manual 中所述 - 我认为这比第一种方法更简单,例如:

    ((tex-mode . ((ispell-local-dictionary . "english"))))
    

    对于具有特定模式的文件,或

    ((nil . ((ispell-local-dictionary . "english"))))
    

    所有文件

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-10-15
    • 1970-01-01
    • 1970-01-01
    • 2012-10-28
    • 1970-01-01
    • 1970-01-01
    • 2019-09-28
    • 2017-02-08
    相关资源
    最近更新 更多