]> git.eshelyaron.com Git - emacs.git/commitdiff
Avoid false indications from Flymake in .dir-locals.el files
authorEli Zaretskii <eliz@gnu.org>
Mon, 21 Oct 2019 11:29:13 +0000 (14:29 +0300)
committerEli Zaretskii <eliz@gnu.org>
Mon, 21 Oct 2019 11:29:13 +0000 (14:29 +0300)
* 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 <cpitclaudel@gmail.com>.

lisp/progmodes/elisp-mode.el

index 516e4f9cd63689244ad8c135ca506c95b3b2e616..7705761365ce9f6060d77d7ea9127b3525d4232f 100644 (file)
@@ -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.