From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id yN04JjS7v2UToAAAqHPOHw:P1 (envelope-from ) for ; Sun, 04 Feb 2024 17:28:36 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id yN04JjS7v2UToAAAqHPOHw (envelope-from ) for ; Sun, 04 Feb 2024 17:28:36 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b="d8Lor/vi"; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1707064116; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=q7HAAfOPb6IXL5aT8UWQ85aMf94yeo/t7FM6kosHfmc=; b=gBbHCK8W5i1QDwS1Mck9lu/8w56S/Bepkjiuquqfn0jW0MynIoRXz11zW8+kFbrO3GZbNr EfZ5MZqyAwaLquAe7u/OuPovrlbdySB+q12W2bWLGe8XYr8tCRrTtdTElha92+0GYmf1gf Z/YYELVEHCpr3Z4Ob70GzW4y5orFmk0QENcyzNogZiyqIO3HF3dko7pjMf/DJLsla1pWCv 3tJ12gsCzV3NSd2hyGYbEuqm/f1Z5jI1U9JicmRnjovswZCn1GM1/PxRw3Jm47H4KbPd/e 39JE6dGdG8LxmwjdpzcJh1WZWHR8/1DEwMj1C6knJorfZ3QJlZ49/BwM31fHqw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b="d8Lor/vi"; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.net ARC-Seal: i=1; s=key1; d=yhetil.org; t=1707064116; a=rsa-sha256; cv=none; b=Lz9IwbPDJ3n0QahHvgQq5Xn6aAXmYFsR+cIUbRE9/Cie8lyTDg5M0jaK6R6uLuSmh5fjro aK9GqwVRX49b0VkI88Xda1SOY9Xoq5PzkCZxBnqDSgP3NzGH/3i9ueGdotBvI7XcOTnUkP U9XTCK15d1OLdhS6cSYbplcZE2hpdZhKjs4OGF6y7pRmOLiFDmM8Ms9jmJslpAtCbAuqNJ K2zykByPjERL+ijbjnycmb6di0aQZYKMj/c/tANj3UOOB/6fJRjpRhxsbl1JVVNcytC6Sd bhxfkC5fGN2VQpMD3iskRU7bzI+kXvcyPu3O0BsA5okJ18pB+oH8n2oWIzaMKQ== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 2D75D3F4A3 for ; Sun, 4 Feb 2024 17:28:36 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWfLJ-00068M-HJ; Sun, 04 Feb 2024 11:27:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rWfLH-00068C-1b for emacs-orgmode@gnu.org; Sun, 04 Feb 2024 11:27:39 -0500 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rWfLB-0000Sa-8Z for emacs-orgmode@gnu.org; Sun, 04 Feb 2024 11:27:38 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id B2CBA240104 for ; Sun, 4 Feb 2024 17:27:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1707064047; bh=Y13uXSJSpLSZFCXAnvMvoHxA6JHPlyWWqZm/Jx1Dy6w=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=d8Lor/viM074l9BBrRBshIygCAv1lp6ODVFJiP1rY7OudPn9UTiThjsc2KOpPWRqM Ff/8t43hvmz1gFjqVcTQiioqNc5EnrU9jjCn82I0osLgRMgxRAN4b09wCwIq8t3dSD 9Cix4Msb7IK6MO1AWu0WNM1upGDFkRLN0dy5TJZbnhpyWhL9ru83CXXk3LakeBKmrw guVu6z9XOMnNOBn2pnIPrXORVUR1s+sOpfNVvkTRzZyVzapyUaBZu7LIyeK+WBek/H EnGTNVe20w3znjeRbcGwZgAYZb4LPce8mTkWQqI6QMrJUaX7aK6PpS3zIWcYBRDbFR jwATg9ArLLS8Q== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4TSZfl02Vrz6tvy; Sun, 4 Feb 2024 17:27:26 +0100 (CET) From: Ihor Radchenko To: Jack Kamm Cc: Nasser Alkmim , emacs-orgmode@gnu.org Subject: Re: Async Python src block behavior with :dir header property In-Reply-To: <87bk8x81g3.fsf@gmail.com> References: <87il3a55bg.fsf@gmail.com> <8734udvjai.fsf@localhost> <86plxhely9.fsf@gmail.com> <8734udoejo.fsf@localhost> <86y1c5cztv.fsf@gmail.com> <875xz9o4nj.fsf@localhost> <87plxg95u4.fsf@gmail.com> <87msskmm47.fsf@localhost> <87mssi8ht2.fsf@gmail.com> <87plxdmtq3.fsf@localhost> <87bk8x81g3.fsf@gmail.com> Date: Sun, 04 Feb 2024 16:30:56 +0000 Message-ID: <87y1c019a7.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -9.88 X-Migadu-Scanner: mx13.migadu.com X-Spam-Score: -9.88 X-Migadu-Queue-Id: 2D75D3F4A3 X-TUID: h3T+xVZJ8c65 --=-=-= Content-Type: text/plain Jack Kamm writes: > 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. Thanks! Attaching the two patches combined with some fixed to my patch. Please check if these two patches solve the discussed bug. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-org-babel-execute-src-block-Force-dir-according-to-l.patch >From 66bbac4207d7132ebc9f91f60384809ae556c2ef Mon Sep 17 00:00:00 2001 Message-ID: <66bbac4207d7132ebc9f91f60384809ae556c2ef.1707064153.git.yantar92@posteo.net> From: Ihor Radchenko Date: Sat, 3 Feb 2024 16:47:57 +0100 Subject: [PATCH 1/2] org-babel-execute-src-block: Force :dir according to live session * lisp/ob-core.el (org-babel-execute-src-block): Force eval directory to follow live session buffer, if any. This is consistent with what we promise in the manual section "16.4 Environment of a Code Block">Choosing a working directory. Link: https://orgmode.org/list/87mssi8ht2.fsf@gmail.com --- lisp/ob-core.el | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 1de3af6ad..fd8d06c5d 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -840,14 +840,17 @@ (defun org-babel-execute-src-block (&optional arg info params executor-type) (dir (cdr (assq :dir params))) (mkdirp (cdr (assq :mkdirp params))) (default-directory - (cond - ((not dir) default-directory) - ((member mkdirp '("no" "nil" nil)) - (file-name-as-directory (expand-file-name dir))) - (t - (let ((d (file-name-as-directory (expand-file-name dir)))) - (make-directory d 'parents) - d)))) + (cond + ((not dir) default-directory) + ((when-let ((session (cdr (assq :session params)))) + (when (org-babel-comint-buffer-livep session) + (buffer-local-value 'default-directory (get-buffer session))))) + ((member mkdirp '("no" "nil" nil)) + (file-name-as-directory (expand-file-name dir))) + (t + (let ((d (file-name-as-directory (expand-file-name dir)))) + (make-directory d 'parents) + d)))) (cmd (intern (concat "org-babel-execute:" lang))) result exec-start-time) (unless (fboundp cmd) -- 2.43.0 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0002-ob-comint-Make-file-results-from-async-sessions-resp.patch >From e9765a146bf27e6769a2563862d52b0efb77eb2e Mon Sep 17 00:00:00 2001 Message-ID: In-Reply-To: <66bbac4207d7132ebc9f91f60384809ae556c2ef.1707064153.git.yantar92@posteo.net> References: <66bbac4207d7132ebc9f91f60384809ae556c2ef.1707064153.git.yantar92@posteo.net> From: Jack Kamm Date: Wed, 31 Jan 2024 20:06:00 -0800 Subject: [PATCH 2/2] 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 --=-=-= Content-Type: text/plain -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at --=-=-=--