lang/emacs-lisp: restore flycheck in elisp buffers

However, with `emacs-lisp-checkdoc` disabled and `emacs-lisp`
significantly gimped.

byte-compile-warnings may need to be adjusted to allow for *some*
warnings.

Also, reformat emacs-lisp-mode hooks
This commit is contained in:
Henrik Lissner 2019-05-02 20:42:43 -04:00
parent ee7ff68ae4
commit 25beb4bcfd
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 24 additions and 7 deletions

View file

@ -122,12 +122,27 @@ if it's callable, `apropos' otherwise."
("Types" "^\\s-*(\\(cl-def\\(?:struct\\|type\\)\\|def\\(?:class\\|face\\|group\\|ine-\\(?:condition\\|error\\|widget\\)\\|package\\|struct\\|t\\(?:\\(?:hem\\|yp\\)e\\)\\)\\)\\s-+'?\\(\\(?:\\sw\\|\\s_\\|\\\\.\\)+\\)" 2)))) ("Types" "^\\s-*(\\(cl-def\\(?:struct\\|type\\)\\|def\\(?:class\\|face\\|group\\|ine-\\(?:condition\\|error\\|widget\\)\\|package\\|struct\\|t\\(?:\\(?:hem\\|yp\\)e\\)\\)\\)\\s-+'?\\(\\(?:\\sw\\|\\s_\\|\\\\.\\)+\\)" 2))))
;;;###autoload ;;;###autoload
(defun +emacs-lisp|disable-flycheck-maybe () (defun +emacs-lisp|reduce-flycheck-errors-in-emacs-config ()
"Disable flycheck-mode if in emacs.d." "Remove `emacs-lisp-checkdoc' checker and reduce `emacs-lisp' checker
verbosity when editing a file in `doom-private-dir' or `doom-emacs-dir'."
(when (and (bound-and-true-p flycheck-mode) (when (and (bound-and-true-p flycheck-mode)
(eq major-mode 'emacs-lisp-mode) (eq major-mode 'emacs-lisp-mode)
(or (not buffer-file-name) (or (not buffer-file-name)
(cl-loop for dir in (list doom-emacs-dir doom-private-dir) (cl-loop for dir in (list doom-emacs-dir doom-private-dir)
if (file-in-directory-p buffer-file-name dir) if (file-in-directory-p buffer-file-name dir)
return t))) return t)))
(flycheck-mode -1))) (add-to-list (make-local-variable 'flycheck-disabled-checkers)
'emacs-lisp-checkdoc)
(set (make-local-variable 'flycheck-emacs-lisp-check-form)
(concat "(progn "
(prin1-to-string
`(progn
(load ,user-init-file t t)
(defmacro map! (&rest _))
(setq byte-compile-warnings
'(obsolete cl-functions
interactive-only make-local mapcar
suspicious constants))))
" "
(default-value 'flycheck-emacs-lisp-check-form)
")"))))

View file

@ -48,12 +48,16 @@ This marks a foldable marker for `outline-minor-mode' in elisp buffers.")
#'(;; 3rd-party functionality #'(;; 3rd-party functionality
auto-compile-on-save-mode auto-compile-on-save-mode
outline-minor-mode outline-minor-mode
;; fontificiation
rainbow-delimiters-mode
highlight-quoted-mode
;; initialization ;; initialization
+emacs-lisp|extend-imenu)) +emacs-lisp|extend-imenu))
;; Flycheck's two emacs-lisp checkers produce a *lot* of false positives in ;; Flycheck's two emacs-lisp checkers produce a *lot* of false positives in
;; emacs configs, so disable it when you're editing them ;; emacs configs, so we disable `emacs-lisp-checkdoc' and reduce the
(add-hook 'flycheck-mode-hook #'+emacs-lisp|disable-flycheck-maybe) ;; `emacs-lisp' checker's verbosity.
(add-hook 'flycheck-mode-hook #'+emacs-lisp|reduce-flycheck-errors-in-emacs-config)
;; Special fontification for elisp ;; Special fontification for elisp
(font-lock-add-keywords (font-lock-add-keywords
@ -64,8 +68,6 @@ This marks a foldable marker for `outline-minor-mode' in elisp buffers.")
(when +emacs-lisp-enable-extra-fontification (when +emacs-lisp-enable-extra-fontification
`((+emacs-lisp-highlight-vars-and-faces . +emacs-lisp--face))))) `((+emacs-lisp-highlight-vars-and-faces . +emacs-lisp--face)))))
(add-hook! 'emacs-lisp-mode-hook #'(rainbow-delimiters-mode highlight-quoted-mode))
;; Recenter window after following definition ;; Recenter window after following definition
(advice-add #'elisp-def :after #'doom*recenter) (advice-add #'elisp-def :after #'doom*recenter)