d12frosted / flyspell-correct

Distraction-free words correction with flyspell via selected interface.
Other
200 stars 14 forks source link

Does personal dictionary save work? #97

Closed notuntoward closed 2 years ago

notuntoward commented 2 years ago

I'm using flyspell-correct andflyspell-correct-ivy and I have a question: Should I expect the "Save" button to save to my personal dictionary?

When I see that a word not in the default hunspelldictionary is marked as misspelled, I typeC-;and then M-o s. After that, I see the squiggly misspelled error face disappear, along with a message in the mini-buffer, saying: "Personal dictionary saved."

But if I kill emacs and reopen the org-file I was working on, the same word is, again, marked as misspelled.

I've already googled quite a bit, and have tried every suggested hunspelltweak, but saved words are still not saved.

Here are the relevant parts of my config:

(setq hunspell_bin (executable-find "hunspell"))
(setq hunspell_dict_dir (expand-file-name "~/.hunspell"))
(use-package flyspell
  :init
  (setenv "DICPATH" hunspell_dict_dir)
  :custom
  (flyspell-issue-message-flag nil)
  (flyspell-issue-welcome-flag nil)
  (ispell-program-name hunspell_bin)
  ;; (ispell-extra-args '("-i utf-8 -p en_US"))
  (ispell-dictionary "english")
  (ispell-silently-savep t)
  :config
  (setq ispell-really-hunspell t
    ;; ispell-extra-args '("-i" "utf-8")
    ispell-local-dictionary-alist
    '(("deutsch"
       "[A-Za-zöäüß]" "[^A-Za-zöäüß]" "[']" nil
       ("-d" "de_DE_frami" "-p" hunspell_dict_dir)
       nil utf-8)
      ("english"
       "[A-Za-z]" "[^A-Za-z]" "[']" nil
       ("-d" "en_US" "-p" hunspell_dict_dir)
       nil utf-8))
        ispell-dictionary-alist ispell-local-dictionary-alist
        ispell-hunspell-dictionary-alist ispell-dictionary-alist))

(use-package flyspell-correct
  :after flyspell
  :bind (:map flyspell-mode-map ("C-;" . flyspell-correct-wrapper)))

(use-package flyspell-correct-ivy
  :after flyspell-correct)
d12frosted commented 2 years ago

Hey @notuntoward,

I think it might be related to overloading ispell-dictionary-alist. Could you please try without these modifications and see if that works?

Also, does ~/.hunspell exist? It might silently fail if that directory does not exist.

I actually never used hunspell, maybe there is more sources of problems. I am using aspell and it works flawlessly. Just for the record, this is my configuration.

(use-package ispell
  :config
  (setq ispell-dictionary "english"
        ispell-program-name (executable-find "aspell"))
  (when (equal (file-name-base ispell-program-name) "aspell")
    (add-to-list 'ispell-extra-args "--sug-mode=ultra")))

(use-package flyspell
  :defer t
  :diminish flyspell-mode
  :hook ((text-mode . flyspell-mode)
         (prog-mode . flyspell-prog-mode)))

(use-package flyspell-correct
  :defer t
  :general
  (leader-def
    "[s" '(flyspell-correct-wrapper
           :which-key "Spelling correction")))

And it stores personal dictionary in $HOME/.aspell.en.pws by default.

notuntoward commented 2 years ago

Thanks for the reply. Yes, ~/.hunspellexists, and flyspell_check successfully uses the dictionaries installed there to correct spelling. It's just saving to the personal dictionaries that doesn't work. Too ba, because I'm having difficulty installing aspell on Windows.

However, aspell installation was easy, and a setup like yours does correctly save to a personal dictionary, both on Windows and MacOS,

So, this seems to be a hunspell problem.

notuntoward commented 2 years ago

Closed since it seems to be a hunspell problem, not one with flyspell_check.

gety9 commented 2 years ago

@notuntoward

Hi there, i am also on windows and made it work so posting in case it will be helpful to someone. I did 2 things:

  1. added ispell-personal-dictionary variable where i want personal dictionary to be (setq ispell-personal-dictionary "e:/Dropbox/Hunspell_en_US")

  2. Manually created above file (empty). Without it after pressing "SAVE" Flyspell pop-up was saying that word is saved to personal dictionary but upon closing/opening buffer it marked it as incorrect again.

That's it.

Step 1 also can be achieved by passing "-p" in ispell-extra-args. But i liked ispell-personal-dictionary way better.