Hello, stardiviner <numbch...@gmail.com> writes:
> I hope ~:mkdirp~ header argument can also work for other related header > arguments > like ~:dir~, ~:file~ etc not just ~:tangle~. Like following example. > > #+begin_src sh :mkdirp yes :dir "data/code/mkdirp/dir" :file "test" :results > file link > echo "hello" > #+end_src > > So I added a simple patch to make it work. Thank you. Some comments follow. > #+cindex: @samp{mkdirp}, header argument > -The =mkdirp= header argument creates parent directories for tangled > -files if the directory does not exist. =yes= enables directory > -creation and =no= inhibits directory creation. > +The =mkdirp= header argument creates parent directories for =dir= > +header argument specified path and tangled files if the directory does > +not exist. =yes= enables directory creation and =no= inhibits > +directory creation. Please also support "t" and "nil", or, more generally, make "no" and "nil" equivalent, and anything else would be "t". > - (or (and dir (file-name-as-directory (expand-file-name dir))) > + (or (and dir > + ;; Possibly create the parent directories for file. > + (let (fnd (file-name-as-directory (expand-file-name > dir))) > + (if (and (string= mkdirp "yes") fnd) > + (make-directory fnd 'parents)))) > +;;; test-ob-core.el --- tests for ob-core.el Tests are in "test-ob.el" file. You should add yours there instead of creating a new file. > +(ert-deftest test-ob-core/dir-mkdirp () > + (org-test-with-temp-text > + "#+begin_src sh :mkdirp yes :dir \"data/code\" > +pwd > +#+end_src" > + (org-babel-execute-src-block) > + (should (file-directory-p "data/code")))) Nitpick: `should' is better outside `org-test-with-temp-text'? Could you send an updated patch? Regards, -- Nicolas Goaziou