From 3f8c0a253d872a11059a978985cc8ac4153c622e Mon Sep 17 00:00:00 2001 From: Anton Onyshchenko Date: Wed, 20 May 2015 23:01:17 +0200 Subject: [PATCH] Make directory if it does not exist when renaming the current buffer file --- spacemacs/funcs.el | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spacemacs/funcs.el b/spacemacs/funcs.el index c6eb6584b..2888af4e4 100644 --- a/spacemacs/funcs.el +++ b/spacemacs/funcs.el @@ -399,6 +399,9 @@ argument takes the kindows rotate backwards." (cond ((get-buffer new-name) (error "A buffer named '%s' already exists!" new-name)) (t + (let ((dir (file-name-directory new-name))) + (when (and (not (file-exists-p dir)) (yes-or-no-p (format "Create directory '%s'?" dir))) + (make-directory dir t))) (rename-file filename new-name 1) (rename-buffer new-name) (set-visited-file-name new-name)