1

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.

Erex
  • 11
  • 1
  • 2

3 Answers3

5

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."))) ))
lawlist
  • 13,099
  • 3
  • 49
  • 158
4

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.
ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
  • 1
    After changing the `ispell-personal-dictionary` for a buffer that is already open with `flyspell` active, I use `ispell-kill-ispell` to get the new ispell session started. When setting `ispell-personal-dictionary` before the buffer is loaded, there is no need to call `ispell-kill-ispell`. – lawlist Dec 18 '14 at 16:57
  • @lawlist: Running `ispell-kill-ispell` is not enough to force `ispell` to reload a new `ispell-personal-dictionary` that has been set. Restarting emacs will force `ispell` to use a new personal dictionary, but this should not be necessary. Any ideas on how to change personal dictionary while remaining in the same emacs 28 editor session? – StackExchanger Jul 02 '23 at 22:36
1

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)
pilgix
  • 323
  • 2
  • 9