Re: [O] [PATCH] Fix behaviour of ":dir" when ":mkdirp" is not defined

2019-04-28 Thread Achim Gratz

Am 24.04.2019 um 12:43 schrieb Joaquín Aguirrezabalaga:

   #+begin_src elisp :dir /tmp/some-test-dir :mkdirp t
   default-directory
   #+end_src


Do not hardcode "/tmp" in the tests.


--
Achim.

(on the road :-)




[O] [PATCH] Fix behaviour of ":dir" when ":mkdirp" is not defined

2019-04-28 Thread Joaquín Aguirrezabalaga
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ín Aguirrezabalaga

>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



Re: [O] [PATCH] Fix behaviour of ":dir" when ":mkdirp" is not defined

2019-04-25 Thread Nicolas Goaziou
Hello,

Joaquín Aguirrezabalaga  writes:

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

Applied, with a slight refactoring to use `cond' instead of `or' + `if'.

I added TINYCHANGE at the end of the commit message since I don't know
if you signed FSF papers already.

Thank you.

Regards,

-- 
Nicolas Goaziou



[O] [PATCH] Fix behaviour of ":dir" when ":mkdirp" is not defined

2019-04-25 Thread Joaquín Aguirrezabalaga
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ín Aguirrezabalaga

>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