]> git.eshelyaron.com Git - emacs.git/commitdiff
Don't accumulate trailing newlines on every save of .dir-locals.el
authorJuri Linkov <juri@linkov.net>
Thu, 7 Jul 2022 06:31:02 +0000 (09:31 +0300)
committerJuri Linkov <juri@linkov.net>
Thu, 7 Jul 2022 06:31:02 +0000 (09:31 +0300)
* lisp/files-x.el (modify-dir-local-variable): Insert a newline
only after creating a new file.
(dir-locals-to-string): Remove newline to not add more newlines
on every save.

lisp/files-x.el

index a89fc26d60b3341f9aa76a6c766c0be8dd614141..8224a574507a920b2b393967e0f5f51129602ece 100644 (file)
@@ -502,12 +502,13 @@ from the MODE alist ignoring the input argument VALUE."
                       ((and (symbolp (car b)) (stringp (car a))) nil)
                       (t (string< (car a) (car b)))))))
              (current-buffer))
+      (when (eobp) (insert "\n"))
       (goto-char (point-min))
       (indent-sexp))))
 
 (defun dir-locals-to-string (variables)
   "Output alists of VARIABLES to string in dotted pair notation syntax."
-  (format "(%s)\n"
+  (format "(%s)"
           (mapconcat
            (lambda (mode-variables)
              (format "(%S . %s)"