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