Re: [PATCH] prevent mangled output in ob-J by allowing sit-time duration to be customized

2020-09-05 Thread Bastien
Hi Joseph,

Joseph Novakovich  writes:

> Sure, I'd be happy to help!

Thanks!  I added you as the ob-J.el maintainer in 0e580d169.

-- 
 Bastien



Re: [PATCH] prevent mangled output in ob-J by allowing sit-time duration to be customized

2020-09-04 Thread Joseph Novakovich
Hello Bastien,

Sure, I'd be happy to help!

Joseph

On 9/4/20, Bastien  wrote:
> Hi Joseph,
>
> applied on maint (as 7d8247410), thanks.
>
> Would you like to take over ob-J.el maintainance?
>
> --
>  Bastien
>



Re: [PATCH] prevent mangled output in ob-J by allowing sit-time duration to be customized

2020-09-04 Thread Bastien
Hi Joseph,

applied on maint (as 7d8247410), thanks.

Would you like to take over ob-J.el maintainance?

-- 
 Bastien



[PATCH] prevent mangled output in ob-J by allowing sit-time duration to be customized

2020-09-02 Thread Joseph Novakovich
Hello!

The problem is that we read the contents of the output after 0.1
seconds, which, for expensive computations, results in the mangling of
output.  Output from expensive computations gets propagated down to
subsequent code-blocks' outputs, producing a horrible mess.

Joseph
From ee08934a649b4a6c14d8b2ee1c24f849621284a9 Mon Sep 17 00:00:00 2001
From: Joseph Novakovich 
Date: Mon, 31 Aug 2020 10:14:15 -0400
Subject: [PATCH] ob-J.el: Add ability to customize sit duration

* lisp/ob-J.el (org-babel-execute:J, org-babel-J-eval-string): Add
customizability.

(org-babel-execute:J): Lookup optional parameter `:sit' to allow one
to wait for a specified amount of time before grabbing the output of
the J subprocess.  Pass this specified value or the previous default
of .1 to `org-babel-J-eval-string'.
(org-babel-eval-string): Pass new argument `sit-time' to `sit-for'
before grabbing output.

The problem is that we read the contents of the output after 0.1
seconds, which, for expensive computations, results in the mangling of
output.  Output from expensive computations gets propagated down to
subsequent code-blocks' outputs, producing a horrible mess.

TINYCHANGE
---
 lisp/ob-J.el | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lisp/ob-J.el b/lisp/ob-J.el
index c0145211b..f26e82ed9 100644
--- a/lisp/ob-J.el
+++ b/lisp/ob-J.el
@@ -76,6 +76,8 @@ This function is called by `org-babel-execute-src-block'."
   (message "executing J source code block")
   (let* ((processed-params (org-babel-process-params params))
 	 (sessionp (cdr (assq :session params)))
+	 (sit-time (let ((sit (assq :sit params)))
+		 (if sit (cdr sit) .1)))
  (full-body (org-babel-expand-body:J
  body params processed-params))
 	 (tmp-script-file (org-babel-temp-file "J-src")))
@@ -86,9 +88,9 @@ This function is called by `org-babel-execute-src-block'."
 	   (with-temp-file tmp-script-file
 	 (insert full-body))
 	   (org-babel-eval (format "%s < %s" org-babel-J-command tmp-script-file) ""))
-   (org-babel-J-eval-string full-body)
+   (org-babel-J-eval-string full-body sit-time)
 
-(defun org-babel-J-eval-string (str)
+(defun org-babel-J-eval-string (str sit-time)
   "Sends STR to the `j-console-cmd' session and executes it."
   (let ((session (j-console-ensure-session)))
 (with-current-buffer (process-buffer session)
@@ -96,7 +98,7 @@ This function is called by `org-babel-execute-src-block'."
   (insert (format "\n%s\n" str))
   (let ((beg (point)))
 	(comint-send-input)
-	(sit-for .1)
+	(sit-for sit-time)
 	(buffer-substring-no-properties
 	 beg (point-max))
 
-- 
2.28.0