[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Set Python shell in Org edit buffer
From: |
Ihor Radchenko |
Subject: |
Re: [PATCH] Set Python shell in Org edit buffer |
Date: |
Sun, 28 Jan 2024 20:35:33 +0000 |
Liu Hui <liuhui1610@gmail.com> writes:
> Yes, I have updated the text and you're welcome to improve it. Thanks!
> From c503b2ed5116e2abae25459b09abc919074ac54a Mon Sep 17 00:00:00 2001
> From: Liu Hui <liuhui1610@gmail.com>
> Date: Tue, 5 Dec 2023 11:40:38 +0800
> Subject: [PATCH] Set Python shell in Org edit buffer
Now, after amending `org-src-associate-babel-session' to execute even
when no session is active, we can use
`org-babel-python-associate-session'.
Attaching tentative patch that should be equivalent to yours.
>From f8a748aee619f9fa3f9104321b33212447e7f952 Mon Sep 17 00:00:00 2001
Message-ID:
<f8a748aee619f9fa3f9104321b33212447e7f952.1706473998.git.yantar92@posteo.net>
From: Ihor Radchenko <yantar92@posteo.net>
Date: Sun, 28 Jan 2024 21:29:25 +0100
Subject: [PATCH] ob-python: Set Python shell in Org edit buffer
* lisp/ob-python.el (org-babel-python-associate-session): New function
setting `python-shell-buffer-name' in *Org Src* buffer according to
source block's :session parameter. This function will be triggered by
`org-src-associate-babel-session'.
* etc/ORG-NEWS (ob-python now sets ~python-shell-buffer-name~ in Org
edit buffers): Announce the change.
Link:
https://orgmode.org/list/CAOQTW-MdC=jiGf+3bEVtfww+izSZix7csBJ+mZ4eZ2BQHDR42w@mail.gmail.com
---
etc/ORG-NEWS | 7 +++++++
lisp/ob-python.el | 6 ++++++
2 files changed, 13 insertions(+)
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index f9c916a9d..2163f00e1 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -13,6 +13,13 @@ Please send Org bug reports to mailto:emacs-orgmode@gnu.org.
* Version 9.7 (not released yet)
** Important announcements and breaking changes
+*** ob-python now sets ~python-shell-buffer-name~ in Org edit buffers
+
+When editing a Python src block, the editing buffer is now associated
+with the Python shell specified by the src block's ~:session~ header,
+which means users can now send code directly from the edit buffer,
+e.g., using ~C-c C-c~, to the session specified in the Org buffer.
+
*** ~org-edit-special~ no longer force-starts session in R and Julia source
blocks
Previously, when R/Julia source block had =:session= header argument
diff --git a/lisp/ob-python.el b/lisp/ob-python.el
index 4d7492e2b..2f62d7353 100644
--- a/lisp/ob-python.el
+++ b/lisp/ob-python.el
@@ -83,6 +83,12 @@ (defcustom org-babel-python-None-to 'hline
:package-version '(Org . "8.0")
:type 'symbol)
+(defun org-babel-python-associate-session (session)
+ "Associate Python code buffer with an Python session.
+Make SESSION without earmuffs be the Python buffer name."
+ (setq-local python-shell-buffer-name
+ (org-babel-python-without-earmuffs session)))
+
(defun org-babel-execute:python (body params)
"Execute Python BODY according to PARAMS.
This function is called by `org-babel-execute-src-block'."
--
2.43.0
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
- Re: [PATCH] Add buffer-local setting to request specific ESS process/session name (was: [PATCH] Set Python shell in Org edit buffer), (continued)
- Re: [PATCH] Add buffer-local setting to request specific ESS process/session name (was: [PATCH] Set Python shell in Org edit buffer), Ihor Radchenko, 2024/01/25
- Re: [PATCH] Set Python shell in Org edit buffer, Ihor Radchenko, 2024/01/10
- Re: [PATCH] Set Python shell in Org edit buffer, Jack Kamm, 2024/01/14
- Re: [PATCH] Set Python shell in Org edit buffer, Ihor Radchenko, 2024/01/16
- Re: [PATCH] Set Python shell in Org edit buffer, Jack Kamm, 2024/01/16
- Re: [PATCH] Set Python shell in Org edit buffer, Ihor Radchenko, 2024/01/28
- Re: [PATCH] Set Python shell in Org edit buffer, Jack Kamm, 2024/01/28
Re: [PATCH] Set Python shell in Org edit buffer, Christopher M. Miles, 2024/01/11
Re: [PATCH] Set Python shell in Org edit buffer, Ihor Radchenko, 2024/01/05
Re: [PATCH] Set Python shell in Org edit buffer,
Ihor Radchenko <=