emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [FEATURE] Make header argument :mkdirp yes work for other header


From: Nicolas Goaziou
Subject: Re: [O] [FEATURE] Make header argument :mkdirp yes work for other header arguments not just :tangle
Date: Sun, 03 Mar 2019 09:03:53 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

Hello,

stardiviner <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]