From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [PATCH] New header parameter :show-process for Org-babel-clojure Date: Thu, 10 Nov 2016 16:18:24 +0100 Message-ID: <87lgwrgy7z.fsf@nicolasgoaziou.fr> References: <036bf007-5e9c-310c-5bf8-0660c1b96a5c@fgiasson.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35599) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c4r7R-0004lz-6y for emacs-orgmode@gnu.org; Thu, 10 Nov 2016 10:18:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c4r7P-0004zF-SZ for emacs-orgmode@gnu.org; Thu, 10 Nov 2016 10:18:25 -0500 Received: from relay3-d.mail.gandi.net ([2001:4b98:c:538::195]:60733) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c4r7P-0004wb-Jg for emacs-orgmode@gnu.org; Thu, 10 Nov 2016 10:18:23 -0500 In-Reply-To: <036bf007-5e9c-310c-5bf8-0660c1b96a5c@fgiasson.com> (Frederick Giasson's message of "Mon, 7 Nov 2016 14:19:42 -0500") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Frederick Giasson Cc: emacs-orgmode@gnu.org Hello, Frederick Giasson writes: > 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 ...) BTW, did you sign FSF papers already? I cannot find any reference in org-contribute.org? Regards, -- Nicolas Goaziou