From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.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 IJ1mEzrUcWX1CAEAG6o9tA:P1 (envelope-from ) for ; Thu, 07 Dec 2023 15:18:34 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id IJ1mEzrUcWX1CAEAG6o9tA (envelope-from ) for ; Thu, 07 Dec 2023 15:18:34 +0100 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 E48CD5970C for ; Thu, 7 Dec 2023 15:18:33 +0100 (CET) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=S0PFi4b4; dmarc=pass (policy=none) header.from=gmail.com; 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" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1701958714; a=rsa-sha256; cv=none; b=P0XcK13tOFq3i+rUbvKek68rJRtfAVL/bJuns/H6+wyaMS2ynjlEta9sBlBVR9aBueW0MS QbabiBJFWDYkOgaaCg9KC8zq0OUWmkbUVrHLlgFGZZ6HO02A77R8aDJW5RWpvLM39eCD/K 6HY47ygW/9ntW5SZVV4dbJb9nZrTHVp/ko1fLaDPew3vMo1udQlFG2QW9E+rgOTaPgso+t Rmt5sDZNLSYXHyNuAk7/CBSTH7UrOGBjnLZsZrThtwogdqOK22HU9rTsdg3Gnadldirzuk Ne91Y8di7Jor2n5wvKoH16xXH7teBOOXDB1iiVVG2aittHWOHlaNEw6OcRtsCg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=S0PFi4b4; dmarc=pass (policy=none) header.from=gmail.com; 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" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1701958714; 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=pOPP6ujpTurcBTKK8hElkieRVcScoFgvP4x2UYjS1fE=; b=ezuCDLgXZmjglO3QYdg4kZT4fWoRfzeW3UURcpbJ3+kBzJi74ZIRgNjqQtSxihnGjJVUhY WHSivDJQeYlEn5QXOFJ82yhPMjiIp295m+Kvh52P1WQez7mQt4QT9vgOU63mneqbPcxUQK WMH4G5HpcFWonrty7mbIlKLEVoPZ0Nz5o6c6ZGmL1PaOWb65VduJjWwP8ovps4y0QADLZF AbIWKpafsT4xHmXcySHzqEEj6P7y7IVWiQEMW3HGlNeevC+bJd5BbMjcj4Nc/yuU40Cyfa 1P+aEaWNhvN3daMUAObeMB5hiYW+92kljGtFlA48ukRH10w5Aywl3rwPvixQzQ== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBFCi-0002G8-J3; Thu, 07 Dec 2023 09:18:16 -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 1rBFCg-0002Dg-UW for emacs-orgmode@gnu.org; Thu, 07 Dec 2023 09:18:15 -0500 Received: from mail-ot1-x330.google.com ([2607:f8b0:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBFCf-00016r-4V for emacs-orgmode@gnu.org; Thu, 07 Dec 2023 09:18:14 -0500 Received: by mail-ot1-x330.google.com with SMTP id 46e09a7af769-6d9d4193d94so576303a34.3 for ; Thu, 07 Dec 2023 06:18:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701958690; x=1702563490; darn=gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=pOPP6ujpTurcBTKK8hElkieRVcScoFgvP4x2UYjS1fE=; b=S0PFi4b4pzUWWL3O0sOGIsYeamzq5L391E5kxQi9KI6K9/gMb2eCKCLFf5/6xQHbRz XHcfUOoibFvzKQPeH5BJcszq7F/2RI6lomnqgWKWBhqFYGJ1LumsbXlBUl+BH1dj+ZoF QQhVvHOtND7Ddav47H7M05xrFXshZZ2sqT9+BG6pEZPrS1Gmbuf7jXKxDPXfL/7sluvZ RErbVwjVg90zOHCs9shEFM4uPNnUc8H4tZZcPe2oU1SmmGdUNTQRzSDncrfNCf1iCPhS FZo7MgKOCMSzB5e1bcgCFDAjnQ1loZB4qf0njy8S2DBbZ4WqphWaMcaG9oCRvbPqiMff JS6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701958690; x=1702563490; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pOPP6ujpTurcBTKK8hElkieRVcScoFgvP4x2UYjS1fE=; b=aVd19LOvQ7Kx9+i3ghkHmVci7pR3i1g+8YtMfqS74W6XvV9K4iXekq4BvXEZn2Xf4S T6m56IlwXXMtSjEIGL1sw5Lp19IEQnlxmLPQ00n8OdbXR9zf6drBg9BWMSfmscLw/8c8 EyKQqRsOWwe9Lk7VwdMTTHklSffgxE9vKSM9PEQpxo1LHZk7AfTo2D3D0LHuSuOQgcPd 8uQLHWB2zCZk9f6R2+shDTvmZVcnXNzT03Sfk4e7eNw7q9yc0V1UrednyB4Jk1dJUToz R/UTb+qqjyGi3DWO4va5XEgXwRcb9tceZScBp/s2qxmG3S/gwVXpWrddmYGcEbeDlx4P 4emA== X-Gm-Message-State: AOJu0Yw7CeVhON10KtHoeRGQpbftAswJoPiXCe8Eg/NeGo7d9xdpuAWV 8E8Ks751oi0IV3nAZ7GADf3gL8sNSBLEykyyROI= X-Google-Smtp-Source: AGHT+IE+SwAp7c8NJx4BH0nj98SigjuMOpxlgAEBjCHhQa5+SkyIUQf/EuyH5nMRbV63y35p8KPf30QgadMeEBtsayE= X-Received: by 2002:a05:6870:5586:b0:1fb:4a5:52c0 with SMTP id qj6-20020a056870558600b001fb04a552c0mr3004152oac.37.1701958690347; Thu, 07 Dec 2023 06:18:10 -0800 (PST) MIME-Version: 1.0 References: <87zfyosw8n.fsf@localhost> <87ttovlb1u.fsf@localhost> <878r6647vv.fsf@localhost> In-Reply-To: <878r6647vv.fsf@localhost> From: Liu Hui Date: Thu, 7 Dec 2023 22:17:58 +0800 Message-ID: Subject: Re: [PATCH] Set Python shell in Org edit buffer To: Ihor Radchenko Cc: emacs-orgmode@gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2607:f8b0:4864:20::330; envelope-from=liuhui1610@gmail.com; helo=mail-ot1-x330.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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-Scanner: mx13.migadu.com X-Migadu-Spam-Score: -8.11 X-Spam-Score: -8.11 X-Migadu-Queue-Id: E48CD5970C X-TUID: N0rS61S7DuZq Ihor Radchenko =E4=BA=8E2023=E5=B9=B412=E6=9C=887=E6= =97=A5=E5=91=A8=E5=9B=9B 18:33=E5=86=99=E9=81=93=EF=BC=9A > > +(defun org-babel-edit-prep:python (info) > > + "Set Python shell in Org edit buffer according to INFO." > > + (let ((session (cdr (assq :session (nth 2 info))))) > > + (when (and session (not (string=3D session "none"))) > > + (setq-local python-shell-buffer-name > > + (org-babel-python-without-earmuffs session))))) > > Will this work if Python session does not exist yet? If the specified session does not exist, users have to start the session manually if they want to evaluate code directly in the edit buffer. In fact, python-shell-send-* commands will clearly suggest users using 'run-python' or C-c C-p to create the session in this case. Another choice is to use '(org-babel-python-initiate-session session)' in org-babel-edit-prep:python, like ob-R, to create the session when the specified session does not exist, but I feel it is invasive as users may just want to edit the code.