From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?utf-8?Q?Joaqu=C3=ADn?= Aguirrezabalaga Subject: [PATCH] Fix behaviour of ":dir" when ":mkdirp" is not defined Date: Wed, 24 Apr 2019 12:43:58 +0200 Message-ID: <87a7gfof81.fsf@loge.kinote.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([209.51.188.92]:41129) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hJFNt-00037j-9G for emacs-orgmode@gnu.org; Wed, 24 Apr 2019 06:44:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hJFNs-0002wz-5G for emacs-orgmode@gnu.org; Wed, 24 Apr 2019 06:44:13 -0400 Received: from niflheim.kinote.org ([46.38.243.128]:33867 helo=mail.kinote.org) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hJFNr-0002v4-Sl for emacs-orgmode@gnu.org; Wed, 24 Apr 2019 06:44:12 -0400 Received: from loge.kinote.org (loge [10.18.201.32]) by mail.kinote.org (Postfix) with ESMTP id D339B3A012C for ; Wed, 24 Apr 2019 12:44:08 +0200 (CEST) Received: from loge (localhost [127.0.0.1]) by loge.kinote.org (Postfix) with ESMTPS id 9105E194050B for ; Wed, 24 Apr 2019 12:44:08 +0200 (CEST) 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: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello, I think the behaviour of ":dir" is broken since commit 8b5941330 (ob-core: Make :mkdirp work for :dir too). It only works now if ":mkdirp" is defined. If I execute the following: #+begin_src elisp :dir /tmp/some-test-dir default-directory #+end_src Instead of the expected "/tmp/some-test-dir" returned value, I get my current directory. Only add ":mkdirp t": #+begin_src elisp :dir /tmp/some-test-dir :mkdirp t default-directory #+end_src do I get the expected result. Please find attached my proposal for fixing the issue. Regards, Joaqu=C3=ADn Aguirrezabalaga --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-ob-core-Fix-dir-when-mkdirp-is-not-defined.patch >From 9a6e63a96604dce4efac7780a633341ce00828d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20Aguirrezabalaga?= Date: Wed, 24 Apr 2019 11:42:19 +0200 Subject: [PATCH] ob-core: Fix :dir when :mkdirp is not defined * lisp/ob-core.el (org-babel-execute-src-block): Fix behaviour of ":dir path" when ":mkdirp" is not defined. * testing/lisp/test-ob.el: Add a test case. Since commit 8b5941330 the behaviour for ":dir path" is broken. Its value is only considered when ":mkdirp" is defined. --- lisp/ob-core.el | 13 +++++++------ testing/lisp/test-ob.el | 8 ++++++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 7591e99ca..eaeb56837 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -680,12 +680,13 @@ block." (mkdirp (cdr (assq :mkdirp params))) (default-directory (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))) + (if (member mkdirp '("no" "nil" nil)) + (file-name-as-directory (expand-file-name dir)) + (progn + (let ((d (file-name-as-directory + (expand-file-name dir)))) + (make-directory d 'parents) + d)))) default-directory)) (cmd (intern (concat "org-babel-execute:" lang))) result) diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index facc0a4ba..1833cac3c 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -1635,6 +1635,14 @@ t (prog1 (file-directory-p "data/code") (delete-directory "data" t))))) +(ert-deftest test-ob-core/dir-no-mkdirp () + "Test :dir without :mkdirp header combination." + (org-test-with-temp-text-in-file + "#+begin_src emacs-lisp :dir /tmp/test-dir-no-mkdirp +default-directory +#+end_src" + (should (equal "/tmp/test-dir-no-mkdirp/" (org-babel-execute-src-block))))) + (ert-deftest test-ob/script-escape () ;; Delimited lists of numbers (should (equal '(1 2 3) -- 2.20.1 --=-=-=--