aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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)