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: Mon, 04 Mar 2019 23:21:25 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

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)))

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

> +(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")))

I applied your patch with the changes above.

Regards,

-- 
Nicolas Goaziou



reply via email to

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