From 6742695f53c96044f8ae06b6c86d13c0729be685 Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Sat, 28 Nov 2020 08:50:47 +0100 Subject: [PATCH] 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. --- init.el | 3 ++- site-lisp/db-utils.el | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/init.el b/init.el index 1fc4596..32dac21 100644 --- a/init.el +++ b/init.el @@ -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)) diff --git a/site-lisp/db-utils.el b/site-lisp/db-utils.el index 58d6bf2..099c006 100644 --- a/site-lisp/db-utils.el +++ b/site-lisp/db-utils.el @@ -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