From: "Joaquín Aguirrezabalaga" <kinote@kinote.org>
To: emacs-orgmode@gnu.org
Subject: [PATCH] Fix behaviour of ":dir" when ":mkdirp" is not defined
Date: Wed, 24 Apr 2019 12:43:58 +0200 [thread overview]
Message-ID: <87a7gfof81.fsf@loge.kinote.org> (raw)
[-- 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
next reply other threads:[~2019-04-24 10:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-24 10:43 Joaquín Aguirrezabalaga [this message]
2019-04-28 11:47 ` [PATCH] Fix behaviour of ":dir" when ":mkdirp" is not defined 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a7gfof81.fsf@loge.kinote.org \
--to=kinote@kinote.org \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).