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 ACEUG5WemmX1IAEAkFu2QA (envelope-from ) for ; Sun, 07 Jan 2024 13:52:37 +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 eAIxE5WemmXicAAAe85BDQ (envelope-from ) for ; Sun, 07 Jan 2024 13:52:37 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=iqKV9Xkt; 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=1704631957; 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=ZUwDkbaBhRtFtXzFI78RS9vPJtNiyc/hZQ68B4MkH6I=; b=TVTv6eQq9ivTwU08Kq1AdxksW8uXsp+yeJrqfyeo45hG5MxRb0Tx/RrTTBE1WWsn19kKZi bbOSNNa6MwSSjk0HJmrlCKnLd4GPKGkMYEjiDr6VUG4r9M0w/FN5ip4oB6pW0xv7fQVJzy VAmmCSKYUL6G8CBdOH2HSLhfKdsoVWmNJRpzlKtS3/q18YnATR+PgCTtaXATDbGx9i67St 5XC6E1FhUJLCtKnFtYtEeYHq1OitXusaEmjWKAENYTTNKfSaz282ko9egDavRsM8/ysZUv rlt3dnB5LqtDniBrT1CRL3yzJN07LJW82rdVx5VOoetRdt6F+WNTqq203kh/TA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1704631957; a=rsa-sha256; cv=none; b=bftfGiTLoL3N4sWlBQgL/cOYwb1+tJkEGkGlNrKkdndHj/eUNjmmilQtdaFg2FK6N14Tui oAeCzx8/0EIzKatsKUNLfTGYsdAUwFniW0I0yDeKe0Pl73FwBY0ZmhuPqXzhB4XyTOLqKL AvOh9WrtdVWmU202r5uZvdWV0u5isRdPMaEJfakcU8ed2C9z0YU6lzbyGAiLa9cgQnIIvX Z8ymzQNxlCJ5CKSc7EuE92xuWnfiyvD0j6gtVG0nstlR5bteLpJSXZuv8r+Zg+YgUO2frD 2M+96O9oOX3uwjAiS7bCl7PjnGUdAKWvvfntMIzW+2U2GFmUpKj9/TCkoKCiUw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=iqKV9Xkt; 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 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 CAABD77C72 for ; Sun, 7 Jan 2024 13:52:36 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rMScx-0000Cq-Fr; Sun, 07 Jan 2024 07:51:43 -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 1rMScu-0000Ch-8O for emacs-orgmode@gnu.org; Sun, 07 Jan 2024 07:51:40 -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 1rMScp-0004dc-VK for emacs-orgmode@gnu.org; Sun, 07 Jan 2024 07:51:38 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 5480A240104 for ; Sun, 7 Jan 2024 13:51:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1704631891; bh=1Zpgfsd5dnMAG97Kd5Tx4PXnLRRCWAb5jy7bIT8WrUw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From; b=iqKV9Xkt7D7FZTZuf/TokH0l1fih4Das0ry4gteF4W/URSZq63i/4oas/NHk3r8tC ZrHg/2U8y3H/N3L+oJ1qnLAoqwvRzBv+1Vvu135DhiI99n8INRbx/Mw1HSkEwZgxv3 skFiVgWb37Uza+5b3RTff/iSB6saCSC3M8jndTrLDd5UHWtqF+8GOmjqUMr39D1AM3 2Obh5u3BNGpNCZmbgopL+Qupt6KvcLI/qboLAtkS85EM+uvqAQJTp9w6IiQgtQSrH0 p8nZ4uyYsrI9qUHtq3n5TrPXFfw/1MmsznuC0qty8pv8q/XZjIrLPk3wvtMmY0NhB4 9SDfovqhHzIPg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4T7HBV3s7sz6tsB; Sun, 7 Jan 2024 13:51:30 +0100 (CET) From: Ihor Radchenko To: Jack Kamm Cc: Liu Hui , emacs-orgmode@gnu.org Subject: Re: [PATCH] Set Python shell in Org edit buffer In-Reply-To: <87o7dxu15h.fsf@gmail.com> References: <87zfyosw8n.fsf@localhost> <87ttovlb1u.fsf@localhost> <878r6647vv.fsf@localhost> <87bkb2rqer.fsf@localhost> <87edfwsuvx.fsf@localhost> <87sf4bsm1w.fsf@localhost> <87mstw18r4.fsf@gmail.com> <87bkaak0ol.fsf@localhost> <87ttnyz0jv.fsf@gmail.com> <87wmsn6ghw.fsf@localhost> <87o7dxu15h.fsf@gmail.com> Date: Sun, 07 Jan 2024 12:54:40 +0000 Message-ID: <87msthwbfz.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.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=-1, 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-Queue-Id: CAABD77C72 X-Migadu-Scanner: mx10.migadu.com X-Migadu-Spam-Score: -9.51 X-Spam-Score: -9.51 X-TUID: wc9BFDQaI0gl Jack Kamm writes: >> Now, the question is what to do with the existing implementation of >> `org-src-associate-babel-session'. It only runs >> org-babel--associate-session when >> >> (and session (not (string= session "none")) >> (org-babel-comint-buffer-livep session) >> (let ((f (intern (format "org-babel-%s-associate-session" >> (nth 0 info))))) >> (and (fboundp f) (funcall f session)))) >> ... >> I am tentatively inclined to change this check to >> >> (or (org-babel-comint-buffer-livep session) >> (eq org-src-auto-initiate-session t) >> (alist-get (nth 0 info) org-src-auto-initiate-session) >> (alist-get 'default org-src-auto-initiate-session)) > > I think there are 2 aspects of the session+editing behavior that I'd > like to disentangle: > > 1. Whether to create session when editing (if it doesn't exist yet) > 2. If session exists, whether to "associate" it so that evaluation > commands (e.g. python-shell-send-region, ess-eval-region) and > autocompletion use it. > > Personally, I prefer to disable #1 while enabling #2. For ob-R, it > seems like #1 happens in `org-babel-edit-prep:R' while #2 happens in > `org-babel-R-associate-session', so adding an option to disable the > latter isn't useful for me, and it's not clear to me whether it'd be > useful generally for others either. > ... > As an aside, I just noticed some inconsistent behavior in ob-R. It seems > it only auto-creates the session when ":session *foo*" (i.e. the session > name has "earmuffs"). But when ":session foo" (no earmuffs), ob-R > doesn't autostart the session. While this is probably accidental, it > doesn't seem to cause any problems, which makes me question whether it's > really needful for ob-R to initiate a session on edit. In particular, > if ":session foo" already exists, then ess-eval-region still works fine > in the src block. Which is exactly my desired behavior -- don't create > the session if it doesn't exist yet, but if it already exists then play > nicely with it. I imagine that both #1 and #2 should happen in org-babel--associate-session. #1 should probably be discouraged, and it looks like even for ob-R creating new session is not really necessary. So, a good option could be (1) removing (org-babel-comint-buffer-livep session) from `org-src-associate-babel-session' (2) Removing `org-babel-edit-prep:R' Then, the existence of org-babel--associate-session will simply be a reminder for babel backends to implement session support inside babel edit buffers. > As for ob-python; I think it's best to set `python-shell-buffer-name' > in `org-babel-edit-prep:python' rather than > `org-babel-python-associate-session'. While both work for > `python-shell-send-region' if the session already exists, > `org-babel-edit-prep:python' has the advantage that it will run even > if the session doesn't exist yet, so then "M-x run-python" in the src > block will create a session with the correct name. With the above, we can use `org-babel-python-associate-session'. Just for consistency - org-babel--associate-session is somewhat redundant as org-babel-edit-prep: can be used every time the format is used, except that org-babel--associate-session function does not need to check if :session argument is present. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at