[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Add a separate mode for .dir-locals.el

From: Stefan Monnier
Subject: Re: Add a separate mode for .dir-locals.el
Date: Thu, 17 Oct 2019 12:37:56 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

>>> A better option would be to have a base `lisp-prog-mode` and hen
>>> derive emacs-lisp-mode from it.
>> Exactly.  dir-locals-mode should share a parent with emacs-lisp-mode.
> Yes.  Is this very hard to do?

No, it should be straightforward.
Se sample patch below.


diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index 516e4f9cd63..da275bcae60 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -231,8 +231,16 @@ emacs-lisp-set-electric-text-pairs
           (setq-local electric-pair-text-pairs elisp-pairs)))))
   (remove-hook 'electric-pair-mode-hook #'emacs-lisp-set-electric-text-pairs))
+(define-derived-mode emacs-lisp-data-mode prog-mode "Emacs-Lisp-Data"
+  "Major mode for buffers holding data written in Emacs Lisp syntax."
+  :group 'lisp
+  (lisp-mode-variables nil nil 'elisp)
+  (setq-local electric-quote-string t)
+  (setq imenu-case-fold-search nil))
-(define-derived-mode emacs-lisp-mode prog-mode "Emacs-Lisp"
+(define-derived-mode emacs-lisp-mode emacs-lisp-data-mode "Emacs-Lisp"
   "Major mode for editing Lisp code to run in Emacs.
 Delete converts tabs to spaces as it moves back.
@@ -241,15 +249,12 @@ emacs-lisp-mode
   :group 'lisp
   (defvar project-vc-external-roots-function)
-  (lisp-mode-variables nil nil 'elisp)
   (add-hook 'after-load-functions #'elisp--font-lock-flush-elisp-buffers)
   (if (boundp 'electric-pair-text-pairs)
       (setq-local electric-pair-text-pairs
                   (append '((?\` . ?\') (?‘ . ?’))
     (add-hook 'electric-pair-mode-hook #'emacs-lisp-set-electric-text-pairs))
-  (setq-local electric-quote-string t)
-  (setq imenu-case-fold-search nil)
   (add-function :before-until (local 'eldoc-documentation-function)
   (add-hook 'xref-backend-functions #'elisp--xref-backend nil t)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]