diff options
author | Alan Pearce | 2014-12-17 20:09:20 +0000 |
---|---|---|
committer | Alan Pearce | 2014-12-17 20:09:20 +0000 |
commit | 6dca0437a33666f1f2b11c1812d1eae03097bc6e (patch) | |
tree | 97b0d3921c18403de8113a9d97beef33f95f077e /tag-emacs/emacs.d/init.el | |
parent | 2a3a3b4caf2b881ece4c83b4a7e02047f3735555 (diff) | |
download | dotfiles-6dca0437a33666f1f2b11c1812d1eae03097bc6e.tar.lz dotfiles-6dca0437a33666f1f2b11c1812d1eae03097bc6e.tar.zst dotfiles-6dca0437a33666f1f2b11c1812d1eae03097bc6e.zip |
Emacs: Offer to create missing directories
Diffstat (limited to 'tag-emacs/emacs.d/init.el')
-rw-r--r-- | tag-emacs/emacs.d/init.el | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tag-emacs/emacs.d/init.el b/tag-emacs/emacs.d/init.el index 3187d09..a43ffe4 100644 --- a/tag-emacs/emacs.d/init.el +++ b/tag-emacs/emacs.d/init.el @@ -406,6 +406,13 @@ (kill-this-buffer) (message "File '%s' successfully removed" filename))))) +(defun my-create-non-existent-directory () + (let ((parent-directory (file-name-directory buffer-file-name))) + (when (and (not (file-exists-p parent-directory)) + (y-or-n-p (format "Directory `%s' does not exist! Create it?" parent-directory))) + (make-directory parent-directory t)))) +(add-to-list 'find-file-not-found-functions #'my-create-non-existent-directory) + (defun kill-or-delete-this-buffer-dwim (&optional arg) "Kills current buffer. With prefix arg, delete it." (interactive "P") |