2020-01-09 18:41:48 -05:00
|
|
|
;;; checkers/spell/config.el -*- lexical-binding: t; -*-
|
2019-02-22 00:20:29 -05:00
|
|
|
|
2020-01-02 21:10:38 -05:00
|
|
|
(defvar ispell-dictionary "en_US")
|
|
|
|
|
2019-02-22 00:20:29 -05:00
|
|
|
(after! ispell
|
2019-07-28 22:55:18 +02:00
|
|
|
;; Don't spellcheck org blocks
|
|
|
|
(pushnew! ispell-skip-region-alist
|
|
|
|
'(":\\(PROPERTIES\\|LOGBOOK\\):" . ":END:")
|
|
|
|
'("#\\+BEGIN_SRC" . "#\\+END_SRC")
|
|
|
|
'("#\\+BEGIN_EXAMPLE" . "#\\+END_EXAMPLE"))
|
|
|
|
|
2019-04-02 14:03:27 -04:00
|
|
|
;; 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"
|
2020-01-23 10:52:44 +00:00
|
|
|
ispell-extra-args '("--sug-mode=ultra" "--run-together" "--dont-tex-check-comments"))
|
2019-03-18 15:52:32 +01:00
|
|
|
|
2019-07-28 14:52:59 +02:00
|
|
|
(add-hook! 'text-mode-hook
|
2020-01-09 18:41:48 -05:00
|
|
|
(defun +spell-remove-run-together-switch-for-aspell-h ()
|
2019-07-22 23:34:23 +02:00
|
|
|
(setq-local ispell-extra-args (remove "--run-together" ispell-extra-args))))
|
2019-03-18 15:52:32 +01:00
|
|
|
|
2020-01-09 18:41:48 -05:00
|
|
|
(defun +spell-init-ispell-extra-args-a (orig-fun &rest args)
|
2019-07-22 23:34:23 +02:00
|
|
|
:around '(ispell-word flyspell-auto-correct-word)
|
2019-04-02 14:03:27 -04:00
|
|
|
(let ((ispell-extra-args (remove "--run-together" ispell-extra-args)))
|
|
|
|
(ispell-kill-ispell t)
|
|
|
|
(apply orig-fun args)
|
2019-07-22 23:34:23 +02:00
|
|
|
(ispell-kill-ispell t))))
|
2019-03-18 15:52:32 +01:00
|
|
|
|
2019-04-02 14:03:27 -04:00
|
|
|
(`hunspell
|
2019-05-06 19:39:35 -04:00
|
|
|
(setq ispell-program-name "hunspell"))
|
2019-02-22 00:20:29 -05:00
|
|
|
|
2019-06-18 17:30:26 +02:00
|
|
|
(_ (doom-log "Spell checker not found. Either install `aspell' or `hunspell'"))))
|
2019-02-22 00:20:29 -05:00
|
|
|
|
|
|
|
|
2019-05-06 19:39:35 -04:00
|
|
|
;;;###package flyspell
|
|
|
|
(progn ; built-in
|
2019-09-28 12:32:33 -04:00
|
|
|
(setq flyspell-issue-welcome-flag nil
|
|
|
|
;; Significantly speeds up flyspell, which would otherwise print
|
|
|
|
;; messages for every word when checking the entire buffer
|
|
|
|
flyspell-issue-message-flag nil)
|
2019-02-26 16:46:26 -05:00
|
|
|
|
2020-01-20 19:20:34 -05:00
|
|
|
(add-hook! '(org-mode-hook
|
|
|
|
markdown-mode-hook
|
|
|
|
TeX-mode-hook
|
|
|
|
rst-mode-hook
|
|
|
|
mu4e-compose-mode-hook
|
|
|
|
message-mode-hook)
|
|
|
|
#'flyspell-mode)
|
|
|
|
|
2019-12-24 16:43:30 -05:00
|
|
|
(when (featurep! +everywhere)
|
2020-01-20 19:20:34 -05:00
|
|
|
(add-hook! '(yaml-mode-hook
|
|
|
|
conf-mode-hook
|
|
|
|
prog-mode-hook)
|
2019-12-24 16:43:30 -05:00
|
|
|
#'flyspell-prog-mode))
|
2019-05-19 01:37:24 -04:00
|
|
|
|
2019-07-28 14:52:59 +02:00
|
|
|
(add-hook! 'flyspell-mode-hook
|
2020-01-09 18:41:48 -05:00
|
|
|
(defun +spell-inhibit-duplicate-detection-maybe-h ()
|
2019-07-22 23:34:23 +02:00
|
|
|
"Don't mark duplicates when style/grammar linters are present.
|
2019-02-26 16:46:26 -05:00
|
|
|
e.g. proselint and langtool."
|
2019-07-22 23:34:23 +02:00
|
|
|
(when (or (and (bound-and-true-p flycheck-mode)
|
|
|
|
(executable-find "proselint"))
|
|
|
|
(featurep 'langtool))
|
|
|
|
(setq-local flyspell-mark-duplications-flag nil))))
|
|
|
|
|
2019-02-26 16:46:26 -05:00
|
|
|
;; Ensure mode-local predicates declared with `set-flyspell-predicate!' are
|
|
|
|
;; used in their respective major modes.
|
2020-01-09 18:41:48 -05:00
|
|
|
(add-hook 'flyspell-mode-hook #'+spell-init-flyspell-predicate-h)
|
2019-10-26 21:34:44 -04:00
|
|
|
|
2020-01-20 22:23:40 -05:00
|
|
|
(let ((flyspell-correct
|
|
|
|
(general-predicate-dispatch nil
|
|
|
|
(and (not (or mark-active (ignore-errors (evil-insert-state-p))))
|
|
|
|
(memq 'flyspell-incorrect (face-at-point nil t)))
|
|
|
|
#'flyspell-correct-at-point)))
|
|
|
|
(map! :map flyspell-mouse-map
|
|
|
|
"RET" flyspell-correct
|
|
|
|
[return] flyspell-correct
|
|
|
|
[mouse-1] #'flyspell-correct-at-point)))
|
2019-02-22 00:20:29 -05:00
|
|
|
|
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! flyspell-correct
|
2019-12-30 15:06:44 -07:00
|
|
|
:commands flyspell-correct-at-point flyspell-correct-previous
|
2019-02-22 00:20:29 -05:00
|
|
|
:config
|
2019-04-02 15:33:03 -04:00
|
|
|
(cond ((and (featurep! :completion helm)
|
|
|
|
(require 'flyspell-correct-helm nil t)))
|
|
|
|
((and (featurep! :completion ivy)
|
|
|
|
(require 'flyspell-correct-ivy nil t)))
|
|
|
|
((require 'flyspell-correct-popup nil t)
|
2019-02-22 00:20:29 -05:00
|
|
|
(setq flyspell-popup-correct-delay 0.8)
|
|
|
|
(define-key popup-menu-keymap [escape] #'keyboard-quit))))
|
2020-02-08 20:43:29 -05:00
|
|
|
|
|
|
|
|
|
|
|
(use-package! flyspell-lazy
|
|
|
|
:after flyspell)
|