[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [BUG] shell sessions started outside of Babel broken
From: |
Ihor Radchenko |
Subject: |
Re: [BUG] shell sessions started outside of Babel broken |
Date: |
Wed, 22 Feb 2023 10:38:43 +0000 |
Jack Kamm <jackkamm@tatersworld.org> writes:
> Ihor Radchenko <yantar92@posteo.net> writes:
>
>> What is confusing is that `org-babel-execute-src-block' does not use
>> generic `org-babel-initiate-session'.
>
> I usually find myself confused whenever I am trying to remember
> where org-babel-LANG-initiate-session is run and what it's doing...
AFAIU, org-babel-LANG-initiate-session is ran the first time the session
is started. Its job is setting the comint to work with babel.
org-babel-LANG-prep-session is ran before a code block is executed
within a session. Its purpose is applying header args (like variable
bindings) and performing other immediate preparations to actually
execute the src block.
> In ob-shell's case, when I read the lisp code it seems like
> org-babel-prompt-command would get called every time
> org-babel-execute:shell runs (via org-babel-sh-initiate-session).
No. `org-babel-sh-initiate-session' has
(or (org-babel-comint-buffer-livep session)
...)
So, it does nothing when the session buffer is already present.
> But that's not how the behavior seems when I use it, e.g. if using a
> M-x shell session, the prompt isn't changed after executing a src
> block.
Because `org-babel-comint-buffer-livep' will return t for a buffer
created by M-x shell. It may or may not be a bug.
We can, for example, make `org-babel-comint-buffer-livep' return nil
unless a special buffer-local indicator is set upon evaluating
`org-babel-sh-initiate-session'.
However, it may be tricky in general case because what we have to do
when creating a new session buffer may or may not be the same with what
we have to do when M-x shell buffer exists already.
>> We may, however, allow an extra header arg to set the prompt regexp
>> manually. Would it make sense?
>
> It does feel a little confusing, but I don't have any better ideas at
> the moment.
>
> To clarify -- would the header arg be for setting
> comint-prompt-regexp, org-babel-prompt-command, both, or something
> else?
I imagine that the header arg will be setting comint-prompt-regexp.
--
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] Async evaluation in ob-shell, (continued)
- Re: [PATCH] Async evaluation in ob-shell, jackkamm, 2023/02/11
- Re: [PATCH] Async evaluation in ob-shell, Matt, 2023/02/12
- Re: [PATCH] Async evaluation in ob-shell, Jack Kamm, 2023/02/12
- [BUG] shell sessions started outside of Babel broken, Matt, 2023/02/13
- Re: [BUG] shell sessions started outside of Babel broken, Jack Kamm, 2023/02/15
- Re: [BUG] shell sessions started outside of Babel broken, Ihor Radchenko, 2023/02/16
- Re: [BUG] shell sessions started outside of Babel broken, Jack Kamm, 2023/02/19
- Re: [BUG] shell sessions started outside of Babel broken, Ihor Radchenko, 2023/02/20
- Re: [BUG] shell sessions started outside of Babel broken, Jack Kamm, 2023/02/21
- Re: [BUG] shell sessions started outside of Babel broken,
Ihor Radchenko <=
- [BUG] conda doesn't work in ob-shell sessions, Matt, 2023/02/13
- Re: [BUG] conda doesn't work in ob-shell sessions, Jack Kamm, 2023/02/15