如何更改ispell私人字典

时间:2014-12-18 10:54:19

标签: emacs ispell

我想对大项目/存储库中的几个文件进行拼写检查,并使用与我自己不同的私有字典。这样我就可以使用项目字典,以后可以将其上传给其他用户使用。

3 个答案:

答案 0 :(得分:4)

克里斯的回答是正确的。以下是我用于在aspell个人词典和aspell语言之间切换的示例。我同时使用flyspellispell。个人词典的路径需要根据用户规范进行调整。

(defface ispell-alpha-num-choice-face
  '((t (:background "black" :foreground "red")))
  "Face for `ispell-alpha-num-choice-face`."
  :group 'ispell)

(defface ispell-text-choice-face
  '((t (:background "black" :foreground "forestgreen")))
  "Face for `ispell-text-choice-face`."
  :group 'ispell)

(defun my-ispell-change-dictionaries ()
"Switch between language dictionaries."
(interactive)
  (let ((choice (read-char-exclusive (concat
          "["
          (propertize "E" 'face 'ispell-alpha-num-choice-face)
          "]"
          (propertize "nglish" 'face 'ispell-text-choice-face)
          " | ["
          (propertize "S" 'face 'ispell-alpha-num-choice-face)
          "]"
          (propertize "panish" 'face 'ispell-text-choice-face)))))
    (cond
      ((eq choice ?E)
        (setq flyspell-default-dictionary "english")
        (setq ispell-dictionary "english")
        (setq ispell-personal-dictionary "/Users/HOME/.0.data/.0.emacs/.aspell.en.pws")
        (ispell-kill-ispell)
        (message "English"))
      ((eq choice ?S)
        (setq flyspell-default-dictionary "spanish")
        (setq ispell-dictionary "spanish")
        (setq ispell-personal-dictionary "/Users/HOME/.0.data/.0.emacs/.aspell.es.pws")
        (ispell-kill-ispell)
        (message "Español"))
      (t (message "No changes have been made."))) ))

答案 1 :(得分:3)

从Emacs,变量ispell-personal-dictionary可用于选择您的个人词典文件:

  

您的个人拼写字典的文件名,或者为零。如果没有,那么   默认的个人字典,("〜/。ispell_DICTNAME"用于ispell或   "〜/ .aspell.LANG.pws"使用aspell),其中DICTNAME是名称   您的默认字典和LANG是两个字母的语言代码。

在现代系统上,Emacs' ispell-个函数通常使用GNU aspell

  

一个免费和开源的拼写检查器,旨在最终取代Ispell

从您的问题中不清楚是否所有人都将通过Emacs进行拼写检查。幸运的是,aspell支持一个类似的命令行选项:

--personal=<file>, -p <file>
    Personal word list file name.

答案 2 :(得分:1)

我的init.el文件中有这个,这对我很有用 (见http://www.emacswiki.org/emacs/FlySpell

(setq ispell-program-name "aspell")
(setq ispell-list-command "list")


(let ((langs '("spanish" "british" "french")))
  (setq lang-ring (make-ring (length langs)))
  (dolist (elem langs) (ring-insert lang-ring elem)))
(defun cycle-ispell-languages ()
  (interactive)
  (let ((lang (ring-ref lang-ring -1)))
    (ring-insert lang-ring lang)
    (ispell-change-dictionary lang)))

我已经设置了一个键组合,可以从一个字典循环到另一个字典

(global-set-key [M-f6] 'cycle-ispell-languages)
相关问题