From mboxrd@z Thu Jan 1 00:00:00 1970 From: Frederick Giasson Subject: Re: [PATCH] New header parameter :show-process for Org-babel-clojure Date: Thu, 10 Nov 2016 12:20:43 -0500 Message-ID: <5c5e3832-315a-e98d-b098-dc18692ed0b3@fgiasson.com> References: <036bf007-5e9c-310c-5bf8-0660c1b96a5c@fgiasson.com> <87lgwrgy7z.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55807) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c4t1t-0002BC-DU for emacs-orgmode@gnu.org; Thu, 10 Nov 2016 12:20:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c4t1q-0001de-7D for emacs-orgmode@gnu.org; Thu, 10 Nov 2016 12:20:49 -0500 Received: from s052.panelboxmanager.com ([72.55.186.33]:53900) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c4t1q-0001cS-3E for emacs-orgmode@gnu.org; Thu, 10 Nov 2016 12:20:46 -0500 Received: from mailnull by s052.panelboxmanager.com with sa-checked (Exim 4.87) (envelope-from ) id 1c4t1m-002cgA-RD for emacs-orgmode@gnu.org; Thu, 10 Nov 2016 12:20:43 -0500 Received: from modemcable199.69-130-66.mc.videotron.ca ([66.130.69.199]:52050 helo=[192.168.0.199]) by s052.panelboxmanager.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.87) (envelope-from ) id 1c4t1m-002cfq-IW for emacs-orgmode@gnu.org; Thu, 10 Nov 2016 12:20:42 -0500 In-Reply-To: <87lgwrgy7z.fsf@nicolasgoaziou.fr> Content-Language: en-US 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: emacs-orgmode@gnu.org 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