astahlman / ob-async

Asynchronous src_block execution for org-babel
343 stars 32 forks source link

Different end-of-line characters shown when using :async #18

Closed PeterMosmans closed 6 years ago

PeterMosmans commented 6 years ago

Hi,

I use ob-asycn, great package: thanks! I'm using Emacs 27.0.50 (git) on Windows x64. When using :async, the output shows ^M (carriage return / line feed) after each output line. Without :async, the output is correct (no carriage returns, just line feeds)

Example with :async:

   #+BEGIN_SRC sh
   echo $SHELL
   #+END_SRC

   #+RESULTS:
   :RESULTS:
   /usr/bin/zsh

   :END:

Note that the ^M character is replaced here by two blank lines: Emacs shows ^M in the Org mode file.

Example without :async:

   #+BEGIN_SRC sh
   echo $SHELL
   #+END_SRC

   #+RESULTS:
   :RESULTS:
   /usr/bin/zsh
   :END:

Cheers,

Peter

astahlman commented 6 years ago

Hmmm, strange. Can you execute troubleshooting.org and paste the contents here, or in a gist? That will help us rule out some sort of version inconsistency in Emacs/org-mode between the parent and child Emacs processes.

PeterMosmans commented 6 years ago

Hi @astahlman thanks for troubleshooting (so far :wink:) - see https://gist.github.com/PeterMosmans/7736f1d004942dd116c1ff342654ab73 (I think that will include the relevant parts, let me know if you want me to post more)

astahlman commented 6 years ago

Interesting. Did you try turning on async debugging? (The section right after the output you posted.)

Let's also try eliminating org-babel from the equation - what does this print to your *Messages* buffer?

(require 'async)
(async-start
  `(lambda () "Test string\r\nI'm on a Windows-style newline\nI'm on a Unix-style newline")
  `(lambda (result) (message "%s" result)))
PeterMosmans commented 6 years ago

Yeah, I tried all steps in troubleshooting.org. Results from your steps:

async
#<process emacs>
Test string

I'm on a Windows-style newline

I'm on a Unix-style newline

..and with debug on...

t
Transmitting sexp {{{'(lambda nil "Test string
\nI'm on a Windows-style newline\nI'm on a Unix-style newline")
}}}
astahlman commented 6 years ago

I believe this is a result of the way the emacs-async library handles encoding of the messages passed between the parent and child Emacs processes. See details in https://github.com/jwiegley/emacs-async/issues/93.

astahlman commented 6 years ago

The upstream (potential) fix is merged - can you try upgrading to the latest version of async (20180103.2312) and see if the problem persists?

PeterMosmans commented 6 years ago

Superb @astahlman , it works like a charm. Thank you so much for your time and your tenacity, much appreciated :thumbsup:

..and of course a happy 2018, that all of your goals will be attained :wink:

Peter

astahlman commented 6 years ago

Excellent, glad it's working for you!