emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: stardiviner <numbchild@gmail.com>
To: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Cc: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: [FEATURE] Make header argument :mkdirp yes work for other header arguments not just :tangle
Date: Tue, 05 Mar 2019 13:13:48 +0800	[thread overview]
Message-ID: <87ef7l52er.fsf@gmail.com> (raw)
In-Reply-To: <87imwy2sd6.fsf@nicolasgoaziou.fr>


Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Hello,
>
> stardiviner <numbchild@gmail.com> writes:
>
>> New patch in attachment.
>
> Thank you.
>
>> From aafdd41f7ae5f6218a2be890f58d45be443de4a9 Mon Sep 17 00:00:00 2001
>> From: stardiviner <numbchild@gmail.com>
>> Date: Sat, 2 Mar 2019 12:11:47 +0800
>> Subject: [PATCH] ob-core.el: Make :mkdirp work for :dir too
>>
>> * lisp/ob-core.el (org-babel-execute-src-block): make directory if :dir
>>   path does not exist when :mkdirp yes exist.
>>
>> * doc/org-manualo.rg (mkdirp): declare new change in manual.
>>
>> * etc/ORG-NEWS: declare changes in ORG-NEWS.
>
> No need to declare changes in changes file. This could end up in an
> infloop.
>
>> +		   (or (and dir
>> +			    ;; Possibly create the parent directories for file.
>> +			    (let ((fnd (file-name-as-directory (expand-file-name dir))))
>> +			      (cond
>> +			       ((member mkdirp '("yes" "t")) (make-directory fnd 'parents))
>> +			       ((member mkdirp '("no" "nil")) nil)
>> +			       (t (make-directory fnd 'parents)))))
>>  		       default-directory))
>
> I used:
>
> 	   (or (and dir
> 		    (not (member mkdirp '("no" "nil" nil)))
> 		    (progn
> 		      (let ((d (file-name-as-directory
> 				(expand-file-name dir))))
> 			(make-directory d 'parents)
> 			d)))

I indeed have this thought of code too. But later changed still. I'm not good at
Elisp yet, so hard to figure out which style code is better. I will keep
learning. Thanks for your advice and teaching.

> Do we need to make a case when dir is a remote?

Absolutely, some people use remote dir very often, myself too. I use literate
programming in Org Mode, so TRAMP etc support is very necessary. But I don't
know how to support for remote dir.

>
>> +(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")))
>> +
>
> I meant (should (org-test-with-temp-text "..." ... (file-directory-p "data/code")))

Learned. I will check out to learn a bit of ert testing framework in recently.

>
> I applied your patch with the changes above.
>
> Regards,

Thanks as always.

-- 
[ stardiviner ]
       I try to make every word tell the meaning what I want to express.

       Blog: https://stardiviner.github.io/
       IRC(freenode): stardiviner, Matrix: stardiviner
       GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
      

  reply	other threads:[~2019-03-05  5:13 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
2019-03-03 15:15       ` stardiviner
2019-03-04 22:21         ` Nicolas Goaziou
2019-03-05  5:13           ` stardiviner [this message]
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=87ef7l52er.fsf@gmail.com \
    --to=numbchild@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@nicolasgoaziou.fr \
    /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).