emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 19ab768: Output alists with dotted pair notation in


From: Juri Linkov
Subject: [Emacs-diffs] master 19ab768: Output alists with dotted pair notation in .dir-locals.el
Date: Mon, 24 Sep 2018 16:53:04 -0400 (EDT)

branch: master
commit 19ab7686ae42dcce1e0861bce4713c69a64eec45
Author: Juri Linkov <address@hidden>
Commit: Juri Linkov <address@hidden>

    Output alists with dotted pair notation in .dir-locals.el
    
    * lisp/files-x.el (add-dir-local-variables-to-string): New function.
    (modify-dir-local-variable): Use it.  (Bug#32817)
---
 lisp/files-x.el | 35 ++++++++++++++++++++++++++---------
 1 file changed, 26 insertions(+), 9 deletions(-)

diff --git a/lisp/files-x.el b/lisp/files-x.el
index 92532e8..201b7a4 100644
--- a/lisp/files-x.el
+++ b/lisp/files-x.el
@@ -492,15 +492,32 @@ from the MODE alist ignoring the input argument VALUE."
       ;; 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
-               (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)))))
+      (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))
+      (goto-char (point-min))
+      (indent-sexp))))
+
+(defun add-dir-local-variables-to-string (variables)
+  "Output alists of VARIABLES to string in dotted pair notation syntax."
+  (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 via email to

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