2015-08-11 18:00:16 +00:00
|
|
|
;;; packages.el --- Spell Checking Layer packages File for Spacemacs
|
|
|
|
;;
|
2016-01-12 02:40:54 +00:00
|
|
|
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
|
2015-08-11 18:00:16 +00:00
|
|
|
;;
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
|
|
|
;;; License: GPLv3
|
|
|
|
|
|
|
|
(setq spell-checking-packages
|
|
|
|
'(
|
2015-10-20 13:05:24 +00:00
|
|
|
auto-dictionary
|
2015-08-11 18:00:16 +00:00
|
|
|
flyspell
|
2016-05-06 14:50:56 +00:00
|
|
|
flyspell-correct
|
2016-06-06 08:41:17 +00:00
|
|
|
(flyspell-correct-ivy :toggle (configuration-layer/layer-usedp 'ivy))
|
|
|
|
(flyspell-correct-helm :toggle (configuration-layer/layer-usedp 'helm))
|
|
|
|
(flyspell-correct-popup :toggle (and (not (configuration-layer/layer-usedp 'ivy))
|
|
|
|
(not (configuration-layer/layer-usedp 'helm))))
|
|
|
|
(flyspell-popup :toggle enable-flyspell-auto-completion)))
|
2015-08-11 18:00:16 +00:00
|
|
|
|
2015-10-20 13:05:24 +00:00
|
|
|
(defun spell-checking/init-auto-dictionary ()
|
|
|
|
(use-package auto-dictionary
|
|
|
|
:defer t
|
2015-11-01 16:27:44 +00:00
|
|
|
:if spell-checking-enable-auto-dictionary
|
2015-10-20 13:05:24 +00:00
|
|
|
:init
|
2015-11-02 11:50:35 +00:00
|
|
|
(progn
|
|
|
|
(add-hook 'flyspell-mode-hook 'auto-dictionary-mode)
|
|
|
|
;; Select the buffer local dictionary if it was set, otherwise
|
|
|
|
;; auto-dictionary will replace it with a guessed one at each activation.
|
|
|
|
;; https://github.com/nschum/auto-dictionary-mode/issues/5
|
2015-11-03 04:02:01 +00:00
|
|
|
(defun spacemacs//adict-set-local-dictionary ()
|
|
|
|
"Set the local dictionary if not nil."
|
|
|
|
(when (and (fboundp 'adict-change-dictionary)
|
|
|
|
ispell-local-dictionary)
|
|
|
|
(adict-change-dictionary ispell-local-dictionary)))
|
2015-11-02 11:50:35 +00:00
|
|
|
(add-hook 'auto-dictionary-mode-hook
|
2015-11-03 04:02:01 +00:00
|
|
|
'spacemacs//adict-set-local-dictionary 'append))))
|
2015-10-20 13:05:24 +00:00
|
|
|
|
2015-08-11 18:00:16 +00:00
|
|
|
(defun spell-checking/init-flyspell ()
|
|
|
|
(use-package flyspell
|
|
|
|
:defer t
|
2015-10-20 13:05:24 +00:00
|
|
|
:commands (spell-checking/change-dictionary)
|
2015-08-11 18:00:16 +00:00
|
|
|
:init
|
|
|
|
(progn
|
2015-12-09 11:29:19 +00:00
|
|
|
(spell-checking/add-flyspell-hook 'text-mode-hook)
|
2015-12-17 19:38:21 +00:00
|
|
|
(when spell-checking-enable-by-default
|
|
|
|
(add-hook 'prog-mode-hook 'flyspell-prog-mode))
|
2015-10-15 11:10:06 +00:00
|
|
|
|
2015-08-11 18:00:16 +00:00
|
|
|
(spacemacs|add-toggle spelling-checking
|
|
|
|
:status flyspell-mode
|
2015-11-02 11:50:35 +00:00
|
|
|
:on (if (derived-mode-p 'prog-mode)
|
|
|
|
(flyspell-prog-mode)
|
|
|
|
(flyspell-mode))
|
|
|
|
:off (progn
|
|
|
|
(flyspell-mode-off)
|
|
|
|
;; Also disable auto-dictionary when disabling spell-checking.
|
|
|
|
(when (fboundp 'auto-dictionary-mode) (auto-dictionary-mode -1)))
|
|
|
|
:documentation "Enable automatic spell checking."
|
2015-09-08 01:16:15 +00:00
|
|
|
:evil-leader "tS")
|
2015-10-15 11:10:06 +00:00
|
|
|
|
2016-04-03 04:12:28 +00:00
|
|
|
(spacemacs/declare-prefix "S" "spelling")
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys
|
2015-11-02 21:18:11 +00:00
|
|
|
"Sb" 'flyspell-buffer
|
2015-10-20 13:05:24 +00:00
|
|
|
"Sd" 'spell-checking/change-dictionary
|
2015-09-08 01:16:15 +00:00
|
|
|
"Sn" 'flyspell-goto-next-error))
|
2016-04-03 04:12:28 +00:00
|
|
|
:config (spacemacs|diminish flyspell-mode " Ⓢ" " S")))
|
2015-08-11 18:00:16 +00:00
|
|
|
|
2016-05-06 14:50:56 +00:00
|
|
|
(defun spell-checking/init-flyspell-correct ()
|
|
|
|
(use-package flyspell-correct
|
2016-06-06 08:41:17 +00:00
|
|
|
:commands (flyspell-correct-word-generic
|
|
|
|
flyspell-correct-previous-word-generic)
|
2016-05-06 14:50:56 +00:00
|
|
|
:init
|
2016-06-06 08:41:17 +00:00
|
|
|
(spacemacs/set-leader-keys "Sc" 'flyspell-correct-previous-word-generic)))
|
|
|
|
|
|
|
|
(defun spell-checking/init-flyspell-correct-ivy ()
|
|
|
|
(use-package flyspell-correct-ivy))
|
|
|
|
|
|
|
|
(defun spell-checking/init-flyspell-correct-helm ()
|
|
|
|
(use-package flyspell-correct-helm))
|
|
|
|
|
|
|
|
(defun spell-checking/init-flyspell-correct-popup ()
|
|
|
|
(use-package flyspell-correct-popup))
|
2016-06-02 02:52:05 +00:00
|
|
|
|
|
|
|
(defun spell-checking/init-flyspell-popup ()
|
|
|
|
(use-package flyspell-popup
|
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(progn
|
2016-06-02 03:00:02 +00:00
|
|
|
(setq flyspell-popup-correct-delay 0.8)
|
2016-06-02 02:52:05 +00:00
|
|
|
(add-hook 'flyspell-mode-hook 'flyspell-popup-auto-correct-mode))))
|