From 35b20de45f27038f2249edae1476f5c9932a8b55 Mon Sep 17 00:00:00 2001 From: Leo Vivier Date: Fri, 17 Apr 2020 06:39:03 +0200 Subject: [PATCH] (fix): ensure that directory exists before capturing to dir (#476) Co-authored-by: Jethro Kuan --- org-roam-capture.el | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/org-roam-capture.el b/org-roam-capture.el index 5d7d149..0983cfc 100644 --- a/org-roam-capture.el +++ b/org-roam-capture.el @@ -218,17 +218,18 @@ the file if the original value of :no-save is not t and (org-template (org-capture-get :template)) (roam-template (concat roam-head org-template))) (unless (file-exists-p file-path) + (make-directory (file-name-directory file-path) t) (org-roam-capture--put :orig-no-save (org-capture-get :no-save) :new-file t) (org-capture-put :template - ;; Fixes org-capture-place-plain-text throwing 'invalid search bound' - ;; when both :unnarowed t and "%?" is missing from the template string; - ;; may become unnecessary when the upstream bug is fixed - (if (s-contains-p "%?" roam-template) - roam-template - (concat roam-template "%?")) - :type 'plain - :no-save t)) + ;; Fixes org-capture-place-plain-text throwing 'invalid search bound' + ;; when both :unnarowed t and "%?" is missing from the template string; + ;; may become unnecessary when the upstream bug is fixed + (if (s-contains-p "%?" roam-template) + roam-template + (concat roam-template "%?")) + :type 'plain + :no-save t)) file-path)) (defun org-roam-capture--expand-template ()