From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:700:3204::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id pmXvKAw7kGVYdAAAkFu2QA (envelope-from ) for ; Sat, 30 Dec 2023 16:45:16 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id +GeMIgw7kGV4xAAAe85BDQ (envelope-from ) for ; Sat, 30 Dec 2023 16:45:16 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b="OHoVsJ/Y"; 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=1703951116; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=IdREjYZwuugNsW2N4fOOYiQuTkEiINTWiBKyUZiO22c=; b=iWIuSmj1A5+ekcGTLoIdLwHhTof1KGnjPeX4m+d1ECupg66UiKisXmKC0+CP5albdHXyBl twX9sCgD43nmDJ2k/MuQeQOiBmLWEOOf0uGBLyaaSgyQY66V2qlItYmCyyYOzV88dQ6SmQ d1D2HfU0rvPUTgNakiSqxwg1pB4FXKTLliosAB58AiFKLs5oT4LKaNJkd3ndr/JKOvsukm 3VlRWCQyu1x+J0bGwPw9wmV4qGnhrAQYD79oDQC2DHX5Etogpa1zl/wg+rU6xV/TZyetsd zpuD641GMRSKY6Z+ZWcL+NqHwfXvvJJxBhmJ5R3Z8dd8TEyOdDpk4LaDtzPCZA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b="OHoVsJ/Y"; 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=1703951116; a=rsa-sha256; cv=none; b=rwySFqs5X9PXVGvAITugoic5/xuAAn+Tfk8UPy6mQhj3jYWcPAYEj35QP75j7CmMXYmUMx TjhEFG1NQ9D8VyvGLB88i16apDrmOpoqIXDXUQLq70gAXTOcJOu4NlgUr3XPXp4vfbbUlo HeA/8zddg7CBdV2CS7X/OrtPfLP6tyMTIRpEaqa0FTgl52piGr86Xa0AFWMSMdAUngOLkG O3pbpNPJjvF3qHIu/9r7R/TssAGCX8hL82FTpXRsRcDGAmJL+40IQjgeh1gBG8M9ENPDcF REId61ENGEu4XKIMYN+iZFiBGdi+7qBR8fleZxn6ejMswOepqsRc/9TKwgGzjg== 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 2FBC56EB0E for ; Sat, 30 Dec 2023 16:45:16 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rJbVm-0006ot-Oz; Sat, 30 Dec 2023 10:44:30 -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 1rJbVk-0006oS-Nf for emacs-orgmode@gnu.org; Sat, 30 Dec 2023 10:44:28 -0500 Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rJbVh-0001Dl-Px for emacs-orgmode@gnu.org; Sat, 30 Dec 2023 10:44:28 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 18E18240027 for ; Sat, 30 Dec 2023 16:44:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1703951062; bh=of/VYyKP6MQVSc7BJ3VkcY1IEr9n+moH4Ye97GxuRyw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version: Content-Transfer-Encoding:From; b=OHoVsJ/Y3Ckq5k79zSOOU69dns5iDGVCN+jVpKNrPlx4wHhn+ySB7rFOpD3ctmtZI E1ZayDSCJ3N4KMpeFfitUJoUTUkK1FuUeVc0Treg9bE0AKZpxN9WZejnExRwT8xnnr t9deAApC04UbuqJMx8G+lgCGdkhhYFvPwblmfgwb5fNlSVY045XQXAUSta3JZ/Q2/+ tRZh0Smwnb03J+Lo9pGxylrRAm7etrTuqSwRgFq/0L6E+a2JG0f/cXywoKlqsEE9cl dHkdADqSQznEGmMePcsY2x4iaIGOGQZOlFdlhzNbhXrYpCuB+wJ6VB3CkI5QJcmJU4 P3GJQFT9EZwtw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4T2RPd2t3vz9rxK; Sat, 30 Dec 2023 16:44:21 +0100 (CET) From: Ihor Radchenko To: Jack Kamm Cc: emacs-orgmode@gnu.org Subject: Re: [PATCH] Change default ob-python session command to match run-python In-Reply-To: <87edf41yeb.fsf@gmail.com> References: <87edf41yeb.fsf@gmail.com> Date: Sat, 30 Dec 2023 15:47:34 +0000 Message-ID: <87frzj8zft.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=185.67.36.65; envelope-from=yantar92@posteo.net; helo=mout01.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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -9.48 X-Spam-Score: -9.48 X-Migadu-Queue-Id: 2FBC56EB0E X-Migadu-Scanner: mx10.migadu.com X-TUID: HO+bWeB1pvnB Jack Kamm writes: > The attached patch changes the default behavior of ob-python sessions, > to respect python-shell-interpreter(-args) when starting an interactive > session. Thanks! I have several comments. > -(defcustom org-babel-python-command "python" > - "Name of the command for executing Python code." > - :version "24.4" > - :package-version '(Org . "8.0") > +(defcustom org-babel-python-command nil > + "Name of the command for interactive and non-interactive Python code. > +If set, it overrides `org-babel-python-command-session' and > +`org-babel-python-command-nonsession'." What about default value being 'auto? That would be more explicit. > + :version "29.2" :version tags should not be used when we use :package-version - we drop them as we change the defcustom that still has them. See 15.1 Common Item Keywords section of Elisp manual: =E2=80=98:package-version '(PACKAGE . VERSION)=E2=80=99 This keyword specifies that the item was first introduced in PACKAGE version VERSION, or that its meaning or default value was changed in that version. This keyword takes priority over ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ =E2=80=98:version=E2=80=99 ^^^^^^^^^^ > +(defcustom org-babel-python-command-session nil > + "Name of the command for starting interactive Python sessions. > +If `nil' (the default), uses the values from > +`python-shell-interpreter' and `python-shell-interpreter-args'. > +If `org-babel-python-command' is set, then it overrides this > +option." > ... > +(defcustom org-babel-python-command-nonsession "python" > + "Name of the command for executing non-interactive Python code. > +If `org-babel-python-command' is set, then it overrides this option." Unless I miss something, it looks like you also allow command arguments, not just command name as the value. You may need to adjust the docstring to reflect this fact. > (defun org-babel-execute:python (body params) > "Execute Python BODY according to PARAMS. > This function is called by `org-babel-execute-src-block'." > - (let* ((org-babel-python-command > + (let* ((org-babel-python-command-nonsession > + (or (cdr (assq :python params)) > + org-babel-python-command > + org-babel-python-command-nonsession)) > + (org-babel-python-command-session > (or (cdr (assq :python params)) > - org-babel-python-command)) > + org-babel-python-command > + org-babel-python-command-session)) > @@ -374,7 +407,7 @@ (defun org-babel-python-evaluate-external-process > non-nil, then save graphical results to that file instead." > (let ((raw > (pcase result-type > - (`output (org-babel-eval org-babel-python-command > + (`output (org-babel-eval org-babel-python-command-nonsession > I am slightly concerned about `org-babel-python-evaluate-external-process' relying upon being called from `org-babel-execute:python' that let-binds `org-babel-python-nonsession'. Since `org-babel-python-evaluate-external-process' is a public function, it may also be called independently. And it will not obey `org-babel-python-command' then. --=20 Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at