Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[emacs-lisp] Only call flycheck setup once #16826

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions layers/+lang/emacs-lisp/funcs.el
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,19 @@ Intended for use in mode hooks."
(let ((cbuf (current-buffer)))
(ert '(satisfies (lambda (test)
(eq cbuf (spacemacs//find-ert-test-buffer test)))))))


;; setup flycheck, but not for `lisp-interaction-mode'
;;
;; `lisp-interaction-mode' is commonly used as the major-mode for the *scratch*
;; buffer created upon startup, but the flycheck-package and flycheck-elsa
;; linters are meaningless in such a buffer. In fact, they are meaningless for
;; non-file-backed buffers, so just check that.

(defun emacs-lisp//flycheck-package-setup ()
(when buffer-file-name
(flycheck-package-setup)))

(defun emacs-lisp//flycheck-elsa-setup ()
(when buffer-file-name
(flycheck-elsa-setup)))
10 changes: 8 additions & 2 deletions layers/+lang/emacs-lisp/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -312,11 +312,17 @@

(defun emacs-lisp/init-flycheck-package ()
(use-package flycheck-package
:hook (emacs-lisp-mode . flycheck-package-setup)))
:defer t
:init
(spacemacs|add-transient-hook emacs-lisp-mode-hook
emacs-lisp//flycheck-package-setup)))

(defun emacs-lisp/init-flycheck-elsa ()
(use-package flycheck-elsa
:hook (emacs-lisp-mode . flycheck-elsa-setup)))
:defer t
:init
(spacemacs|add-transient-hook emacs-lisp-mode-hook
emacs-lisp//flycheck-elsa-setup)))

(defun emacs-lisp/post-init-ggtags ()
(add-hook 'emacs-lisp-mode-local-vars-hook #'spacemacs/ggtags-mode-enable))
Expand Down