emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: Frederick Giasson <fred@fgiasson.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] New header parameter :show-process for Org-babel-clojure
Date: Thu, 10 Nov 2016 16:18:24 +0100	[thread overview]
Message-ID: <87lgwrgy7z.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <036bf007-5e9c-310c-5bf8-0660c1b96a5c@fgiasson.com> (Frederick Giasson's message of "Mon, 7 Nov 2016 14:19:42 -0500")

Hello,

Frederick Giasson <fred@fgiasson.com> 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

  reply	other threads:[~2016-11-10 15:18 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-07 19:19 [PATCH] New header parameter :show-process for Org-babel-clojure Frederick Giasson
2016-11-10 15:18 ` Nicolas Goaziou [this message]
2016-11-10 17:20   ` Frederick Giasson
2016-11-10 23:55     ` Nicolas Goaziou
2016-11-14 20:46   ` Frederick Giasson
2016-11-15  7:49     ` Nicolas Goaziou
2016-11-17 13:39       ` Frederick Giasson
2016-11-17 23:06         ` Nicolas Goaziou
2016-11-18 15:03           ` Aaron Ecay
2016-11-18 15:09             ` Frederick Giasson
2016-11-18 15:49               ` Nicolas Goaziou
2016-11-18 17:02                 ` Frederick Giasson
2016-11-19  7:40                   ` Nicolas Goaziou
2016-11-18 15:31             ` Frederick Giasson
2016-11-18 15:12           ` Frederick Giasson
2016-11-18 15:51             ` Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lgwrgy7z.fsf@nicolasgoaziou.fr \
    --to=mail@nicolasgoaziou.fr \
    --cc=emacs-orgmode@gnu.org \
    --cc=fred@fgiasson.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).