From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.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 ODLwLBXicWX8QgAAG6o9tA:P1 (envelope-from ) for ; Thu, 07 Dec 2023 16:17:42 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id ODLwLBXicWX8QgAAG6o9tA (envelope-from ) for ; Thu, 07 Dec 2023 16:17:41 +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 75B04471CE for ; Thu, 7 Dec 2023 16:17:41 +0100 (CET) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b="i4e9L/CU"; dmarc=pass (policy=none) header.from=posteo.net; 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=1701962261; 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=3zJFmLDzjxPRroWxi10AAJubT5uTuR6Rh7XSZrlJIP4=; b=GKh+Fx6SixHObmDqFdIcAmo0WYCTBcBWJ5y6YlBOLgm8EefF8Kjd3s6FLrB8y7nV7FZbr0 a41qdvTcy/rGFVwoZrI881vAbQaHraAsVSmMukY/3lQLUO1YSwBrLcJ30rjJofGMCGtc4l J7X7h1SAg8+8OLPONoTPEyFlHm4DjOcEFfvIZL11+PISBxB+SgiRVhFhMv9gyI1BPjxq2n PsGYD2QmICHTbSZBOCuvIgdv9xMI87PPAwUN+ufgwbMOizNpLSCZyCLOh9UWz2wqwm/QZR 9lnxUbIE30ci90dX2Bjjlmabhq8AZhDZGamEL8paIyOI9wflNYA89gkAC1i/8Q== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1701962261; a=rsa-sha256; cv=none; b=Rm8lKEtEz5RRJMQxLsE1UquvfYrxw0m5uc1TeNitqwK8D1HQbiHonZnhh/UD3qXRbdRCdB zu/z5hi9/PbKZNuw54IgFNt9SyC2LsWFGk1HfCnA/6mQ1ktT47KIbKyKOokBS/SRp3b+dY Yowe1Gv8LOY2+gAR7hcM0Gdr2EDkMZ7ntZDwL2WcU0V9j9gnTGOIxe/Q8fR+kZWGAWikaT c8TGnnuFExsXz6trPDSEhRdbIR0jffqt/teHSdaZ1hQ/Mkw90keWM6qxDhPxpL2UEUVAAB XUo5wQkv349MKB1TRyJNBFLzzEkc+RjSna5Dugn3bmBJrDnG24SL3vNqMyUThg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b="i4e9L/CU"; dmarc=pass (policy=none) header.from=posteo.net; 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 1rBG7T-0008Me-FD; Thu, 07 Dec 2023 10:16:55 -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 1rBG7O-0008MF-VI for emacs-orgmode@gnu.org; Thu, 07 Dec 2023 10:16:52 -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 1rBG7J-0008H1-IG for emacs-orgmode@gnu.org; Thu, 07 Dec 2023 10:16:50 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id D0D1E240028 for ; Thu, 7 Dec 2023 16:16:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1701962197; bh=ysuhhf/fsgLyALyI+SovbRYrzhmrk3AEMlrar1t8uog=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version: Content-Transfer-Encoding:From; b=i4e9L/CU+MzSNizCvFl0E2ncSpSCskWKu09EoZF9nnKgOnvkW58fEwags/U5eNWnt x/1Gu5TfOZLlMd0ZjfHyrAv7vpV406YoxY0nKPQgH7TsJ6I+3OK5sxtMxe/maPen1c M3Ainxm5GpQjEbgLXDrw+eTmnmQYcybA5AriRRDES/L61hsm0sBk2T7LdI0heaPKa1 0JggNvcbZpWVzVtUxb8L9vzDiXI3umRQ61/MiX6hSaE2kueuJcZZDmHTJyzmbKvxAZ RytX9nQIiofnRpq/D42O8SOZL5xbd3RrfqJN+aRJPg1S4jsPVW8MJ+u+W4pw/eaUuJ 0YPFCnOADefJw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4SmHtF3Ccnz6tvr; Thu, 7 Dec 2023 16:16:37 +0100 (CET) From: Ihor Radchenko To: Liu Hui Cc: emacs-orgmode@gnu.org Subject: Re: [PATCH] Set Python shell in Org edit buffer In-Reply-To: References: <87zfyosw8n.fsf@localhost> <87ttovlb1u.fsf@localhost> <878r6647vv.fsf@localhost> Date: Thu, 07 Dec 2023 15:19:40 +0000 Message-ID: <87bkb2rqer.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-Scanner: mx11.migadu.com X-Migadu-Spam-Score: -9.11 X-Spam-Score: -9.11 X-Migadu-Queue-Id: 75B04471CE X-TUID: 3XYzowUDm4cy 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 > 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? --=20 Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at