emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [PATCH] Async evaluation in ob-shell


From: Ihor Radchenko
Subject: Re: [PATCH] Async evaluation in ob-shell
Date: Sat, 18 Mar 2023 10:48:27 +0000

Matt <matt@excalamus.com> writes:

> Way back in https://list.orgmode.org/87sfeyc7qr.fsf@localhost/, we had this 
> exchange:
>
>  ---- On Mon, 20 Feb 2023 11:24:52 +0000  Ihor Radchenko  wrote --- 
>> Matt <matt@excalamus.com> writes:
>>
>> > +(defun ob-shell-async-chunk-callback (string)
>> > +  "Filter applied to results before insertion.
>> > +See `org-babel-comint-async-chunk-callback'."
>> > +  (replace-regexp-in-string (concat org-babel-sh-prompt "*") "" string))
>>
>  > Why not using `comint-prompt-regexp'?
>
> I switched out `org-babel-sh-prompt'  with `comint-prompt-regexp' so that the 
> expression looks like:
>
> +(defun ob-shell-async-chunk-callback (string)
> +  "Filter applied to results before insertion.
> +See `org-babel-comint-async-chunk-callback'."
> +  (replace-regexp-in-string comint-prompt-regexp "" string))
>
> This causes the new test `test-ob-shell/session-async-evaluation' to fail, as 
> you pointed out: https://list.orgmode.org/87bkl96g6e.fsf@localhost/
>
> The test fails when we switch out the prompt in the callback because 
> `comint-prompt-regexp' has two spaces in it.  The second space causes a 
> prompt to not be filtered (by the callback).  The output becomes ": 1\n: 2\n: 
> org_babel_sh_prompt>\n" instead of  ": 1\n: 2\n" .  This looks like a bug in 
> the `comint-prompt-regexp''.

No, this looks like a bug in comint.el. ob-shell correctly sets
PROMPT to be org-babel-sh-prompt, which is "org_babel_sh_prompt> ", with
space! The fact that the comint output does not, in fact, contain space
is wrong.

We can probably remove the space in org-babel-sh-prompt to work around
this (likely, Emacs) bug.

> It could be that `test-ob-shell/session-async-evaluation' doesn't test 
> correctly, but it looks right to me (I could certainly be mistaken).  
> Therefore, I see only two options to fix it: remove a space from the concat 
> expression (which I did in my latest patch) or remove a space from 
> `org-babel-sh-prompt'.

Removing space from the concat expression in plain wrong, as Max
explained. 

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