From 87d03bef9433a7ff5fbceb709df36b49818f6f58 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Sat, 30 Mar 2019 12:06:56 -0700 Subject: [PATCH] Ensure the auto-save directory exists The auto-save functions don't automatically create it. --- oni-core.el | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/oni-core.el b/oni-core.el index 5b3af65..488d512 100644 --- a/oni-core.el +++ b/oni-core.el @@ -4,7 +4,7 @@ ;; Author: Tom Willemse ;; Keywords: local -;; Version: 20190304234446 +;; Version: 20190330120416 ;; Package-Requires: (oni-data-dir expand-region multiple-cursors embrace) ;; This program is free software; you can redistribute it and/or modify @@ -29,6 +29,9 @@ (require 'oni-data-dir) +(defconst oni-core--auto-save-directory (oni-data-dir-locate "auto-save-files/") + "Directory where auto-saves go.") + (defalias 'yes-or-no-p 'y-or-n-p) (defun oni-core--destroy-trailing-whitespace () @@ -44,9 +47,14 @@ (local-set-key (kbd "RET") 'electric-newline-and-maybe-indent)) (local-unset-key (kbd "C-j")) (local-unset-key (kbd "RET")))) + +(defun oni-core--ensure-autosave-directory-exists () + "Create the autosave directory if doesn't exist." + (mkdir oni-core--auto-save-directory t)) + (add-to-list 'auto-save-file-name-transforms - `(".*" ,(oni-data-dir-locate "auto-save-files/") t) - :append) + `(".*" ,oni-core--auto-save-directory t) + :append) (setq backup-directory-alist `((".*" . ,(oni-data-dir-locate "backup-files")))) @@ -79,6 +87,7 @@ (add-hook 'electric-indent-local-mode-hook #'oni-core--switch-newline-keys) (add-hook 'minibuffer-setup-hook 'electric-pair-local-mode) (add-hook 'prog-mode-hook 'goto-address-prog-mode) +(add-hook 'auto-save-hook #'oni-core--ensure-autosave-directory-exists) (global-set-key (kbd "C-M-SPC") 'er/expand-region) (global-set-key (kbd "M-+") 'mc/mark-next-like-this)