unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#32817: 27.0.50; Dotted pair syntax for directory-local variables
@ 2018-09-23 23:14 Juri Linkov
  2018-09-25 12:10 ` Phil Sainty
  0 siblings, 1 reply; 7+ messages in thread
From: Juri Linkov @ 2018-09-23 23:14 UTC (permalink / raw)
  To: 32817

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)





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

end of thread, other threads:[~2018-09-27  6:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-23 23:14 bug#32817: 27.0.50; Dotted pair syntax for directory-local variables Juri Linkov
2018-09-25 12:10 ` 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

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).