Enable flycheck mode in Emacs Lisp only when buffer has a file

Flycheck used to be activated unconditionally, resulting in annoying warnings
when evaluating Lisp expressions in the minibuffer with `pp-eval-expression`,
and in the scratch buffer.
This commit is contained in:
Daniel - 2020-11-28 08:50:47 +01:00
parent 9e84ba5251
commit 6742695f53
No known key found for this signature in database
GPG Key ID: 1C7071A75BB72D64
2 changed files with 7 additions and 1 deletions

View File

@ -593,6 +593,7 @@
db/text-to-hex
conditionally-enable-lispy
turn-on-lispy-when-available
turn-on-flycheck-when-file
db/sort-nsm-permanent-settings
endless/colorize-compilation
db/turn-off-local-electric-pair-mode
@ -2587,7 +2588,7 @@ With given ARG, display files in `db/important-document-path."
(use-package elisp-mode
:config (progn
(add-hook 'emacs-lisp-mode-hook 'turn-on-lispy-when-available)
(add-hook 'emacs-lisp-mode-hook 'flycheck-mode)))
(add-hook 'emacs-lisp-mode-hook 'turn-on-flycheck-when-file)))
(use-package geiser
:commands (geiser-mode))

View File

@ -257,6 +257,11 @@ Will print a warning in case of failure."
(require 'lispy)
(lispy-mode)))
(defun turn-on-flycheck-when-file ()
"Turn on `flycheck-mode' when buffer is associated with a file."
(when buffer-file-name
(flycheck-mode +1)))
(defun db/sort-nsm-permanent-settings ()
"Sort values in `nsm-permanent-host-settings."
(setq nsm-permanent-host-settings