emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: stardiviner <numbchild@gmail.com>
Cc: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: [FEATURE] Make header argument :mkdirp yes work for other header arguments not just :tangle
Date: Sun, 03 Mar 2019 09:03:53 +0100	[thread overview]
Message-ID: <87k1hge652.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <8736o4h15m.fsf@gmail.com> (stardiviner's message of "Sun, 03 Mar 2019 15:23:17 +0800")

Hello,

stardiviner <numbchild@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

  reply	other threads:[~2019-03-03  8:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-19  5:40 [Proposal] Make header argument :mkdirp yes work for other header arguments not just :tangle Christopher M. Miles
2019-03-02  4:55 ` stardiviner
2019-03-03  7:23   ` [FEATURE] " stardiviner
2019-03-03  8:03     ` Nicolas Goaziou [this message]
2019-03-03 15:15       ` stardiviner
2019-03-04 22:21         ` Nicolas Goaziou
2019-03-05  5:13           ` stardiviner
2019-03-05  6:02           ` [Discuss] make :tangle header argument respect :dir could save info typing stardiviner
2019-03-19 13:08             ` Sean O'Halpin
2019-03-20  5:47               ` stardiviner
2019-03-03  4:32 ` [Proposal] Make header argument :mkdirp yes work for other header arguments not just :tangle stardiviner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k1hge652.fsf@nicolasgoaziou.fr \
    --to=mail@nicolasgoaziou.fr \
    --cc=emacs-orgmode@gnu.org \
    --cc=numbchild@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).