From 61fb5214816ef3d57e676d900e499ffcd079a1f9 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Mon, 21 Oct 2019 14:29:13 +0300 Subject: [PATCH] Avoid false indications from Flymake in .dir-locals.el files MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * lisp/progmodes/elisp-mode.el (emacs-lisp-mode): Don't install 'elisp-flymake-checkdoc' and 'elisp-flymake-byte-compile' hooks for .dir-locals.el files. Reported by Clément Pit-Claudel . --- lisp/progmodes/elisp-mode.el | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index 516e4f9cd63..7705761365c 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -256,8 +256,20 @@ Blank lines separate paragraphs. Semicolons start comments. (setq-local project-vc-external-roots-function #'elisp-load-path-roots) (add-hook 'completion-at-point-functions #'elisp-completion-at-point nil 'local) - (add-hook 'flymake-diagnostic-functions #'elisp-flymake-checkdoc nil t) - (add-hook 'flymake-diagnostic-functions #'elisp-flymake-byte-compile nil t)) + ;; .dir-locals.el and lock files will cause the byte-compiler and + ;; checkdoc emit spurious warnings, because they don't follow the + ;; conventions of Emacs Lisp sources. Until we have a better fix, + ;; like teaching elisp-mode about files that only hold data + ;; structures, we disable the ELisp Flymake backend for these files. + (unless + (let* ((bfname (buffer-file-name)) + (fname (and (stringp bfname) (file-name-nondirectory bfname)))) + (or (not (stringp fname)) + (string-match "\\`\\.#" fname) + (string-equal dir-locals-file fname))) + (add-hook 'flymake-diagnostic-functions #'elisp-flymake-checkdoc nil t) + (add-hook 'flymake-diagnostic-functions + #'elisp-flymake-byte-compile nil t))) ;; Font-locking support. -- 2.39.2