tools/flyspell: conform to new conventions

This commit is contained in:
Henrik Lissner 2019-07-22 23:34:23 +02:00
parent 90f5128de2
commit 287e61a72c
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 21 additions and 23 deletions

View file

@ -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))))

View file

@ -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)))