emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/org 107cbc74a9 2/3: ob-python: Set Python shell in Org


From: ELPA Syncer
Subject: [elpa] externals/org 107cbc74a9 2/3: ob-python: Set Python shell in Org edit buffer
Date: Mon, 29 Jan 2024 09:58:39 -0500 (EST)

branch: externals/org
commit 107cbc74a9c4a51025555864c4895d7415c793f6
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>

    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.
    
    Co-authored-by: Liu Hui <liuhui1610@gmail.com>
    
    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 f4e98d78bd..eb4303cf1f 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 4d7492e2be..2f62d7353d 100644
--- a/lisp/ob-python.el
+++ b/lisp/ob-python.el
@@ -83,6 +83,12 @@ If `org-babel-python-command' is set, then it overrides this 
option."
   :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'."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]