是否可以设置 AUCTeX,以便它加载与 使用的语言相同的拼写词典polyglossia
?例如,当文档包含\usepackage{polyglossia}
和时,是否可以加载丹麦语 ispell 词典\setdefaultlanguage{danish}
?
答案我怎样才能让 AUCTeX 使用与 babel 加载的相同语言的拼写词典?似乎不适用于本案。
答案1
我无法测试这个,因为我手头没有多个词典。但是如果它不能完全工作(添加到你的 .emacs 中),它应该可以帮助你入门:
;; replace the language names and dictionary paths below to suit your setup:
(defvar my-dicts
'(("danish" . "path-to-my-danish-dictionary")
("english" . "path-to-my-english-dictionary"))
"An alist of dictionaries to pick from")
(defun polyglossia-check ()
"If polyglossia is loaded, sets the dictionary to the value in my-dicts
corresponding to the value of setdefaultlanguage or setmainlanguage."
(interactive)
(if
(= (shell-command (concat "grep polyglossia " default-directory
TeX-auto-local "/*"))
0)
(save-excursion
(beginning-of-buffer)
(re-search-forward "\\(setdefaultlanguage\\|setmainlanguage\\){")
(mark-word)
(let ((lang (buffer-substring (point) (mark))))
(setq ispell-local-dictionary (cdr (assoc lang my-dicts)))))))
(add-hook 'TeX-auto-cleanup-hook 'polyglossia-check)
每当解析文档时,钩子就会运行。我不确定这种情况发生的频率。如果它似乎不起作用,请尝试M-x polyglossia-check
显式调用。