diff --git a/modules/feature/spellcheck/config.el b/modules/feature/spellcheck/config.el index 9f2158a32..c1f8b3bb6 100644 --- a/modules/feature/spellcheck/config.el +++ b/modules/feature/spellcheck/config.el @@ -1,17 +1,25 @@ ;;; feature/spellcheck/config.el -*- lexical-binding: t; -*- +(defvar-local +spellcheck-immediately t + "If non-nil, spellcheck the current buffer upon starting `flyspell-mode'. + +Since spellchecking can be slow in some buffers, this can be disabled with: + + (setq-hook! 'LaTeX-mode-hook +spellcheck-immediately nil)") + (def-package! flyspell ; built-in :commands flyspell-mode + :init + (add-hook 'flyspell-mode-hook #'+spellcheck|immediately) :config (setq ispell-program-name (executable-find "aspell") ispell-list-command "--list" ispell-extr-args '("--dont-tex-check-comments")) - (defun +spellcheck|automatically () + (defun +spellcheck|immediately () "Spellcheck the buffer when `flyspell-mode' is enabled." - (when flyspell-mode - (flyspell-buffer))) - (add-hook 'flyspell-mode-hook #'+spellcheck|automatically)) + (when (and flyspell-mode +spellcheck-immediately) + (flyspell-buffer)))) (def-package! flyspell-correct