diff --git a/modules/tools/flyspell/autoload.el b/modules/tools/flyspell/autoload.el index 54da4e769..e33ab0df4 100644 --- a/modules/tools/flyspell/autoload.el +++ b/modules/tools/flyspell/autoload.el @@ -14,7 +14,7 @@ (add-to-list '+flyspell--predicate-alist (cons mode predicate)))) ;;;###autoload -(defun +flyspell|init-predicate () +(defun +flyspell-init-predicate-h () "TODO" (when-let (pred (assq major-mode +flyspell--predicate-alist)) (setq-local flyspell-generic-check-word-predicate (cdr pred)))) diff --git a/modules/tools/flyspell/config.el b/modules/tools/flyspell/config.el index dc7afb19a..8cc79cdb5 100644 --- a/modules/tools/flyspell/config.el +++ b/modules/tools/flyspell/config.el @@ -27,17 +27,16 @@ Since spellchecking can be slow in some buffers, this can be disabled with: (setq ispell-program-name "aspell" ispell-extra-args '("--sug-mode=ultra" "--run-together")) - (defun +flyspell|remove-run-together-switch-for-aspell () - (setq-local ispell-extra-args (remove "--run-together" ispell-extra-args))) - (add-hook 'text-mode-hook #'+flyspell|remove-run-together-switch-for-aspell) + (add-hook 'text-mode-hook + (defun +flyspell-remove-run-together-switch-for-aspell-h () + (setq-local ispell-extra-args (remove "--run-together" ispell-extra-args)))) - (defun +flyspell*setup-ispell-extra-args (orig-fun &rest args) + (defun +flyspell-setup-ispell-extra-args-a (orig-fun &rest args) + :around '(ispell-word flyspell-auto-correct-word) (let ((ispell-extra-args (remove "--run-together" ispell-extra-args))) (ispell-kill-ispell t) (apply orig-fun args) - (ispell-kill-ispell t))) - (advice-add #'ispell-word :around #'+flyspell*setup-ispell-extra-args) - (advice-add #'flyspell-auto-correct-word :around #'+flyspell*setup-ispell-extra-args)) + (ispell-kill-ispell t)))) (`hunspell (setq ispell-program-name "hunspell")) @@ -52,29 +51,28 @@ Since spellchecking can be slow in some buffers, this can be disabled with: (when (featurep! +prog) (add-hook 'prog-mode-hook #'flyspell-prog-mode)) - (defun +flyspell|inhibit-duplicate-detection-maybe () - "Don't mark duplicates when style/grammar linters are present. + (add-hook 'flyspell-mode-hook + (defun +flyspell-inhibit-duplicate-detection-maybe-h () + "Don't mark duplicates when style/grammar linters are present. e.g. proselint and langtool." - (when (or (and (bound-and-true-p flycheck-mode) - (executable-find "proselint")) - (featurep 'langtool)) - (setq-local flyspell-mark-duplications-flag nil))) - (add-hook 'flyspell-mode-hook #'+flyspell|inhibit-duplicate-detection-maybe) + (when (or (and (bound-and-true-p flycheck-mode) + (executable-find "proselint")) + (featurep 'langtool)) + (setq-local flyspell-mark-duplications-flag nil)))) - (defun +flyspell|immediately () - "Spellcheck the buffer when `flyspell-mode' is enabled." - (when (and flyspell-mode +flyspell-immediately) - (flyspell-buffer))) - (add-hook 'flyspell-mode-hook #'+flyspell|immediately) + (add-hook 'flyspell-mode-hook + (defun +flyspell-immediately-h () + "Spellcheck the buffer when `flyspell-mode' is enabled." + (when (and flyspell-mode +flyspell-immediately) + (flyspell-buffer)))) ;; Ensure mode-local predicates declared with `set-flyspell-predicate!' are ;; used in their respective major modes. - (add-hook 'flyspell-mode-hook #'+flyspell|init-predicate)) + (add-hook 'flyspell-mode-hook #'+flyspell-init-predicate-h)) (def-package! flyspell-correct - :commands (flyspell-correct-word-generic - flyspell-correct-previous-word-generic) + :commands flyspell-correct-word-generic flyspell-correct-previous-word-generic :config (cond ((and (featurep! :completion helm) (require 'flyspell-correct-helm nil t)))