emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Jack Kamm <jackkamm@gmail.com>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: Nasser Alkmim <nasser.alkmim@gmail.com>, emacs-orgmode@gnu.org
Subject: Re: Async Python src block behavior with :dir header property
Date: Sat, 03 Feb 2024 17:26:04 -0800	[thread overview]
Message-ID: <87bk8x81g3.fsf@gmail.com> (raw)
In-Reply-To: <87plxdmtq3.fsf@localhost>

[-- Attachment #1: Type: text/plain, Size: 612 bytes --]

Ihor Radchenko <yantar92@posteo.net> writes:

>> I agree it's a problem -- if there are multiple blocks with the same
>> session but different ":dir" arguments, then a ":file" result of the
>> second block will be relative to the wrong :dir.
>>
>> This seems like a longstanding problem, and affects both async and
>> non-async session blocks.
>
> Maybe something like the attached?

Nice, that seems like the right way to do it.

I updated the patch for `org-babel-comint-async-filter' to follow the
same approach, setting default-directory based on the session buffer's
value rather than the :dir header arg.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ob-comint-Make-file-results-from-async-sessions-resp.patch --]
[-- Type: text/x-patch, Size: 2360 bytes --]

From 1a1a22e4f4a12ebe83c3fef26fe727066fb14476 Mon Sep 17 00:00:00 2001
From: Jack Kamm <jackkamm@gmail.com>
Date: Wed, 31 Jan 2024 20:06:00 -0800
Subject: [PATCH] ob-comint: Make file results from async sessions respect :dir
 header

* lisp/ob-comint.el (org-babel-comint-async-filter): Set
default-directory before calling `org-babel-insert-result'

https://list.orgmode.org/875xz9o4nj.fsf@localhost/T/#t
---
 lisp/ob-comint.el | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lisp/ob-comint.el b/lisp/ob-comint.el
index 7d258ea0e..349524701 100644
--- a/lisp/ob-comint.el
+++ b/lisp/ob-comint.el
@@ -224,6 +224,8 @@ (defun org-babel-comint-async-filter (string)
 	 (file-callback org-babel-comint-async-file-callback)
 	 (combined-string (concat org-babel-comint-async-dangling string))
 	 (new-dangling combined-string)
+         ;; Assumes comint filter called with session buffer current
+         (session-dir default-directory)
 	 ;; list of UUID's matched by `org-babel-comint-async-indicator'
 	 uuid-list)
     (with-temp-buffer
@@ -248,7 +250,8 @@ (defun org-babel-comint-async-filter (string)
                                 (let* ((info (org-babel-get-src-block-info))
                                        (params (nth 2 info))
                                        (result-params
-                                        (cdr (assq :result-params params))))
+                                        (cdr (assq :result-params params)))
+                                       (default-directory session-dir))
                                   (org-babel-insert-result
                                    (funcall file-callback
                                             (nth
@@ -291,7 +294,8 @@ (defun org-babel-comint-async-filter (string)
                                    (let* ((info (org-babel-get-src-block-info))
                                           (params (nth 2 info))
                                           (result-params
-                                           (cdr (assq :result-params params))))
+                                           (cdr (assq :result-params params)))
+                                          (default-directory session-dir))
 				     (org-babel-insert-result
                                       res-str result-params info))
 				   t))))
-- 
2.43.0


  reply	other threads:[~2024-02-04  1:27 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-31  7:29 Async Python src block behavior with :dir header property Nasser Alkmim
2024-01-31 11:23 ` Ihor Radchenko
2024-01-31 12:17   ` Nasser Alkmim
2024-01-31 12:47     ` Ihor Radchenko
2024-01-31 15:00       ` Nasser Alkmim
2024-01-31 16:21         ` Ihor Radchenko
2024-02-01  4:16           ` Jack Kamm
2024-02-01  8:40             ` Nasser Alkmim
2024-02-01 11:59             ` Ihor Radchenko
2024-02-03  1:20               ` Jack Kamm
2024-02-03 15:51                 ` Ihor Radchenko
2024-02-04  1:26                   ` Jack Kamm [this message]
2024-02-04 16:30                     ` Ihor Radchenko
2024-02-05  0:59                       ` Jack Kamm
2024-02-05 14:10                         ` Ihor Radchenko
2024-02-06  6:56                           ` Jack Kamm
2024-02-06 14:06                             ` Ihor Radchenko
2024-02-08  3:08                               ` Jack Kamm
2024-02-08 15:43                                 ` Ihor Radchenko
2024-02-08 17:46                                   ` Bruno Barbier
2024-02-10 18:14                                   ` Jack Kamm
2024-02-10 21:01                                     ` Ihor Radchenko
2024-02-13  9:43                                       ` Nasser Alkmim
2024-02-13 14:31                                         ` Ihor Radchenko

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=87bk8x81g3.fsf@gmail.com \
    --to=jackkamm@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=nasser.alkmim@gmail.com \
    --cc=yantar92@posteo.net \
    /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).