Subject: Ispell process restarted too often

From: Juri Linkov <[email-masked]>
Date: Sun, 10 Mar 2024 09:37:20 +0200

When different projects have different personal dictionaries
and flyspell mode is used, then ispell process is killed and restarted
almost on every key press.  This creates hundreds of hunspell processes
that soon fill all available memory.  Is it possible to fix this?

Here is an example of project-local .dir-locals.el:

  ((nil . ((ispell-personal-dictionary . "/tmp/test/.hunspell")
           (mode . flyspell))))

Example of backtrace after switching buffers
with different personal dictionaries:

  ispell-kill-ispell(t)
  ispell-internal-change-dictionary()
  ispell-buffer-local-dict()
  ispell-accept-buffer-local-defs()
  flyspell-accept-buffer-local-defs()
  flyspell-word()
  flyspell-check-changes()

Also tried to make the ispell process buffer-local with:

  (make-variable-buffer-local 'ispell-process)
  (make-variable-buffer-local 'ispell-current-personal-dictionary)

But this is worse and caused more problems:

  Error enabling Flyspell mode:
  (Buffer  *temp* has no process)
    flyspell-mode()
    set-auto-mode-0(flyspell-mode t)
    hack-one-local-variable(mode flyspell)
    hack-local-variables-apply()
    hack-dir-local-variables-non-file-buffer()
    project--value-in-dir(project-vc-name "/tmp/test/")
    project-name((vc Git "/tmp/test/"))
    project-mode-line-format()
    eval((project-mode-line-format) t)
    redisplay_internal\ \(C\ function\)()