From 8f34521e5650df4c28607b4a05da865f4aafda2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?tr=C3=A9meur?= Date: Mon, 5 Dec 2022 16:58:28 +0000 Subject: [PATCH] Make missing directories automatically --- config.org | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/config.org b/config.org index cfd004f..b254af2 100644 --- a/config.org +++ b/config.org @@ -142,6 +142,17 @@ It’s 2022. (setq python-shell-interpreter "python3") #+END_SRC +Make new directories automatically (from [[https://emacsredux.com/blog/2022/06/12/auto-create-missing-directories/][Emacs Redux]]). + +#+BEGIN_SRC emacs-lisp + (defun er-auto-create-missing-dirs () + (let ((target-dir (file-name-directory buffer-file-name))) + (unless (file-exists-p target-dir) + (make-directory target-dir t)))) + + (add-to-list 'find-file-not-found-functions #'er-auto-create-missing-dirs) +#+END_SRC + ** OS-specific stuff On Linux, I have to tell Emacs to use Chrome for web links.