unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: 32817@debbugs.gnu.org
Subject: bug#32817: 27.0.50; Dotted pair syntax for directory-local variables
Date: Mon, 24 Sep 2018 02:14:41 +0300	[thread overview]
Message-ID: <87bm8nolge.fsf@mail.linkov.net> (raw)

As indicated in https://lists.gnu.org/archive/html/emacs-devel/2018-09/msg00817.html
the current syntax is confusing.

This patch fixes add-dir-local-variable to output syntax corresponding
to examples in (info "(emacs) Directory Variables"):

diff --git a/lisp/files-x.el b/lisp/files-x.el
index 92532e85f4..8603b6299c 100644
--- a/lisp/files-x.el
+++ b/lisp/files-x.el
@@ -492,15 +492,31 @@ modify-dir-local-variable
       ;; Insert modified alist of directory-local variables.
       (insert ";;; Directory Local Variables\n")
       (insert ";;; For more information see (info \"(emacs) Directory Variables\")\n\n")
-      (pp (sort variables
+      (princ (add-dir-local-variables-to-string
+              (sort variables
 		    (lambda (a b)
 		      (cond
 		       ((null (car a)) t)
 		       ((null (car b)) nil)
 		       ((and (symbolp (car a)) (stringp (car b))) t)
 		       ((and (symbolp (car b)) (stringp (car a))) nil)
-		   (t (string< (car a) (car b))))))
-	  (current-buffer)))))
+		       (t (string< (car a) (car b)))))))
+             (current-buffer))
+      (goto-char (point-min))
+      (indent-sexp))))
+
+(defun add-dir-local-variables-to-string (variables)
+  (format "(%s)" (mapconcat
+                  (lambda (mode-variable)
+                    (format "(%S . %s)"
+                            (car mode-variable)
+                            (format "(%s)" (mapconcat
+                                            (lambda (variable-value)
+                                              (format "(%s . %S)"
+                                                      (car variable-value)
+                                                      (cdr variable-value)))
+                                            (cdr mode-variable) "\n"))))
+                  variables "\n")))
 
 ;;;###autoload
 (defun add-dir-local-variable (mode variable value)





             reply	other threads:[~2018-09-23 23:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-23 23:14 Juri Linkov [this message]
2018-09-25 12:10 ` bug#32817: 27.0.50; Dotted pair syntax for directory-local variables Phil Sainty
2018-09-25 19:41   ` Juri Linkov
2018-09-26 15:01     ` Phil Sainty
2018-09-26 15:50       ` Eli Zaretskii
2018-09-27  0:09         ` Juri Linkov
2018-09-27  6:47           ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bm8nolge.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=32817@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).