emacs-orgmode
[Top][All Lists]
Advanced

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

Re: babel output seems to drop anything before % (in session)


From: Kaushal Modi
Subject: Re: babel output seems to drop anything before % (in session)
Date: Tue, 8 Jun 2021 23:54:17 -0400


On Thu, May 6, 2021 at 7:45 PM Nick Savage <nick@nicksavage.ca> wrote:
So I have a patch written that doesn't completely fix the problem, but
maybe makes enough progress that someone else can figure it out.

The issue is that comint-prompt-regexp is reading the "% " as a prompt,
and taking everyone off before it. I've added another parameter to
org-babel-comint-with-output in the "meta" to pass our own regexp to
replace comint-prompt-regexp, which works except when it doesn't. The
regexp I've added is just "\n" now, so the newline characters are removed.

The tests that Daniele added as a patch don't quite pass though with
this. The issue is that something in the way the output is posted in the
output buffer includes the prompt occasionally is included in a line and
occasionally not. It seems the first time the block of code is executed,
it is included (and therefore needs to be removed) and each other time
it is not, so it is only the first time that it is run is not working
properly.

This is obviously way too fragile to actually merge, but I was hoping
the work I've done so far is enough to help someone else make progress.
I'll probably take another stab at this tomorrow (since it's bugging
me), but thought I'd share what I have for now.

Cheers,
Nick

Thanks! I tried out your patch and it does fix the truncation of results output. Though, it retains the shell prompt in the first eval block and removes it only from the second eval block onwards.

Here's a MWE:

=====
#+property: header-args:shell :exports both :results output :session *ob-shell-session-issue*

#+begin_src shell
echo "1 > 0"
#+end_src

#+RESULTS:
:
: sh-4.2$ 1 > 0

#+begin_src shell
echo "1 > 0"
#+end_src

#+RESULTS:
:
: 1 > 0

#+begin_src shell
echo "1 > 0"
#+end_src

#+RESULTS:
:
: 1 > 0

#+begin_src shell
echo "1 > 0"
#+end_src

#+RESULTS:
:
: 1 > 0
=====

reply via email to

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