diff options
| author | Lars Ingebrigtsen | 2019-07-13 17:13:12 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2019-07-13 17:13:12 +0200 |
| commit | e6b40fe511f86524c0e1aa84abc9aef1cab5d706 (patch) | |
| tree | d01c82ce0a8a40971d8869ac24523a207e3f7ec7 | |
| parent | 82e799f71d454367e71782df1e4b0440681334cb (diff) | |
| download | emacs-e6b40fe511f86524c0e1aa84abc9aef1cab5d706.tar.gz emacs-e6b40fe511f86524c0e1aa84abc9aef1cab5d706.zip | |
Don't have savehist-save bug out on non-existing directory
* lisp/savehist.el (savehist-save): Ensure that the directory
exists before saving (bug#31348).
| -rw-r--r-- | lisp/savehist.el | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lisp/savehist.el b/lisp/savehist.el index 7e6ccd91c72..83591310829 100644 --- a/lisp/savehist.el +++ b/lisp/savehist.el | |||
| @@ -299,7 +299,11 @@ If AUTO-SAVE is non-nil, compare the saved contents to the one last saved, | |||
| 299 | ;; kill-emacs-hook, and also that multiple Emacs instances | 299 | ;; kill-emacs-hook, and also that multiple Emacs instances |
| 300 | ;; could write to this file at once. | 300 | ;; could write to this file at once. |
| 301 | (let ((file-precious-flag t) | 301 | (let ((file-precious-flag t) |
| 302 | (coding-system-for-write savehist-coding-system)) | 302 | (coding-system-for-write savehist-coding-system) |
| 303 | (dir (file-name-directory savehist-file))) | ||
| 304 | ;; Ensure that the directory exists before saving. | ||
| 305 | (unless (file-exists-p dir) | ||
| 306 | (make-directory dir t)) | ||
| 303 | (write-region (point-min) (point-max) savehist-file nil | 307 | (write-region (point-min) (point-max) savehist-file nil |
| 304 | (unless (called-interactively-p 'interactive) 'quiet))) | 308 | (unless (called-interactively-p 'interactive) 'quiet))) |
| 305 | (when savehist-file-modes | 309 | (when savehist-file-modes |