emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] [PATCH] New header parameter :show-process for Org-babel-clojure


From: Frederick Giasson
Subject: Re: [O] [PATCH] New header parameter :show-process for Org-babel-clojure
Date: Thu, 10 Nov 2016 12:20:43 -0500
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:50.0) Gecko/20100101 Thunderbird/50.0

Hi Nicolas,

I noticed that you included some of my previous fixes in
Org-babel-clojure, so here are the latest work I did. I updated it to
work with the latest code on Git. I did two things with these fixes:


   (1) I better handle any possible error or exceptions that may be
raised by nREPL by displaying any errors in the RESULTS section

   (2) I added a new header option called ":show-process" which create
a new window/buffer to display anything that is outputted by the
Clojure code in the code block.


In the past, I did refer to this as ":async", but as we discussed at
that time, it really was not async. So I changed the naming of this
new feature to remove this ambiguity.
OK.

In any case, I did update the worg documentation accordingly too.

Finally I updated ORG-NEWS in the 9.1 section.
I think you can merge patch 2 and 3. ORG-NEWS updates usually do not
require their own

See the patch files attached to this email.
Thank you. Some nit-picks follow.

Subject: [PATCH 1/2] Better error handling with nREPL. Displaying any possible
  errors or exceptions in the result block. Adding a new :show-process header
  option such that the underlying process of a Clojure block code get output in
  a new buffer and a new window such that the developer can see what is going
  on.
Could you provide a proper commit message? In particular, each modified
function has to be specified there.
  (defun org-babel-execute:clojure (body params)
-  "Execute a block of Clojure code with Babel."
+  "Execute a block of Clojure code with Babel. The underlying process 
performed by the
"The underlying..." has to go on the line below.

+  code block can be output using the :show-process parameter"
    (let ((expanded (org-babel-expand-body:clojure body params))
-       result)
+        (sbuffer "*Clojure Show Process Sub Buffer*")
+        (show (if (assoc :show-process params) t nil))
   (show (assq :show-process params))

+        (response (cons 'dict nil))
   (response (list 'dict))

+        status
+        result)
+         ; Check if the user want show the process in an output buffer/window
Need ";;" instead of ";". Also, full stop missing at the end.

+         (when show
+           ; Create a new window with the show output buffer
   ;; Create.... output buffer.

+           (switch-to-buffer-other-window sbuffer)
+
+           ; Run the Clojure code in nREPL
Ditto.

+           (nrepl-request:eval
+            expanded
+            (lambda (resp)
+              (when (member "out" resp)
+                ; Print the output of the nREPL in the output buffer
Ditto.

+                (princ (nrepl-dict-get resp "out") (get-buffer sbuffer)))
+              (when (member "ex" resp)
+                ; In case there is an exception, then add it to the output 
buffer as well
Ditto.

+                (princ (nrepl-dict-get resp "ex") (get-buffer sbuffer))
+                (princ (nrepl-dict-get resp "root-ex") (get-buffer sbuffer)))
+              (when (member "err" resp)
+                ; In case there is an error, then add it to the output buffer 
as well
Ditto.

+                (princ (nrepl-dict-get resp "err") (get-buffer sbuffer)))
+              (nrepl--merge response resp)
+              ; Update the status of the nREPL output session
Ditto.
+              (setq status (nrepl-dict-get response "status")))
+            (cider-current-connection)
+            (cider-current-session))
+
+           ; Wait until the nREPL code finished to be processed
Ditto.

+           (while (not (member "done" status))
+             (nrepl-dict-put response "status" (remove "need-input" status))
+             (accept-process-output nil 0.01)
+             (redisplay))
+
+           ; Delete the show buffer & window when the processing is finalized
Ditto.

+           (let ((wins (get-buffer-window-list sbuffer nil t)))
+             (dolist (win wins)
+               (delete-window win))
+             (kill-buffer sbuffer))
   (mapc #'delete-window (get-buffer-window-list sbuffer nil t))
   (kill-buffer sbuffer)

+
+           ; Put the output or the value in the result section of the code 
block
See above.

+           (setq result (concat (nrepl-dict-get response
+                                                (if (or (member "output" 
result-params)
+                                                        (member "pp" 
result-params))
+                                                    "out"
+                                                  "value"))
+                                (nrepl-dict-get response "ex")
+                                (nrepl-dict-get response "root-ex")
+                                (nrepl-dict-get response "err"))))
+         ; Check if user want to run code without showing the process
Ditto.

+         (when (not show)
   (unless show ...)

Ok good, will fix these issues and resend the patch.

BTW, did you sign FSF papers already? I cannot find any reference in
org-contribute.org?

No, what are the FSF papers?


Thanks,

Fred



reply via email to

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