Created
May 21, 2013 14:38
-
-
Save jwinder/5620306 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Create non-existent directories containing a new file before saving | |
(add-hook 'before-save-hook | |
(lambda () | |
(when buffer-file-name | |
(let ((dir (file-name-directory buffer-file-name))) | |
(when (and (not (file-exists-p dir)) | |
(y-or-n-p (format "Directory %s does not exist. Create it?" dir))) | |
(make-directory dir t)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment