【发布时间】:2013-02-16 20:32:08
【问题描述】:
我仅将 Emacs 用于 \LaTeX 和 python 编程。有没有办法在处理 .tex 文件时自动打开 flyspell-mode,在处理 .py 文件时自动打开 flyspell-prog-mode?如何在我的 .emacs 文件中执行此操作?
【问题讨论】:
标签: emacs emacs24 aspell flyspell
我仅将 Emacs 用于 \LaTeX 和 python 编程。有没有办法在处理 .tex 文件时自动打开 flyspell-mode,在处理 .py 文件时自动打开 flyspell-prog-mode?如何在我的 .emacs 文件中执行此操作?
【问题讨论】:
标签: emacs emacs24 aspell flyspell
将这些函数添加到 python-mode 和 latex-mode 的钩子中
(require 'python)
;; If you use tex-mode
(require 'tex-mode)`
(add-hook 'latex-mode-hook 'flyspell-mode)
;; If you use AUCTeX
(load "auctex.el" nil t t)`
(add-hook 'LaTeX-mode-hook 'flyspell-mode)
(add-hook 'python-mode-hook 'flyspell-prog-mode)
【讨论】:
LaTeX-mode-hook,这就是我让它工作的方式。小写没有用。也许是emacs版本?我正在为 Windows 使用 GNU Emacs 24。
这样的事情应该可以工作。
(setq auto-mode-alist (cons '("\\.tex\\'" . flyspell-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.py\\'" . flyspell-prog-mode) auto-mode-alist))
【讨论】:
flyspell,但它完全关闭了语法高亮,并且它不能识别非单词,例如数学方程式和\emph{}之类的东西。它将它们全部标记为拼写错误。