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: stardiviner
Subject: Re: [O] [FEATURE] Make header argument :mkdirp yes work for other header arguments not just :tangle
Date: Tue, 05 Mar 2019 13:13:48 +0800
User-agent: mu4e 1.1.0; emacs 27.0.50

Nicolas Goaziou <address@hidden> writes:

> Hello,
>
> stardiviner <address@hidden> writes:
>
>> New patch in attachment.
>
> Thank you.
>
>> From aafdd41f7ae5f6218a2be890f58d45be443de4a9 Mon Sep 17 00:00:00 2001
>> From: stardiviner <address@hidden>
>> 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 via email to

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