summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Schulte <schulte.eric@gmail.com>2011-01-19 20:29:09 -0700
committerEric Schulte <schulte.eric@gmail.com>2011-01-19 20:29:09 -0700
commitc07b5aed1e161fa0f3c4878006ac0ec3471fec66 (patch)
tree5370270f0ce5ae18ae4ee6f3c59499c9b51bc9a8
parent4007c1cdcead1a2ef52ed7e57d5615203a05204c (diff)
downloadorg-mode-c07b5aed1e161fa0f3c4878006ac0ec3471fec66.tar.gz
ob-tangle: new :mkdirp header argument creates parent dirs of tangle targets
* lisp/ob-tangle.el (org-babel-tangle): New :mkdirp header argument optionally creates parent directories of tangle targets.
-rw-r--r--lisp/ob-tangle.el5
1 files changed, 5 insertions, 0 deletions
diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index 4d34082..d7564d0 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -37,6 +37,7 @@
(declare-function org-back-to-heading "org" (invisible-ok))
(declare-function org-fill-template "org" (template alist))
(declare-function org-babel-update-block-body "org" (new-body))
+(declare-function make-directory "files" (dir &optional parents))
;;;###autoload
(defcustom org-babel-tangle-lang-exts
@@ -210,6 +211,10 @@ exported source code blocks by language."
(if (and ext (string= "yes" tangle))
(concat base-name "." ext) base-name))))
(when file-name
+ ;; possibly create the parent directories for file
+ (when ((lambda (m) (and m (not (string= m "no"))))
+ (get-spec :mkdirp))
+ (make-directory (file-name-directory file-name) 'parents))
;; delete any old versions of file
(when (and (file-exists-p file-name)
(not (member file-name path-collector)))