如何(自动)为特定目录下的每个文件将字典(例如,通过自动调用ispell-change-dictionary)设置为特定语言?
例如:我希望我的标准目录语言是美国英语(例如,通过在我的.emacs文件中设置(setq ispell-dictionary "en_US-wo_accents") ),但我希望/home/werner/dissertation/目录下(或:目录下)的所有文件都使用英国英语。也许对于/home/werner/letters/下的所有文件,也可以使用荷兰语。
我知道有一种解决方案规定在文件的第一行使用-*- ispell-dictionary: "english" -*-为该特定文件设置字典(在EmacsWiki.org中描述)。我想防止不得不把这一行放在我创建的每个新文件的顶部。
发布于 2012-01-26 01:25:34
您可以使用类似于(但当您想要为给定的文件创建复杂的东西时,此方法更有用):
(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)或者您可以像Emacs Manual中描述的那样在.dir-locals.el中指定它-我认为,这将比第一种方法更简单,类似于:
((tex-mode . ((ispell-local-dictionary . "english"))))对于具有特定模式的文件,或
((nil . ((ispell-local-dictionary . "english"))))对于所有文件
https://stackoverflow.com/questions/9005529
复制相似问题