(fix): ensure that directory exists before capturing to dir (#476)

Co-authored-by: Jethro Kuan <jethrokuan95@gmail.com>
This commit is contained in:
Leo Vivier
2020-04-17 06:39:03 +02:00
committed by GitHub
parent 06afa27725
commit 35b20de45f

View File

@ -218,17 +218,18 @@ the file if the original value of :no-save is not t and
(org-template (org-capture-get :template)) (org-template (org-capture-get :template))
(roam-template (concat roam-head org-template))) (roam-template (concat roam-head org-template)))
(unless (file-exists-p file-path) (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) (org-roam-capture--put :orig-no-save (org-capture-get :no-save)
:new-file t) :new-file t)
(org-capture-put :template (org-capture-put :template
;; Fixes org-capture-place-plain-text throwing 'invalid search bound' ;; Fixes org-capture-place-plain-text throwing 'invalid search bound'
;; when both :unnarowed t and "%?" is missing from the template string; ;; when both :unnarowed t and "%?" is missing from the template string;
;; may become unnecessary when the upstream bug is fixed ;; may become unnecessary when the upstream bug is fixed
(if (s-contains-p "%?" roam-template) (if (s-contains-p "%?" roam-template)
roam-template roam-template
(concat roam-template "%?")) (concat roam-template "%?"))
:type 'plain :type 'plain
:no-save t)) :no-save t))
file-path)) file-path))
(defun org-roam-capture--expand-template () (defun org-roam-capture--expand-template ()