Jack Kamm writes:
>> 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.
>
> Thanks Ihor. I tested the patch and it seems to
Ihor Radchenko writes:
> Applied, onto main, fixing the oversight in
> org-src-associate-babel-session (now, it does not require session
> running).
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=319563cef
>
> Since ESS already released a new version with my patch for ESS
Ihor Radchenko writes:
> Liu Hui 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
>> Date: Tue, 5 Dec 2023 11:40:38 +0800
>> Subject: [PATCH] Set Python shell in Org
Liu Hui 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
> Date: Tue, 5 Dec 2023 11:40:38 +0800
> Subject: [PATCH] Set Python shell in Org edit buffer
Now, after amending
Jack Kamm writes:
> Ihor Radchenko writes:
>
>>> My concern is that advising `ess-request-a-process' would cause
>>> maintenance burden on ob-R. It would require some knowledge about the
>>> ESS internals to maintain properly.
>>
>> Not really. I only meant writing an advice iff our request is
Ihor Radchenko writes:
>> My concern is that advising `ess-request-a-process' would cause
>> maintenance burden on ob-R. It would require some knowledge about the
>> ESS internals to maintain properly.
>
> Not really. I only meant writing an advice iff our request is accepted
> by ESS devs.
Jack Kamm writes:
>>> Currently I lean towards a combination of #1 and #3, but am not sure,
>>> and happy to go with whatever you think is best.
>>
>> We can also advice `ess-request-a-process' as a temporary workaround.
>
> My concern is that advising `ess-request-a-process' would cause
>
Ihor Radchenko writes:
>> It's annoying there's no way to tell ESS to start new session instead of
>> evaluating in existing one. Here are a few alternatives we could
>> consider to deal with this:
>>
>> 1. Change the worg/ORG-NEWS, to suggest users make sure the session
>> exists (either by
Ihor Radchenko writes:
> Now, the question is what to do with the existing implementation of
> `org-src-associate-babel-session'. It only runs
> org-babel--associate-session when
>
> (and session (not (string= session "none"))
>(org-babel-comint-buffer-livep session)
>(let ((f
Jack Kamm writes:
>> ---
>> etc/ORG-NEWS | 11 +++
>> lisp/ob-R.el | 20 ++--
>> lisp/ob-julia.el | 16 +---
>> 3 files changed, 26 insertions(+), 21 deletions(-)
>
> Not sure if you are doing this in a separate commit, but you also need
> to make the
Ihor Radchenko writes:
> See the attached tentative patch.
Thanks!
> ---
> etc/ORG-NEWS | 11 +++
> lisp/ob-R.el | 20 ++--
> lisp/ob-julia.el | 16 +---
> 3 files changed, 26 insertions(+), 21 deletions(-)
Not sure if you are doing this in a
Jack Kamm writes:
>> IMHO, it might be enough to adjust org-babel-R-associate-session as the
>> following
>...
> Otherwise, this looks good to me.
See the attached tentative patch.
>From f6fd65f8e80b6efa0a5db084a9c9f94d46e67515 Mon Sep 17 00:00:00 2001
Message-ID:
From: Ihor Radchenko
Date:
Jack Kamm writes:
> Also it seems unnecessary to call `ess-make-buffer-current', as it's
> already called by `ess-force-buffer-current' (which is called by
> `ess-eval-region'). Though it doesn't hurt to call it, either.
On reflection, maybe it's better to keep
`ess-make-buffer-current'. Maybe
Ihor Radchenko writes:
> Note that I proposed to remove auto-starting session completely, which
> is in odds to what you propose below.
Sure, I'm fine with that -- it seems like a reasonable change.
> IMHO, it might be enough to adjust org-babel-R-associate-session as the
> following
>
>
Jack Kamm writes:
> Ihor Radchenko writes:
>
>> So, a good option could be
>> (1) removing (org-babel-comint-buffer-livep session) from
>> `org-src-associate-babel-session'
>> (2) Removing `org-babel-edit-prep:R'
>>
>> With the above, we can use `org-babel-python-associate-session'
>
>
On Sunday, January 7th, 2024 at 14:06, Jack Kamm wrote:
> It looks like ob-R and ob-julia are the only languages that start
> sessions on edit (based on grepping for "edit-prep" and
> "associate-session").
>
> I think their behavior is peculiar enough to have an ob-R/julia-specific
> option on
Ihor Radchenko writes:
> So, a good option could be
> (1) removing (org-babel-comint-buffer-livep session) from
> `org-src-associate-babel-session'
> (2) Removing `org-babel-edit-prep:R'
>
> With the above, we can use `org-babel-python-associate-session'
Sounds good to me.
> I imagine that
Jack Kamm writes:
>> Now, the question is what to do with the existing implementation of
>> `org-src-associate-babel-session'. It only runs
>> org-babel--associate-session when
>>
>> (and session (not (string= session "none"))
>> (org-babel-comint-buffer-livep session)
>> (let ((f
Ihor Radchenko writes:
> Now, the question is what to do with the existing implementation of
> `org-src-associate-babel-session'. It only runs
> org-babel--associate-session when
>
> (and session (not (string= session "none"))
>(org-babel-comint-buffer-livep session)
>(let ((f
Jack Kamm writes:
>> python.el is convenient as it allows setting the session buffer name in
>> advance via buffer-local variable. Then, all the normal python-mode
>> commands, including `run-python' or `python-shell-send-region' will work
>> as expected. However, other babel backends like ob-R
Jack Kamm writes:
>> Because I am still thinking about the idea with global customization and
>> `org-babel--associate-session'.
>
> It's great that you're thinking about this -- it would be nice to have
> better consistency between ob-R, ob-python, etc, and to have better
> configurability on
Ihor Radchenko writes:
>> I agree that `python-shell-buffer-name' should be set according to the
>> :session header, and that Liu's patch fixes a problem in ob-python.
>>
>> Is there any objection if I go ahead and apply it?
>
> Because I am still thinking about the idea with global
Ihor Radchenko writes:
> python.el is convenient as it allows setting the session buffer name in
> advance via buffer-local variable. Then, all the normal python-mode
> commands, including `run-python' or `python-shell-send-region' will work
> as expected. However, other babel backends like ob-R
Jack Kamm writes:
>> What might be more robust is to provide an explicit "start session
>> from Org Src buffer" command for ob-python and re-bind `run-python' to
>> this command in Org Src buffers.
>
> We could refactor `org-babel-python-initiate-session-by-key' to call a
> separate
Jack Kamm 于2023年12月30日周六 06:20写道:
>
> Liu Hui writes:
>
> > But it is indeed possible that two sessions are inconsistent, if users
> > intend to have different org-babel-python-command and
> > python-shell-interpreter, which are used by
> > `org-babel-python-initiate-session' and `run-python',
Liu Hui writes:
> But it is indeed possible that two sessions are inconsistent, if users
> intend to have different org-babel-python-command and
> python-shell-interpreter, which are used by
> `org-babel-python-initiate-session' and `run-python', respectively.
I have just proposed this patch,
Ihor Radchenko writes:
> As long as it remains undocumented, we can break this in future (maybe
> years from now, but still...).
Fair enough, I've had to fix this feature from time to time due to
breakage in the past.
I just pushed d0d838b02 which should hopefully prevent future breakage:
Jack Kamm writes:
> Ihor Radchenko writes:
>
>> I think we have a misunderstanding here.
>>
>> Didn't we just discuss that C-c C-p in python is not equivalent to
>> `org-babel-python-initiate-session'?
>
> ob-python works fine with sessions started externally by `run-python'.
> And I have
Jack Kamm writes:
> Liu Hui writes:
>
>> I just want to set 'python-shell-buffer-name' in the edit buffer
>> according to the :session header and don't need to start the session
>> even if the session doesn't exist.
>
> Sorry that I missed this thread.
>
> I agree that
Ihor Radchenko writes:
> I think we have a misunderstanding here.
>
> Didn't we just discuss that C-c C-p in python is not equivalent to
> `org-babel-python-initiate-session'?
ob-python works fine with sessions started externally by `run-python'.
And I have preserved this functionality, as I
Liu Hui writes:
> I just want to set 'python-shell-buffer-name' in the edit buffer
> according to the :session header and don't need to start the session
> even if the session doesn't exist.
Sorry that I missed this thread.
I agree that `python-shell-buffer-name' should be set according to the
Ihor Radchenko 于2023年12月9日周六 18:29写道:
>
> Liu Hui writes:
>
> >> 2. Check the new variable and attempt to run
> >>`org-babel--associate-session' in org-src-mode definition.
> >
> > I think associating the edit buffer with some session doesn't require
> > starting the session, which is at
Liu Hui writes:
>> 2. Check the new variable and attempt to run
>>`org-babel--associate-session' in org-src-mode definition.
>
> I think associating the edit buffer with some session doesn't require
> starting the session, which is at least feasible for ob-python. When
> editing python src
Ihor Radchenko 于2023年12月8日周五 21:06写道:
>
> Liu Hui writes:
>
> >> What about displaying a yes/no query about starting a new session when
> >> there is none?
> >
> > I think it is OK. I can add an option to allow users to disable the
> > query. WDYT?
>
> I now have second thoughts about obsoleting
Liu Hui writes:
>> What about displaying a yes/no query about starting a new session when
>> there is none?
>
> I think it is OK. I can add an option to allow users to disable the
> query. WDYT?
I now have second thoughts about obsoleting
org-babel--associate-session.
If we need a customization
Ihor Radchenko 于2023年12月7日周四 23:16写道:
>
> Liu Hui writes:
>
> > Ihor Radchenko 于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)
> >> > +
Liu Hui writes:
> Ihor Radchenko 于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")))
>> >
Ihor Radchenko 于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
Liu Hui writes:
>> May you also mention what this means in practice? Like that users can
>> now send region for evaluation right from the edit src buffer?
>> Otherwise, it may not be very clear for ordinary users what this feature
>> adds.
>
> Yes, I have updated the text and you're welcome to
Ihor Radchenko 于2023年12月6日周三 21:20写道:
>
> Liu Hui writes:
>
> >> Makes sense.
> >> I think we may drop a note about this new feature in ORG-NEWS.
> >
> > Thanks, I have added it in the attached patch.
> > ...
> > +When editing a Python src block, the editing buffer is now associated
> > +with
Liu Hui writes:
>> Makes sense.
>> I think we may drop a note about this new feature in ORG-NEWS.
>
> Thanks, I have added it in the attached patch.
> ...
> +When editing a Python src block, the editing buffer is now associated
> +with the Python shell specified by the src block's ~:session~
Ihor Radchenko 于2023年12月5日周二 19:48写道:
>
> Liu Hui writes:
>
> > When editing python src block using C-c ', the python shell is not set
> > in Org edit buffer according to the :session header argument of the
> > block. Consequently, commands such as python-shell-send-region cannot
> > send python
Liu Hui writes:
> When editing python src block using C-c ', the python shell is not set
> in Org edit buffer according to the :session header argument of the
> block. Consequently, commands such as python-shell-send-region cannot
> send python code to the correct python process. To address
43 matches
Mail list logo