* [PATCH] Fix behaviour of ":dir" when ":mkdirp" is not defined
@ 2019-04-24 10:43 Joaquín Aguirrezabalaga
2019-04-28 11:47 ` Achim Gratz
0 siblings, 1 reply; 4+ messages in thread
From: Joaquín Aguirrezabalaga @ 2019-04-24 10:43 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 618 bytes --]
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ob-core-Fix-dir-when-mkdirp-is-not-defined.patch --]
[-- Type: text/x-diff, Size: 2089 bytes --]
From 9a6e63a96604dce4efac7780a633341ce00828d8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Joaqu=C3=ADn=20Aguirrezabalaga?= <kinote@kinote.org>
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] Fix behaviour of ":dir" when ":mkdirp" is not defined
@ 2019-04-25 6:19 Joaquín Aguirrezabalaga
2019-04-25 8:39 ` Nicolas Goaziou
0 siblings, 1 reply; 4+ messages in thread
From: Joaquín Aguirrezabalaga @ 2019-04-25 6:19 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 618 bytes --]
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ob-core-Fix-dir-when-mkdirp-is-not-defined.patch --]
[-- Type: text/x-diff, Size: 2089 bytes --]
From 9a6e63a96604dce4efac7780a633341ce00828d8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Joaqu=C3=ADn=20Aguirrezabalaga?= <kinote@kinote.org>
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Fix behaviour of ":dir" when ":mkdirp" is not defined
2019-04-25 6:19 Joaquín Aguirrezabalaga
@ 2019-04-25 8:39 ` Nicolas Goaziou
0 siblings, 0 replies; 4+ messages in thread
From: Nicolas Goaziou @ 2019-04-25 8:39 UTC (permalink / raw)
To: Joaquín Aguirrezabalaga; +Cc: emacs-orgmode
Hello,
Joaquín Aguirrezabalaga <kinote@kinote.org> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Fix behaviour of ":dir" when ":mkdirp" is not defined
2019-04-24 10:43 [PATCH] Fix behaviour of ":dir" when ":mkdirp" is not defined Joaquín Aguirrezabalaga
@ 2019-04-28 11:47 ` Achim Gratz
0 siblings, 0 replies; 4+ messages in thread
From: Achim Gratz @ 2019-04-28 11:47 UTC (permalink / raw)
To: emacs-orgmode
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 :-)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-04-28 11:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-24 10:43 [PATCH] Fix behaviour of ":dir" when ":mkdirp" is not defined Joaquín Aguirrezabalaga
2019-04-28 11:47 ` Achim Gratz
-- strict thread matches above, loose matches on Subject: below --
2019-04-25 6:19 Joaquín Aguirrezabalaga
2019-04-25 8:39 ` Nicolas Goaziou
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).