emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [PATCH] Set Python shell in Org edit buffer


From: Liu Hui
Subject: Re: [PATCH] Set Python shell in Org edit buffer
Date: Thu, 7 Dec 2023 22:17:58 +0800

Ihor Radchenko <yantar92@posteo.net> 于2023年12月7日周四 18:33写道:

> > +(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= 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.



reply via email to

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