Fix behaviour without aspell
If aspell (or a spell-fu acceptable equivalent) warn the user. If it failed to bind +spell-correct-interface, and bind that. Remove previous hack. It prevents use of +spell/correct if spell-fu does not try to highlight a word. This is extreamly common is docstrings, for example. I think having +spell/correct should check any word it is called upon, even without general text highlighting.
This commit is contained in:
parent
f7293fb67e
commit
ea16bb66c3
2 changed files with 22 additions and 12 deletions
|
@ -50,12 +50,20 @@
|
||||||
(defun +spell/correct ()
|
(defun +spell/correct ()
|
||||||
"Correct spelling of word at point."
|
"Correct spelling of word at point."
|
||||||
(interactive)
|
(interactive)
|
||||||
;; HACK Fake awareness for our personal dictionary by stopping short if
|
;; spell-fu fails to initialize correctly if it can't find aspell or a similar
|
||||||
;; spell-fu hasn't highlighted the current word. This is necessary
|
;; program. We want to signal the error, not tell the user that every word is
|
||||||
;; because ispell/aspell struggles to find our
|
;; spelled correctly.
|
||||||
;; `ispell-personal-dictionary' if it's not in $HOME.
|
(unless (;; This is what spell-fu uses to check for the aspell executable
|
||||||
(unless (memq 'spell-fu-incorrect-face (face-at-point nil t))
|
or (and ispell-really-aspell ispell-program-name)
|
||||||
(user-error "%S is correct" (thing-at-point 'word t)))
|
(executable-find "aspell"))
|
||||||
|
(user-error "Aspell is required for spell checking"))
|
||||||
|
;; HACK When spell-fu fails to initialize correctly, the init form for the
|
||||||
|
;; spell-fu use-package! is not called. This leaves emacs to assume that
|
||||||
|
;; certain variables are initialized when they are not. We bind what we
|
||||||
|
;; need.
|
||||||
|
(unless (boundp '+spell-correct-interface)
|
||||||
|
(+spell-defun-correct-interface))
|
||||||
|
|
||||||
(ispell-set-spellchecker-params)
|
(ispell-set-spellchecker-params)
|
||||||
(save-current-buffer
|
(save-current-buffer
|
||||||
(ispell-accept-buffer-local-defs))
|
(ispell-accept-buffer-local-defs))
|
||||||
|
|
|
@ -70,19 +70,21 @@
|
||||||
|
|
||||||
(eval-if! (not (featurep! +flyspell))
|
(eval-if! (not (featurep! +flyspell))
|
||||||
|
|
||||||
(use-package! spell-fu
|
(defun +spell-defun-correct-interface ()
|
||||||
:when (executable-find "aspell")
|
|
||||||
:hook (text-mode . spell-fu-mode)
|
|
||||||
:general ([remap ispell-word] #'+spell/correct)
|
|
||||||
:init
|
|
||||||
(defvar +spell-correct-interface
|
(defvar +spell-correct-interface
|
||||||
(cond ((featurep! :completion ivy)
|
(cond ((featurep! :completion ivy)
|
||||||
#'+spell-correct-ivy-fn)
|
#'+spell-correct-ivy-fn)
|
||||||
((featurep! :completion helm)
|
((featurep! :completion helm)
|
||||||
#'+spell-correct-helm-fn)
|
#'+spell-correct-helm-fn)
|
||||||
(#'+spell-correct-generic-fn))
|
(#'+spell-correct-generic-fn))
|
||||||
"Function to use to display corrections.")
|
"Function to use to display corrections."))
|
||||||
|
|
||||||
|
(use-package! spell-fu
|
||||||
|
:when (executable-find "aspell")
|
||||||
|
:hook (text-mode . spell-fu-mode)
|
||||||
|
:general ([remap ispell-word] #'+spell/correct)
|
||||||
|
:init
|
||||||
|
(+spell-defun-correct-interface)
|
||||||
(defvar +spell-excluded-faces-alist
|
(defvar +spell-excluded-faces-alist
|
||||||
'((markdown-mode
|
'((markdown-mode
|
||||||
. (markdown-code-face
|
. (markdown-code-face
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue