Merge pull request #1273 from UndeadKernel/choose_spellchecker

Choose which spell checker flyspell will use
This commit is contained in:
Henrik Lissner 2019-04-02 14:06:22 -04:00 committed by GitHub
commit 7286b32322
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -13,13 +13,24 @@ Since spellchecking can be slow in some buffers, this can be disabled with:
(after! ispell
(setq-default ispell-dictionary "english")
(add-to-list 'ispell-extra-args "--dont-tex-check-comments")
(cond ((executable-find "aspell")
;; Enable either aspell or hunspell.
;; If no module flags are given, enable either aspell or hunspell if their
;; binary is found.
;; If one of the flags `+aspell' or `+hunspell' is given, only enable that
;; spell checker.
(pcase (cond ((featurep! +aspell) 'aspell)
((featurep! +hunspell) 'hunspell)
((executable-find "aspell") 'aspell)
((executable-find "hunspell") 'hunspell))
(`aspell
(setq ispell-program-name "aspell"
ispell-extra-args '("--sug-mode=ultra" "--run-together"))
(setq-hook! 'text-mode-hook
ispell-extra-args (remove "--run-together" ispell-extra-args))
(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)
(defun +flyspell*setup-ispell-extra-args (orig-fun &rest args)
(let ((ispell-extra-args (remove "--run-together" ispell-extra-args)))
@ -29,7 +40,7 @@ Since spellchecking can be slow in some buffers, this can be disabled with:
(advice-add #'ispell-word :around #'+flyspell*setup-ispell-extra-args)
(advice-add #'flyspell-auto-correct-word :around #'+flyspell*setup-ispell-extra-args))
((executable-find "hunspell")
(`hunspell
(setq ispell-program-name "hunspell"
;; Don't use `ispell-cmd-args', it isn't respected with hunspell.
;; Hack ispell-local-dictionary-alist instead.
@ -41,9 +52,9 @@ Since spellchecking can be slow in some buffers, this can be disabled with:
nil
("-d" ,ispell-local-dictionary)
nil
utf-8)))))
utf-8))))
(add-to-list 'ispell-extra-args "--dont-tex-check-comments"))
(_ (warn "Spell checker not found. Either install `aspell' or `hunspell'"))))
;; `flyspell' (built-in)