[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#32817: 27.0.50; Dotted pair syntax for directory-local variables
From: |
Juri Linkov |
Subject: |
bug#32817: 27.0.50; Dotted pair syntax for directory-local variables |
Date: |
Mon, 24 Sep 2018 02:14:41 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) |
As indicated in
https://lists.gnu.org/archive/html/emacs-devel/2018-09/msg00817.html
the current syntax is confusing.
This patch fixes add-dir-local-variable to output syntax corresponding
to examples in (info "(emacs) Directory Variables"):
diff --git a/lisp/files-x.el b/lisp/files-x.el
index 92532e85f4..8603b6299c 100644
--- a/lisp/files-x.el
+++ b/lisp/files-x.el
@@ -492,15 +492,31 @@ modify-dir-local-variable
;; 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
+ (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)))))
+ (t (string< (car a) (car b)))))))
+ (current-buffer))
+ (goto-char (point-min))
+ (indent-sexp))))
+
+(defun add-dir-local-variables-to-string (variables)
+ (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)
- bug#32817: 27.0.50; Dotted pair syntax for directory-local variables,
Juri Linkov <=