简体   繁体   中英

How do I change ispell private dictionary

I would like to do spell check on several files in a big project/repository and use a different private dictionary than my own. Such that I instead use a project dictionary and can later upload this for other users to use.

The answer by Chris is correct. Here is just an example of what I use to switch between aspell personal dictionaries, and also aspell languages. I use both flyspell and ispell . The paths to the personal dictionaries would need to be adjusted according to the user specifications.

(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."))) ))

From Emacs, the variable ispell-personal-dictionary can be used to select your personal dictionary file:

File name of your personal spelling dictionary, or nil. If nil, the default personal dictionary, ("~/.ispell_DICTNAME" for ispell or "~/.aspell.LANG.pws" for aspell) is used, where DICTNAME is the name of your default dictionary and LANG the two letter language code.

On modern systems, Emacs' ispell- functions generally use GNU aspell , a

a Free and Open Source spell checker designed to eventually replace Ispell

It isn't clear from your question whether everybody will be spell-checking through Emacs. Luckily, aspell supports a command-line option that works similarly:

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

I have this in my init.el file, which works great for me (found at 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)))

I've set a key combination to cycle from one dictionary to another

(global-set-key [M-f6] 'cycle-ispell-languages)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM