From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id QMeoCfjtcmWk/AAAauVa8A:P1 (envelope-from ) for ; Fri, 08 Dec 2023 11:20:40 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id QMeoCfjtcmWk/AAAauVa8A (envelope-from ) for ; Fri, 08 Dec 2023 11:20:40 +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 B90A739E6B for ; Fri, 8 Dec 2023 11:20:39 +0100 (CET) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=atc6cIku; 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=1702030840; 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=ru7yPtq4m62QGPou6MCvNmRlPXcvkj8jacPA4LyKQTc=; b=Q0pBEGMpqWCgApJImW9FzsJttfk9OuJXIaxPFt1WEXQpx15gumL34UGA8ufuxJUXpRtDwp b54fFJlZ8NKK7GeDn2h8yBJmsHU1LqZJmmkbRuPpIilaoIHS7gGuWNo7WzG6C+d/RDSy14 nQV42M+WljX9BJKFAoqhvtWVa97a16tHLcblxozUBe3c+UliID5Rq/pcb+C3ZlWJLsMW1m AUdMtog9Xh2/D4liWZ2e1fjpnERuwsc9qkOsnA5UFQOhO1nC1CcXx/tKlKASuyTGsJlPU5 /SHy49vMxXRjLwQipU/ywWW0wxBEmvRfh3dgIE2C3ldV4peyxz6MQSbOVqKgUA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1702030840; a=rsa-sha256; cv=none; b=VP4fm5Pke2fb6bgvnUBk86MURwjCaeJKUjvcGl1NHM7nV4IT1ocSnk+83X5TZwZ50PE76D Hkh2xgdO/KLJTa2IPutaycf9HsDxg7Hu8sdlLsOewRneAE+MQlJoBSyN6sFigWXOSxFdN5 CsNYdtgSjSD9kVn2Hi24obkn9JSRov2TJUcp8Cm5y/tkeTZ8CH+RgCuQfsMxccDaFJKU/N sohecyGL8BP/IOTQJE69jStsf6z7r3Y/uveb7xDicWBxxLiPgfnk2DP+AvEFZnbvSZrTX9 3DvuuKbJVBC8ZwAWCbLBAqojGJynfBPx7T6kBajjFwTjM8r2nRnlHRhTJe1OlQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=atc6cIku; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBXxQ-0002Cn-TC; Fri, 08 Dec 2023 05:19:44 -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 1rBXxO-0002CO-TW for emacs-orgmode@gnu.org; Fri, 08 Dec 2023 05:19:42 -0500 Received: from mail-vs1-xe31.google.com ([2607:f8b0:4864:20::e31]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBXxN-0007It-94 for emacs-orgmode@gnu.org; Fri, 08 Dec 2023 05:19:42 -0500 Received: by mail-vs1-xe31.google.com with SMTP id ada2fe7eead31-4647403bd3bso590721137.0 for ; Fri, 08 Dec 2023 02:19:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702030779; x=1702635579; 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=ru7yPtq4m62QGPou6MCvNmRlPXcvkj8jacPA4LyKQTc=; b=atc6cIkuFCqvgs8RLJQvTmhFvJe0zrZQ3QEuLDyX/Wr3bFwwOEvC6hac/EEAoE5Afm 5dudHjyCCZYHWOES62CzBVr+8nMQMqmM2AK9L4tch2blxkTpgStMzaH5T6IUTAtOI2t8 EHs7zjA5zaFeQ+sQb4LLCZKk7dn7EDJW0oauHXwnx/jAlTshrSq5MAuAAgU9n5P7HSyy wrtYnJbYTk0sARiXXvZopSZSAnmq5a+ucNCBcUQwXqKYSzO99uzEdLSSvhi1e6yYKwhZ UnxKniRwojxnUSRPyiSxckh0fgchMiaRR2QvqFLw+TFKdeQW+WgwaeCLJzMSpfxk3r6t pp2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702030779; x=1702635579; 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=ru7yPtq4m62QGPou6MCvNmRlPXcvkj8jacPA4LyKQTc=; b=Oe6q6MSi97wcpuf/VM6TnsdAWaeIZos95iHXvVJIjsJU8v/xBnvsfM+fhfDFueoOyU tfgN7bdAMvIfLs4wBKXU1KRsI6vPuP8WwjifY9aNDTPSZKuPz/8vNe/hllY2N5aYL3NV d5TuATDm4z9QZbkcIIB4azjx0xetEr0zAehTKhBhXf+B6FbUXQG2HfLsybKdjEFmBwhK EcisQkLp6XupRrxgXfyadrX4MDkrWfDzMZu1KVblxlg3UrUaesAW+nKwR1k3/wOAGXIF 8y7RnZrwpG/tgm7n10nU9il3dCa+ckxz1jBuQC/gT35leO/SrL66WzWnh5QuuAxr+LeK JltQ== X-Gm-Message-State: AOJu0Yx7yVMhq7mgCwhTXchtYVfLuCMRIOIoPhgcXE2POWTEEsup8imw dHbj39SOFu46bDleb3KsO9qUw6O4bc4cpuM82jTWseXUeEZnPA== X-Google-Smtp-Source: AGHT+IEamtmeamlecdPEJaSpMkVNxTUPbgv9SUb0nBelOjJUFw5XiXqoaTXbWsOj2B+Ut9dEqfIXlX+JUfz1nZiA0Jc= X-Received: by 2002:a67:e9cf:0:b0:464:827f:75aa with SMTP id q15-20020a67e9cf000000b00464827f75aamr4005665vso.18.1702030779334; Fri, 08 Dec 2023 02:19:39 -0800 (PST) MIME-Version: 1.0 References: <87zfyosw8n.fsf@localhost> <87ttovlb1u.fsf@localhost> <878r6647vv.fsf@localhost> <87bkb2rqer.fsf@localhost> In-Reply-To: <87bkb2rqer.fsf@localhost> From: Liu Hui Date: Fri, 8 Dec 2023 18:19:28 +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::e31; envelope-from=liuhui1610@gmail.com; helo=mail-vs1-xe31.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: mx11.migadu.com X-Migadu-Spam-Score: -9.46 X-Spam-Score: -9.46 X-Migadu-Queue-Id: B90A739E6B X-TUID: hBIsc2Yuyuqm Ihor Radchenko =E4=BA=8E2023=E5=B9=B412=E6=9C=887=E6= =97=A5=E5=91=A8=E5=9B=9B 23:16=E5=86=99=E9=81=93=EF=BC=9A > > Liu Hui writes: > > > 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. > > I am afraid that manually starting a python session with `run-python' > will be misleading. Look at how much > `org-babel-python-initiate-session-by-key' does. If users instead start > the session with `run-python' they may get inconsistent results ob-python has good support for using the existing session that created by 'run-python', which contributes to a large part of org-babel-python-initiate-session-by-key. It is common for users to start a ob-python session with `run-python', even in the edit buffer. But it is indeed possible that two sessions are inconsistent, if users intend to have different org-babel-python-command and python-shell-interpreter, which are used by `org-babel-python-initiate-session' and `run-python', respectively. > > 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. > > What about displaying a yes/no query about starting a new session when > there is none? I think it is OK. I can add an option to allow users to disable the query. WDYT?