unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Add a separate mode for .dir-locals.el
@ 2019-10-17  2:07 Clément Pit-Claudel
  2019-10-17  2:20 ` Lars Ingebrigtsen
  2019-10-17  8:55 ` Andreas Schwab
  0 siblings, 2 replies; 98+ messages in thread
From: Clément Pit-Claudel @ 2019-10-17  2:07 UTC (permalink / raw)
  To: Emacs developers

[-- Attachment #1: Type: text/plain, Size: 521 bytes --]

Hi all,

.dir-locals.el files are currently opened in emacs-lisp-mode, but they are not proper Emacs Lisp files; as a result, Flymake generates incorrect diagnostics, and I don't know of an easy way to customize Emacs specifically for these files (there's is no hook that runs every time a dir-locals file is opened).  We've had a similar problem for a while in Flycheck.

The attached patch creates a trivial dir-locals-mode, derived from emacs-lisp-mode, and removes Flymake backends in that mode.

Thoughts?
Clément.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-a-separate-mode-for-.dir-locals.el-files.patch --]
[-- Type: text/x-patch; name="0001-Add-a-separate-mode-for-.dir-locals.el-files.patch", Size: 1809 bytes --]

From 9fec681101f27ec578cd25fa11fc737641b8dd91 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Pit-Claudel?= <clement.pitclaudel@live.com>
Date: Wed, 16 Oct 2019 22:02:49 -0400
Subject: [PATCH] Add a separate mode for .dir-locals.el files

* lisp/progmodes/elisp-mode.el (dir-locals-mode): New mode; disable
  Flymake in it
* lisp/files.el (auto-mode-alist): Use it to open .dir-locals.el
---
 lisp/files.el                | 1 +
 lisp/progmodes/elisp-mode.el | 8 ++++++++
 2 files changed, 9 insertions(+)

diff --git a/lisp/files.el b/lisp/files.el
index 4b364b49d8..2f6d63ba1e 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -2657,6 +2657,7 @@ auto-mode-alist
      ("\\.ltx\\'" . latex-mode)
      ("\\.dtx\\'" . doctex-mode)
      ("\\.org\\'" . org-mode)
+     ("\\`\\.dir-locals\\(?:-2\\)?.el\\'" . dir-locals-mode)
      ("\\.el\\'" . emacs-lisp-mode)
      ("Project\\.ede\\'" . emacs-lisp-mode)
      ("\\.\\(scm\\|stk\\|ss\\|sch\\)\\'" . scheme-mode)
diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index 516e4f9cd6..fb704c7de0 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -259,6 +259,14 @@ emacs-lisp-mode
   (add-hook 'flymake-diagnostic-functions #'elisp-flymake-checkdoc nil t)
   (add-hook 'flymake-diagnostic-functions #'elisp-flymake-byte-compile nil t))
 
+;;;###autoload
+(define-derived-mode dir-locals-mode emacs-lisp-mode "Directory locals"
+  "Major mode to edit .dir-locals.el files.
+
+\\{dir-locals-mode-map}"
+  (remove-hook 'flymake-diagnostic-functions #'elisp-flymake-checkdoc t)
+  (remove-hook 'flymake-diagnostic-functions #'elisp-flymake-byte-compile t))
+
 ;; Font-locking support.
 
 (defun elisp--font-lock-flush-elisp-buffers (&optional file)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 98+ messages in thread

end of thread, other threads:[~2019-10-21 13:48 UTC | newest]

Thread overview: 98+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-17  2:07 Add a separate mode for .dir-locals.el Clément Pit-Claudel
2019-10-17  2:20 ` Lars Ingebrigtsen
2019-10-17  7:53   ` Eli Zaretskii
2019-10-17 11:51     ` Clément Pit-Claudel
2019-10-17 12:21       ` João Távora
2019-10-17 13:16         ` Eli Zaretskii
2019-10-17 13:51           ` Clément Pit-Claudel
2019-10-17 15:45             ` Yuri Khan
2019-10-17 15:47               ` Clément Pit-Claudel
2019-10-17 16:55                 ` Amin Bandali
2019-10-17 14:00           ` João Távora
2019-10-17 15:12             ` Dmitry Gutov
2019-10-17 15:32             ` Stefan Monnier
2019-10-17 15:41               ` João Távora
2019-10-17 15:47                 ` Clément Pit-Claudel
2019-10-17 16:37                 ` Stefan Monnier
2019-10-17 17:04                   ` João Távora
2019-10-17 17:35                     ` Eli Zaretskii
2019-10-17 17:42                       ` João Távora
2019-10-17 17:52                         ` Eli Zaretskii
2019-10-17 18:09                           ` João Távora
2019-10-17 18:28                             ` Eli Zaretskii
2019-10-17 19:00                               ` João Távora
2019-10-17 19:21                                 ` Eli Zaretskii
2019-10-17 19:53                                   ` Stefan Monnier
2019-10-18  7:39                                     ` Eli Zaretskii
2019-10-18 12:56                                       ` Stefan Monnier
2019-10-17 21:35                                   ` João Távora
2019-10-18  8:00                                     ` Eli Zaretskii
2019-10-18  8:38                                       ` Juanma Barranquero
2019-10-18 13:14                                         ` Stefan Monnier
2019-10-18 10:25                                       ` João Távora
2019-10-18 12:33                                         ` Eli Zaretskii
2019-10-18 13:43                                           ` João Távora
2019-10-18 14:07                                             ` Dmitry Gutov
2019-10-19  9:52                                             ` Eli Zaretskii
2019-10-19 11:00                                               ` João Távora
2019-10-19 11:08                                                 ` João Távora
2019-10-19 11:56                                                 ` Eli Zaretskii
2019-10-19 12:55                                                   ` Clément Pit-Claudel
2019-10-19 13:36                                                   ` João Távora
2019-10-19 14:03                                                     ` Eli Zaretskii
2019-10-19 16:13                                                       ` João Távora
2019-10-19 12:53                                               ` Clément Pit-Claudel
2019-10-19 14:14                                                 ` Eli Zaretskii
2019-10-19 16:51                                                   ` Clément Pit-Claudel
2019-10-19 20:41                                                   ` Dmitry Gutov
2019-10-19 21:35                                                     ` Alan Mackenzie
2019-10-19 22:01                                                       ` Dmitry Gutov
2019-10-20  5:45                                                     ` Eli Zaretskii
2019-10-20  8:17                                                       ` João Távora
2019-10-20 15:40                                                         ` Juri Linkov
2019-10-20 19:29                                                           ` João Távora
2019-10-21 12:43                                                       ` Dmitry Gutov
2019-10-21 13:15                                                         ` Eli Zaretskii
2019-10-21 13:34                                                           ` Dmitry Gutov
2019-10-21 13:41                                                             ` João Távora
2019-10-21 13:48                                                             ` Eli Zaretskii
2019-10-19 20:38                                                 ` Dmitry Gutov
2019-10-20  5:38                                                   ` Eli Zaretskii
2019-10-20 20:21                                                     ` Dmitry Gutov
2019-10-21  6:24                                                       ` Eli Zaretskii
2019-10-21  7:05                                                         ` João Távora
2019-10-21  7:15                                                           ` Eli Zaretskii
2019-10-21  8:25                                                             ` João Távora
2019-10-21 10:09                                                               ` Eli Zaretskii
2019-10-21 10:28                                                                 ` João Távora
2019-10-21 10:59                                                                   ` Eli Zaretskii
2019-10-21 11:22                                                                     ` João Távora
2019-10-21 11:32                                                                       ` Eli Zaretskii
2019-10-21 11:39                                                                         ` João Távora
2019-10-21 12:26                                                         ` Dmitry Gutov
2019-10-17 19:50                               ` Stefan Monnier
2019-10-17 19:59                                 ` Eli Zaretskii
2019-10-17 20:32                                   ` Stefan Monnier
2019-10-18  7:34                                     ` Michael Albinus
2019-10-18  7:52                                     ` Eli Zaretskii
2019-10-18 13:11                                       ` Stefan Monnier
2019-10-19 10:00                                         ` Eli Zaretskii
2019-10-19 14:05                                           ` Stefan Monnier
2019-10-17 16:36               ` Eli Zaretskii
2019-10-17 17:47                 ` Alan Mackenzie
2019-10-17 18:08                   ` Stefan Monnier
2019-10-17 19:46                     ` Alan Mackenzie
2019-10-17 20:19                       ` Stefan Monnier
2019-10-17 18:19                   ` João Távora
2019-10-17 19:38                     ` Alan Mackenzie
     [not found]           ` <CALDnm50Q+QuhYRqZxV4-YzAAqhmU05+nOS3Oh1wvcJsYEX+sbg@mail.gmail.com>
2019-10-17 14:12             ` Eli Zaretskii
2019-10-17 15:31               ` João Távora
2019-10-17  8:55 ` Andreas Schwab
2019-10-17 11:48   ` Clément Pit-Claudel
2019-10-17 12:03     ` Andreas Schwab
2019-10-17 12:10       ` Clément Pit-Claudel
2019-10-18  3:14       ` Richard Stallman
2019-10-17 13:40   ` Stefan Monnier
2019-10-19 12:28     ` Why we SHOULDN'T add " Alan Mackenzie
2019-10-19 12:59       ` Clément Pit-Claudel
2019-10-19 22:04       ` Dmitry Gutov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).