home

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 1ace167c33839120babb35ba36640572ab367c57
parent 71d0c5b23282d1e4e23dd4abdd4e772f6c3df853
Author: Vincent Demeester <vincent@sbr.pm>
Date:   Thu, 20 Aug 2020 12:32:04 +0200

tools/emacs: prompt in case of non-existing directory…

Signed-off-by: Vincent Demeester <vincent@sbr.pm>

Diffstat:
Mtools/emacs/config/config-editing.el | 10++++++++++
1 file changed, 10 insertions(+), 0 deletions(-)

diff --git a/tools/emacs/config/config-editing.el b/tools/emacs/config/config-editing.el @@ -4,6 +4,16 @@ ;;; Code: (setq-default enable-remote-dir-locals t) +;; When finding file in non-existing directory, offer to create the +;; parent directory. +(defun with-buffer-name-prompt-and-make-subdirs () + (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 #'with-buffer-name-prompt-and-make-subdirs) + ;; UseSmartParens (use-package smartparens :commands (smartparens-mode smartparens-global-mode show-smartparens-global-mode