diff options
author | Reid D McKenzie <me@arrdem.com> | 2018-04-28 06:58:47 -0700 |
---|---|---|
committer | Bozhidar Batsov <bozhidar.batsov@gmail.com> | 2018-04-28 08:58:47 -0500 |
commit | dd836340ba9571b24d9bbccae2336c3f0c22116b (patch) | |
tree | 8156d9d09342a8c576fcd64d11d1229870c76dd0 /nrepl-client.el | |
parent | a2534bfdeb8f574e4fb4cc8b3697be8606f126f3 (diff) |
Add support for displaying various images (#2248)
Diffstat (limited to 'nrepl-client.el')
-rw-r--r-- | nrepl-client.el | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/nrepl-client.el b/nrepl-client.el index 948ad96e..38e0cb53 100644 --- a/nrepl-client.el +++ b/nrepl-client.el @@ -9,6 +9,7 @@ ;; Artur Malabarba <bruce.connor.am@gmail.com> ;; Hugo Duncan <hugo@hugoduncan.org> ;; Steve Purcell <steve@sanityinc.com> +;; Reid McKenzie <me@arrdem.com> ;; ;; This program is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -764,7 +765,8 @@ to the REPL." (defun nrepl-make-response-handler (buffer value-handler stdout-handler stderr-handler done-handler &optional eval-error-handler - pprint-out-handler) + pprint-out-handler + content-type-handler) "Make a response handler for connection BUFFER. A handler is a function that takes one argument - response received from the server process. The response is an alist that contains at least 'id' @@ -773,20 +775,35 @@ and 'session' keys. Other standard response keys are 'value', 'out', 'err', The presence of a particular key determines the type of the response. For example, if 'value' key is present, the response is of type 'value', if -'out' key is present the response is 'stdout' etc. Depending on the type, -the handler dispatches the appropriate value to one of the supplied -handlers: VALUE-HANDLER, STDOUT-HANDLER, STDERR-HANDLER, DONE-HANDLER, -EVAL-ERROR-HANDLER, and PPRINT-OUT-HANDLER. If the optional -EVAL-ERROR-HANDLER is nil, the default `nrepl-err-handler' is used. If any -of the other supplied handlers are nil nothing happens for the -corresponding type of response." +'out' key is present the response is 'stdout' etc. + +Depending on the type, the handler dispatches the appropriate value to one +of the supplied handlers: VALUE-HANDLER, STDOUT-HANDLER, STDERR-HANDLER, +DONE-HANDLER, EVAL-ERROR-HANDLER, PPRINT-OUT-HANDLER and +CONTENT-TYPE-HANDLER. + +Handlers are functions of the buffer and the value they handle, except for +the optional CONTENT-TYPE-HANDLER which should be a function of the buffer, +content, the content-type to be handled as a list `(type attrs)'. + +If the optional EVAL-ERROR-HANDLER is nil, the default `nrepl-err-handler' +is used. If any of the other supplied handlers are nil nothing happens for +the corresponding type of response." (lambda (response) - (nrepl-dbind-response response (value ns out err status id pprint-out) + (nrepl-dbind-response response (content-type content-transfer-encoding body + value ns out err status id + pprint-out) (when (buffer-live-p buffer) (with-current-buffer buffer (when (and ns (not (derived-mode-p 'clojure-mode))) (cider-set-buffer-ns ns)))) - (cond (value + (cond ((and content-type content-type-handler) + (funcall content-type-handler buffer + (if (string= content-transfer-encoding "base64") + (base64-decode-string body) + body) + content-type)) + (value (when value-handler (funcall value-handler buffer value))) (out |