checkers/spell: fix z=, zq, zw & personal dictionary
+ Fixes ispell not noticing allowed words in your personal dictionary. So +spell/correct would sometimes correct words that spell-fu wasn't highlighting as incorrect, and sometimes wouldn't correct words that were. + Fixes spell-fu refusing to read or write to the personal dictionary if the file didn't already exist beforehand (for zq and zw). + Change ispell-dictionary fallback from "en_US" (which aspell won't always recognize) to "en". + Moved ispell-personal-dictionary to ~/.emacs.d/.local/etc/ispell/ by default.
This commit is contained in:
parent
a8b7c00426
commit
c497cdabc7
2 changed files with 33 additions and 2 deletions
|
@ -49,6 +49,15 @@
|
||||||
(defun +spell/correct ()
|
(defun +spell/correct ()
|
||||||
"Correct spelling of word at point."
|
"Correct spelling of word at point."
|
||||||
(interactive)
|
(interactive)
|
||||||
|
;; We fake awareness for our personal dictionary by stopping short if spell-fu
|
||||||
|
;; hasn't highlighted the current word. This is necessary because
|
||||||
|
;; ispell/aspell struggles to find our `ispell-personal-dictionary' if it's
|
||||||
|
;; not in $HOME.
|
||||||
|
(unless (memq 'spell-fu-incorrect-face (face-at-point nil t))
|
||||||
|
(user-error "%S is correct" (thing-at-point 'word t)))
|
||||||
|
(ispell-set-spellchecker-params)
|
||||||
|
(save-current-buffer
|
||||||
|
(ispell-accept-buffer-local-defs))
|
||||||
(if (not (or (featurep! :completion ivy)
|
(if (not (or (featurep! :completion ivy)
|
||||||
(featurep! :completion helm)))
|
(featurep! :completion helm)))
|
||||||
(call-interactively #'ispell-word)
|
(call-interactively #'ispell-word)
|
||||||
|
|
|
@ -48,7 +48,6 @@
|
||||||
|
|
||||||
(global-set-key [remap ispell-word] #'+spell/correct)
|
(global-set-key [remap ispell-word] #'+spell/correct)
|
||||||
|
|
||||||
(defvar ispell-dictionary "en_US")
|
|
||||||
(after! ispell
|
(after! ispell
|
||||||
;; Don't spellcheck org blocks
|
;; Don't spellcheck org blocks
|
||||||
(pushnew! ispell-skip-region-alist
|
(pushnew! ispell-skip-region-alist
|
||||||
|
@ -67,7 +66,22 @@
|
||||||
((executable-find "hunspell") 'hunspell))
|
((executable-find "hunspell") 'hunspell))
|
||||||
(`aspell
|
(`aspell
|
||||||
(setq ispell-program-name "aspell"
|
(setq ispell-program-name "aspell"
|
||||||
ispell-extra-args '("--sug-mode=ultra" "--run-together" "--dont-tex-check-comments"))
|
ispell-extra-args '("--sug-mode=ultra"
|
||||||
|
"--run-together"
|
||||||
|
"--dont-tex-check-comments"))
|
||||||
|
|
||||||
|
(unless ispell-dictionary
|
||||||
|
(setq ispell-dictionary "en"))
|
||||||
|
(unless ispell-aspell-dict-dir
|
||||||
|
(setq ispell-aspell-dict-dir
|
||||||
|
(ispell-get-aspell-config-value "dict-dir")))
|
||||||
|
(unless ispell-aspell-data-dir
|
||||||
|
(setq ispell-aspell-data-dir
|
||||||
|
(ispell-get-aspell-config-value "data-dir")))
|
||||||
|
(unless ispell-personal-dictionary
|
||||||
|
(setq ispell-personal-dictionary
|
||||||
|
(expand-file-name (concat "ispell/" ispell-dictionary ".pws")
|
||||||
|
doom-etc-dir)))
|
||||||
|
|
||||||
(add-hook! 'text-mode-hook
|
(add-hook! 'text-mode-hook
|
||||||
(defun +spell-remove-run-together-switch-for-aspell-h ()
|
(defun +spell-remove-run-together-switch-for-aspell-h ()
|
||||||
|
@ -97,8 +111,16 @@
|
||||||
prog-mode-hook)
|
prog-mode-hook)
|
||||||
#'spell-fu-mode))
|
#'spell-fu-mode))
|
||||||
:config
|
:config
|
||||||
|
(defadvice! +spell--create-word-dict-a (_word words-file _action)
|
||||||
|
:before #'spell-fu--word-add-or-remove
|
||||||
|
(unless (file-exists-p words-file)
|
||||||
|
(make-directory (file-name-directory words-file) t)
|
||||||
|
(with-temp-file words-file
|
||||||
|
(insert (format "personal_ws-1.1 %s 0\n" ispell-dictionary)))))
|
||||||
|
|
||||||
(add-hook! 'spell-fu-mode-hook
|
(add-hook! 'spell-fu-mode-hook
|
||||||
(defun +spell-init-excluded-faces-h ()
|
(defun +spell-init-excluded-faces-h ()
|
||||||
|
"Set `spell-fu-faces-exclude' according to `+spell-excluded-faces-alist'."
|
||||||
(when-let (excluded (alist-get major-mode +spell-excluded-faces-alist))
|
(when-let (excluded (alist-get major-mode +spell-excluded-faces-alist))
|
||||||
(setq-local spell-fu-faces-exclude excluded))))
|
(setq-local spell-fu-faces-exclude excluded))))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue