From 19ab7686ae42dcce1e0861bce4713c69a64eec45 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Mon, 24 Sep 2018 23:52:57 +0300 Subject: [PATCH] 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 92532e85f4f..201b7a47d5d 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) -- 2.11.4.GIT