diff options
author | Juri Linkov <juri@linkov.net> | 2018-09-24 23:52:57 +0300 |
---|---|---|
committer | Juri Linkov <juri@linkov.net> | 2018-09-24 23:52:57 +0300 |
commit | 19ab7686ae42dcce1e0861bce4713c69a64eec45 (patch) | |
tree | a5f17a4171ecbc140f215d9d3e4f723caa73b48a /lisp/files-x.el | |
parent | 36243179695a1711308e1d2f57c9ff847f3ef2d0 (diff) | |
download | emacs-19ab7686ae42dcce1e0861bce4713c69a64eec45.tar.gz |
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)
Diffstat (limited to 'lisp/files-x.el')
-rw-r--r-- | lisp/files-x.el | 35 |
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." ;; 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) |