all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#37878: [PATCH] Add auto-insert skeleton for ".dir-locals.el"
@ 2019-10-22 23:04 Stefan Kangas
  2019-10-23 21:19 ` Juri Linkov
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Kangas @ 2019-10-22 23:04 UTC (permalink / raw)
  To: 37878

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

Steps to reproduce:
0. emacs -Q
1. M-x auto-insert-mode
2. C-x C-f .dir-locals.el RET

Result: The entire Emacs standard header gets inserted into the
buffer, complete with author, copyright notice, provide-statement,
etc.
Expected result: Either don't insert anything or use a custom skeleton.

Please find attached a proposed patch, which adds a skeleton for
"dir-locals.el" to auto-insert-alist.  I believe it would make it
easier for especially beginning Emacs users to use ".dir-locals.el".
(Open the file, type M-x auto-insert, and voilá.)

Any comments?

Best regards,
Stefan Kangas

[-- Attachment #2: 0001-Add-auto-insert-skeleton-for-.dir-locals.el.patch --]
[-- Type: application/octet-stream, Size: 2080 bytes --]

From 2606dfc64c4a02edd6dee34aaa5a2db0d2e8713e Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefankangas@gmail.com>
Date: Wed, 23 Oct 2019 00:53:25 +0200
Subject: [PATCH] Add auto-insert skeleton for ".dir-locals.el"

* lisp/autoinsert.el (auto-insert-alist): Add auto-insert skeleton for
".dir-locals.el".
---
 lisp/autoinsert.el | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/lisp/autoinsert.el b/lisp/autoinsert.el
index b8c2bfd606..f2ac907153 100644
--- a/lisp/autoinsert.el
+++ b/lisp/autoinsert.el
@@ -162,6 +162,29 @@ auto-insert-alist
 	  (replace-match (capitalize (user-login-name)) t t))
      '(end-of-line 1) " <" (progn user-mail-address) ">\n")
 
+    (".dir-locals.el"
+     nil
+     ";;; Directory Local Variables\n"
+     ";;; For more information see (info \"(emacs) Directory Variables\")\n\n"
+     "(("
+     '(setq v1 (let (modes)
+                 (mapatoms (lambda (mode)
+                             (let ((name (symbol-name mode)))
+                               (when (string-match "-mode$" name)
+                                 (add-to-list 'modes name)))))
+                 (sort modes 'string<)))
+     (completing-read "Local variables for mode: " v1 nil t)
+     " . (("
+     (let ((all-variables
+            (apropos-internal ".*"
+                              (lambda (symbol)
+			        (and (boundp symbol)
+				     (get symbol 'variable-documentation))))))
+       (completing-read "Variable to set: " all-variables))
+     " . "
+     (completing-read "Value to set it to: " nil)
+     "))))\n")
+
     (("\\.el\\'" . "Emacs Lisp header")
      "Short description: "
      ";;; " (file-name-nondirectory (buffer-file-name)) " --- " str
@@ -315,7 +338,7 @@ auto-insert-alist
                 ;; There's no custom equivalent of "repeat" for vectors.
                 :value-type (choice file function
                                     (sexp :tag "Skeleton or vector")))
-  :version "25.1")
+  :version "27.1")
 
 
 ;; Establish a default value for auto-insert-directory
-- 
2.23.0


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

end of thread, other threads:[~2019-11-02  3:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-22 23:04 bug#37878: [PATCH] Add auto-insert skeleton for ".dir-locals.el" Stefan Kangas
2019-10-23 21:19 ` Juri Linkov
2019-11-02  3:30   ` Stefan Kangas

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.