1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

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)
This commit is contained in:
Juri Linkov 2018-09-24 23:52:57 +03:00
parent 3624317969
commit 19ab7686ae

View file

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