Add variables to opt-in to flycheck/flyspell

This commit is contained in:
Eivind Fonn 2015-08-28 13:02:20 +02:00 committed by syl20bnr
parent 74a717f2bb
commit 56ecd43753
25 changed files with 89 additions and 38 deletions

View File

@ -39,7 +39,7 @@
(spacemacs|add-company-hook puppet-mode)) (spacemacs|add-company-hook puppet-mode))
(defun puppet/post-init-flycheck () (defun puppet/post-init-flycheck ()
(add-hook 'puppet-mode-hook 'flycheck-mode)) (spacemacs/add-flycheck-hook 'puppet-mode))
(defun puppet/init-puppetfile-mode () (defun puppet/init-puppetfile-mode ()
(use-package puppetfile-mode (use-package puppetfile-mode

View File

@ -44,7 +44,7 @@
'(json-jsonlist)))))) '(json-jsonlist))))))
(defun react/post-init-flycheck () (defun react/post-init-flycheck ()
(add-hook 'react-mode-hook 'flycheck-mode)) (spacemacs/add-flycheck-hook 'react-mode))
(defun react/post-init-js-doc () (defun react/post-init-js-doc ()
(add-hook 'react-mode-hook 'spacemacs/js-doc-require) (add-hook 'react-mode-hook 'spacemacs/js-doc-require)

View File

@ -24,8 +24,8 @@
:defer t :defer t
:init :init
(progn (progn
(spacemacs/add-to-hook 'rcirc-mode-hook '(flyspell-mode (spacemacs/add-flyspell-hook 'rcirc-mode)
rcirc-omit-mode (spacemacs/add-to-hook 'rcirc-mode-hook '(rcirc-omit-mode
rcirc-track-minor-mode)) rcirc-track-minor-mode))
(defun spacemacs//rcirc-with-authinfo (arg) (defun spacemacs//rcirc-with-authinfo (arg)

View File

@ -126,7 +126,8 @@
:init (push 'company-c-headers company-backends-c-mode-common)))) :init (push 'company-c-headers company-backends-c-mode-common))))
(defun c-c++/post-init-flycheck () (defun c-c++/post-init-flycheck ()
(spacemacs/add-to-hooks 'flycheck-mode '(c-mode-hook c++-mode-hook))) (dolist (mode '(c-mode-hook c++-mode-hook))
(spacemacs/add-flycheck-hook mode)))
(defun c-c++/init-gdb-mi () (defun c-c++/init-gdb-mi ()
(use-package gdb-mi (use-package gdb-mi

View File

@ -26,7 +26,7 @@
(when (configuration-layer/layer-usedp 'syntax-checking) (when (configuration-layer/layer-usedp 'syntax-checking)
(defun d/post-init-flycheck () (defun d/post-init-flycheck ()
(add-hook 'd-mode-hook 'flycheck-mode)) (spacemacs/add-flycheck-hook 'd-mode))
(defun d/init-flycheck-dmd-dub () (defun d/init-flycheck-dmd-dub ()
(use-package flycheck-dmd-dub :defer t (use-package flycheck-dmd-dub :defer t
:init (add-hook 'd-mode-hook 'flycheck-dmd-dub-set-include-path)))) :init (add-hook 'd-mode-hook 'flycheck-dmd-dub-set-include-path))))

View File

@ -105,6 +105,7 @@
"")))) ""))))
(defun emacs-lisp/post-init-flycheck () (defun emacs-lisp/post-init-flycheck ()
(spacemacs/add-flycheck-hook 'emacs-lisp-mode)
;; Make flycheck recognize packages in loadpath ;; Make flycheck recognize packages in loadpath
;; i.e (require 'company) will not give an error now ;; i.e (require 'company) will not give an error now
(setq flycheck-emacs-lisp-load-path 'inherit)) (setq flycheck-emacs-lisp-load-path 'inherit))

View File

@ -42,4 +42,4 @@
(require 'erlang-start))) (require 'erlang-start)))
(defun erlang/post-init-flycheck () (defun erlang/post-init-flycheck ()
(add-hook 'erlang-mode-hook 'flycheck-mode)) (spacemacs/add-flycheck-hook 'erlang-mode))

View File

@ -8,7 +8,7 @@
)) ))
(defun go/post-init-flycheck () (defun go/post-init-flycheck ()
(add-hook 'go-mode-hook 'flycheck-mode)) (spacemacs/add-flycheck-hook 'go-mode))
(defun go/init-go-mode() (defun go/init-go-mode()
(when (memq window-system '(mac ns x)) (when (memq window-system '(mac ns x))

View File

@ -30,7 +30,7 @@
:defer t)) :defer t))
(defun haskell/post-init-flycheck () (defun haskell/post-init-flycheck ()
(add-hook 'haskell-mode-hook 'flycheck-mode)) (spacemacs/add-flycheck-hook 'haskell-mode))
(when (configuration-layer/layer-usedp 'syntax-checking) (when (configuration-layer/layer-usedp 'syntax-checking)
(defun haskell/init-flycheck-haskell () (defun haskell/init-flycheck-haskell ()

View File

@ -97,13 +97,8 @@
(add-hook 'web-mode-hook 'evil-matchit-mode)) (add-hook 'web-mode-hook 'evil-matchit-mode))
(defun html/post-init-flycheck () (defun html/post-init-flycheck ()
(spacemacs/add-to-hooks 'flycheck-mode '(haml-mode-hook (dolist (mode '(haml-mode jade-mode less-mode sass-mode scss-mode slim-mode web-mode))
jade-mode-hook (spacemacs/add-flycheck-hook mode)))
less-mode-hook
sass-mode-hook
scss-mode-hook
slim-mode-hook
web-mode-hook)))
(defun html/init-haml-mode () (defun html/init-haml-mode ()
(use-package haml-mode (use-package haml-mode

View File

@ -55,9 +55,8 @@
(push 'company-tern company-backends-js2-mode)))) (push 'company-tern company-backends-js2-mode))))
(defun javascript/post-init-flycheck () (defun javascript/post-init-flycheck ()
(add-hook 'coffee-mode-hook 'flycheck-mode) (dolist (mode '(coffee-mode js2-mode json-mode))
(add-hook 'js2-mode-hook 'flycheck-mode) (spacemacs/add-flycheck-hook mode)))
(add-hook 'json-mode-hook 'flycheck-mode))
(defun javascript/init-js-doc () (defun javascript/init-js-doc ()
(use-package js-doc (use-package js-doc

View File

@ -102,7 +102,7 @@
(add-hook 'LaTeX-mode-hook 'evil-matchit-mode)) (add-hook 'LaTeX-mode-hook 'evil-matchit-mode))
(defun latex/post-init-flycheck () (defun latex/post-init-flycheck ()
(add-hook 'LaTeX-mode-hook 'flycheck-mode)) (spacemacs/add-flycheck-hook 'LaTeX-mode))
(defun latex/post-init-flyspell () (defun latex/post-init-flyspell ()
(add-hook 'LaTeX-mode-hook 'flyspell-mode)) (add-hook 'LaTeX-mode-hook 'flyspell-mode))

View File

@ -6,7 +6,7 @@
)) ))
(defun lua/post-init-flycheck () (defun lua/post-init-flycheck ()
(add-hook 'lua-mode-hook 'flycheck-mode)) (spacemacs/add-flycheck-hook 'lua-mode))
(defun lua/init-lua-mode () (defun lua/init-lua-mode ()
(use-package lua-mode (use-package lua-mode

View File

@ -6,6 +6,6 @@
'(flycheck-nim)) '(flycheck-nim))
(defun nim/init-flycheck-nim () (defun nim/init-flycheck-nim ()
(add-hook 'nim-mode-hook 'flycheck-mode) (spacemacs/add-flycheck-hook 'nim-mode)
(use-package flycheck-nim (use-package flycheck-nim
:if (configuration-layer/layer-usedp 'syntax-checking))) :if (configuration-layer/layer-usedp 'syntax-checking)))

View File

@ -30,7 +30,7 @@
(when (configuration-layer/layer-usedp 'syntax-checking) (when (configuration-layer/layer-usedp 'syntax-checking)
(defun ocaml/post-init-flycheck () (defun ocaml/post-init-flycheck ()
(add-hook 'merlin-mode-hook 'flycheck-mode)) (spacemacs/add-flycheck-hook 'merlin-mode))
(defun ocaml/init-flycheck-ocaml () (defun ocaml/init-flycheck-ocaml ()
(use-package flycheck-ocaml (use-package flycheck-ocaml
:if (configuration-layer/package-usedp 'flycheck) :if (configuration-layer/package-usedp 'flycheck)

View File

@ -262,7 +262,7 @@
(add-hook `python-mode-hook `turn-on-evil-matchit-mode)) (add-hook `python-mode-hook `turn-on-evil-matchit-mode))
(defun python/post-init-flycheck () (defun python/post-init-flycheck ()
(add-hook 'python-mode-hook 'flycheck-mode)) (spacemacs/add-flycheck-hook 'python-mode))
(defun python/init-hy-mode () (defun python/init-hy-mode ()
(use-package hy-mode (use-package hy-mode

View File

@ -61,7 +61,7 @@
(defun ruby/post-init-flycheck () (defun ruby/post-init-flycheck ()
(add-hook 'enh-ruby-mode-hook 'flycheck-mode)) (spacemacs/add-flycheck-hook 'enh-ruby-mode))
(defun ruby/init-ruby-tools () (defun ruby/init-ruby-tools ()
(use-package ruby-tools (use-package ruby-tools

View File

@ -22,7 +22,7 @@
)) ))
(defun rust/post-init-flycheck () (defun rust/post-init-flycheck ()
(add-hook 'rust-mode-hook 'flycheck-mode)) (spacemacs/add-flycheck-hook 'rust-mode))
(when (configuration-layer/layer-usedp 'syntax-checking) (when (configuration-layer/layer-usedp 'syntax-checking)
(defun rust/init-flycheck-rust () (defun rust/init-flycheck-rust ()

View File

@ -5,16 +5,14 @@
- [[#install][Install]] - [[#install][Install]]
- [[#layer][Layer]] - [[#layer][Layer]]
- [[#spell-checker-configuration][Spell Checker Configuration]] - [[#spell-checker-configuration][Spell Checker Configuration]]
- [[#disabling-by-default][Disabling by default]]
- [[#key-bindings][Key Bindings]] - [[#key-bindings][Key Bindings]]
* Description * Description
This layer provides spell checking using [[http://www-sop.inria.fr/members/Manuel.Serrano/flyspell/flyspell.html][Flyspell]]. This layer provides spell checking using [[http://www-sop.inria.fr/members/Manuel.Serrano/flyspell/flyspell.html][Flyspell]].
* Install * Install
** Layer ** Layer
To use this configuration layer add it to your =~/.spacemacs= To use this configuration layer add it to your =~/.spacemacs=
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
@ -22,7 +20,6 @@ To use this configuration layer add it to your =~/.spacemacs=
#+END_SRC #+END_SRC
** Spell Checker Configuration ** Spell Checker Configuration
The built-in Emacs variable that controls which external spell-checking program The built-in Emacs variable that controls which external spell-checking program
is used is =ispell-program-name=, which can be set in your is used is =ispell-program-name=, which can be set in your
=dotspacemacs/user-init= function if you do not like the default. It will give =dotspacemacs/user-init= function if you do not like the default. It will give
@ -31,6 +28,15 @@ variable to be aware of is =ispell-dictionary= which will control the default
dictionary used by =ispell-program-name= (instead of using this variable you can dictionary used by =ispell-program-name= (instead of using this variable you can
also use the key binding ~SPC S d~). also use the key binding ~SPC S d~).
** Disabling by default
By default, spell-checking is enabled in all available major modes and may be
toggled off with ~SPC t S~. You can default this to off by setting the variable
=spell-checking-enable-by-default= to =nil=:
#+BEGIN_SRC emacs-lisp
(setq-default dotspacemacs-configuration-layers
'((spell-checking :variables spell-checking-enable-by-default nil)))
#+END_SRC
* Key Bindings * Key Bindings

View File

@ -15,3 +15,6 @@
;; Command Prefixes ;; Command Prefixes
(spacemacs/declare-prefix "S" "spelling") (spacemacs/declare-prefix "S" "spelling")
(defvar spell-checking-enable-by-default t
"Enable spell checking by default.")

View File

@ -0,0 +1,18 @@
;;; funcs.el --- Spell Checking Layer functions File for Spacemacs
;;
;; Copyright (c) 2012-2014 Sylvain Benner
;; Copyright (c) 2014-2015 Sylvain Benner & Contributors
;;
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
(defun spacemacs/add-flyspell-hook (mode &optional target)
"Enable flyspell for the given MODE, if
`spell-checking-enable-by-default' is true."
(when spell-checking-enable-by-default
(let ((mode-hook (intern (format "%S-hook" mode))))
(add-hook mode-hook 'flyspell-mode))))

View File

@ -21,9 +21,9 @@
:defer t :defer t
:init :init
(progn (progn
(add-hook 'markdown-mode-hook 'flyspell-mode) (spacemacs/add-flyspell-hook 'markdown-mode)
(add-hook 'org-mode-hook 'flyspell-mode) (spacemacs/add-flyspell-hook 'org-mode)
(add-hook 'text-mode-hook 'flyspell-mode) (spacemacs/add-flyspell-hook 'text-mode)
(spacemacs|add-toggle spelling-checking (spacemacs|add-toggle spelling-checking
:status flyspell-mode :status flyspell-mode
:on (flyspell-mode) :on (flyspell-mode)
@ -36,7 +36,8 @@
"Sn" 'flyspell-goto-next-error)) "Sn" 'flyspell-goto-next-error))
:config :config
(progn (progn
(flyspell-prog-mode) (when spell-checking-enable-by-default
(flyspell-prog-mode))
(spacemacs|diminish flyspell-mode "" " S")))) (spacemacs|diminish flyspell-mode "" " S"))))
(defun spell-checking/init-helm-flyspell () (defun spell-checking/init-helm-flyspell ()

View File

@ -7,16 +7,14 @@
- [[#install][Install]] - [[#install][Install]]
- [[#layer][Layer]] - [[#layer][Layer]]
- [[#enablingdisabling-tooltips][Enabling/Disabling tooltips]] - [[#enablingdisabling-tooltips][Enabling/Disabling tooltips]]
- [[#disabling-by-default][Disabling by default]]
- [[#key-bindings][Key Bindings]] - [[#key-bindings][Key Bindings]]
* Description * Description
This layer provides on the fly syntax checking using [[http://www.flycheck.org/][Flycheck]]. This layer provides on the fly syntax checking using [[http://www.flycheck.org/][Flycheck]].
* Install * Install
** Layer ** Layer
To use this configuration layer add it to your =~/.spacemacs= To use this configuration layer add it to your =~/.spacemacs=
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
@ -24,7 +22,6 @@ To use this configuration layer add it to your =~/.spacemacs=
#+END_SRC #+END_SRC
** Enabling/Disabling tooltips ** Enabling/Disabling tooltips
By default tooltips are enabled and used whenever it is possible. By default tooltips are enabled and used whenever it is possible.
You can disable them by setting the variable =syntax-checking-enable-tooltips= You can disable them by setting the variable =syntax-checking-enable-tooltips=
to =nil=: to =nil=:
@ -34,6 +31,15 @@ to =nil=:
'((syntax-checking :variables syntax-checking-enable-tooltips nil))) '((syntax-checking :variables syntax-checking-enable-tooltips nil)))
#+END_SRC #+END_SRC
** Disabling by default
By default, syntax-checking is enabled in all available major modes and may be
toggled off with ~SPC t s~. You can default this to off by setting the variable
=syntax-checking-enable-by-default= to =nil=:
#+BEGIN_SRC emacs-lisp
(setq-default dotspacemacs-configuration-layers
'((syntax-checking :variables syntax-checking-enable-by-default nil)))
#+END_SRC
* Key Bindings * Key Bindings

View File

@ -15,5 +15,8 @@
(defvar syntax-checking-enable-tooltips t (defvar syntax-checking-enable-tooltips t
"If non nil some feedback are displayed in tooltips.") "If non nil some feedback are displayed in tooltips.")
(defvar syntax-checking-enable-by-default t
"Enable syntax-checking by default.")
;; Command Prefixes ;; Command Prefixes

View File

@ -0,0 +1,18 @@
;;; funcs.el --- Syntax Checking Layer functions File for Spacemacs
;;
;; Copyright (c) 2012-2014 Sylvain Benner
;; Copyright (c) 2014-2015 Sylvain Benner & Contributors
;;
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
(defun spacemacs/add-flycheck-hook (mode &optional target)
"Enable flycheck for the given MODE, if
`syntax-checking-enable-by-default' is true."
(when syntax-checking-enable-by-default
(let ((mode-hook (intern (format "%S-hook" mode))))
(add-hook mode-hook 'flycheck-mode))))