]> git.eshelyaron.com Git - emacs.git/commitdiff
Don't have savehist-save bug out on non-existing directory
authorLars Ingebrigtsen <larsi@gnus.org>
Sat, 13 Jul 2019 15:13:12 +0000 (17:13 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Sat, 13 Jul 2019 15:13:12 +0000 (17:13 +0200)
* lisp/savehist.el (savehist-save): Ensure that the directory
exists before saving (bug#31348).

lisp/savehist.el

index 7e6ccd91c72158a38df404fb09362ba6edee6ae8..83591310829971e406c78d8866de1a409cdd1a0d 100644 (file)
@@ -299,7 +299,11 @@ If AUTO-SAVE is non-nil, compare the saved contents to the one last saved,
        ;; kill-emacs-hook, and also that multiple Emacs instances
        ;; could write to this file at once.
        (let ((file-precious-flag t)
-             (coding-system-for-write savehist-coding-system))
+             (coding-system-for-write savehist-coding-system)
+              (dir (file-name-directory savehist-file)))
+          ;; Ensure that the directory exists before saving.
+          (unless (file-exists-p dir)
+            (make-directory dir t))
          (write-region (point-min) (point-max) savehist-file nil
                        (unless (called-interactively-p 'interactive) 'quiet)))
        (when savehist-file-modes