From mboxrd@z Thu Jan 1 00:00:00 1970 From: stardiviner 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 Message-ID: <87ef7l52er.fsf@gmail.com> References: <87ftsk9w03.fsf@gmail.com> <87a7id3mf0.fsf@gmail.com> <8736o4h15m.fsf@gmail.com> <87k1hge652.fsf@nicolasgoaziou.fr> <871s3ogfbe.fsf@gmail.com> <87imwy2sd6.fsf@nicolasgoaziou.fr> Reply-To: numbchild@gmail.com Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([209.51.188.92]:54967) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h12Om-0002hv-Qg for emacs-orgmode@gnu.org; Tue, 05 Mar 2019 00:13:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h12Ol-0000Af-UO for emacs-orgmode@gnu.org; Tue, 05 Mar 2019 00:13:52 -0500 Received: from [61.175.244.13] (port=9569 helo=dark.localdomain) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h12Ol-000086-E9 for emacs-orgmode@gnu.org; Tue, 05 Mar 2019 00:13:51 -0500 In-reply-to: <87imwy2sd6.fsf@nicolasgoaziou.fr> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Nicolas Goaziou Cc: Org Mode Nicolas Goaziou writes: > Hello, > > stardiviner writes: > >> New patch in attachment. > > Thank you. > >> From aafdd41f7ae5f6218a2be890f58d45be443de4a9 Mon Sep 17 00:00:00 2001 >> From: stardiviner >> 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