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: Ihor Radchenko
Subject: Re: [PATCH] Set Python shell in Org edit buffer
Date: Thu, 07 Dec 2023 15:19:40 +0000

Liu Hui <liuhui1610@gmail.com> writes:

> 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.

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?

-- 
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>



reply via email to

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