aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2018-09-24 23:52:57 +0300
committerJuri Linkov2018-09-24 23:52:57 +0300
commit19ab7686ae42dcce1e0861bce4713c69a64eec45 (patch)
treea5f17a4171ecbc140f215d9d3e4f723caa73b48a
parent36243179695a1711308e1d2f57c9ff847f3ef2d0 (diff)
downloademacs-19ab7686ae42dcce1e0861bce4713c69a64eec45.tar.gz
emacs-19ab7686ae42dcce1e0861bce4713c69a64eec45.zip
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)
-rw-r--r--lisp/files-x.el35
1 files 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."
492 ;; Insert modified alist of directory-local variables. 492 ;; Insert modified alist of directory-local variables.
493 (insert ";;; Directory Local Variables\n") 493 (insert ";;; Directory Local Variables\n")
494 (insert ";;; For more information see (info \"(emacs) Directory Variables\")\n\n") 494 (insert ";;; For more information see (info \"(emacs) Directory Variables\")\n\n")
495 (pp (sort variables 495 (princ (add-dir-local-variables-to-string
496 (lambda (a b) 496 (sort variables
497 (cond 497 (lambda (a b)
498 ((null (car a)) t) 498 (cond
499 ((null (car b)) nil) 499 ((null (car a)) t)
500 ((and (symbolp (car a)) (stringp (car b))) t) 500 ((null (car b)) nil)
501 ((and (symbolp (car b)) (stringp (car a))) nil) 501 ((and (symbolp (car a)) (stringp (car b))) t)
502 (t (string< (car a) (car b)))))) 502 ((and (symbolp (car b)) (stringp (car a))) nil)
503 (current-buffer))))) 503 (t (string< (car a) (car b)))))))
504 (current-buffer))
505 (goto-char (point-min))
506 (indent-sexp))))
507
508(defun add-dir-local-variables-to-string (variables)
509 "Output alists of VARIABLES to string in dotted pair notation syntax."
510 (format "(%s)" (mapconcat
511 (lambda (mode-variable)
512 (format "(%S . %s)"
513 (car mode-variable)
514 (format "(%s)" (mapconcat
515 (lambda (variable-value)
516 (format "(%s . %S)"
517 (car variable-value)
518 (cdr variable-value)))
519 (cdr mode-variable) "\n"))))
520 variables "\n")))
504 521
505;;;###autoload 522;;;###autoload
506(defun add-dir-local-variable (mode variable value) 523(defun add-dir-local-variable (mode variable value)