unofficial mirror of bug-gnu-emacs@gnu.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

* bug#37878: [PATCH] Add auto-insert skeleton for ".dir-locals.el"
  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
  0 siblings, 1 reply; 3+ messages in thread
From: Juri Linkov @ 2019-10-23 21:19 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 37878

> 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?

Good addition for someone who doesn't use add-dir-local-variable
that inserts this header.

BTW, please also add the same two lines to the header of
.dir-locals.el in Emacs repository.





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

* bug#37878: [PATCH] Add auto-insert skeleton for ".dir-locals.el"
  2019-10-23 21:19 ` Juri Linkov
@ 2019-11-02  3:30   ` Stefan Kangas
  0 siblings, 0 replies; 3+ messages in thread
From: Stefan Kangas @ 2019-11-02  3:30 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 37878

close 37878 27.1
thanks

Juri Linkov <juri@linkov.net> writes:

>> 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?
>
> Good addition for someone who doesn't use add-dir-local-variable
> that inserts this header.

Thanks for the review.  Now pushed to master as commit 6c82aafcc0.

> BTW, please also add the same two lines to the header of
> .dir-locals.el in Emacs repository.

Good idea.  I did that in commit 7cde03484.

Best regards,
Stefan Kangas





^ permalink raw reply	[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 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).