From de087d0bbe994299e7c9e1209de2da9b4d587f7e Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Thu, 30 Jan 2014 12:10:37 +0100 Subject: [PATCH] ob-clojure.el (org-babel-execute:clojure): Fix output * ob-clojure.el (org-babel-execute:clojure): Use `org-babel-result-cond' to create the correct output. Thanks to Soapy Smith who reported this and to Eric Schulte for providing the fix. --- lisp/ob-clojure.el | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el index 0e0c7b397..cdf453e12 100644 --- a/lisp/ob-clojure.el +++ b/lisp/ob-clojure.el @@ -101,37 +101,40 @@ (defun org-babel-execute:clojure (body params) "Execute a block of Clojure code with Babel." - (let ((expanded (org-babel-expand-body:clojure body params))) + (let ((expanded (org-babel-expand-body:clojure body params)) + result) (case org-babel-clojure-backend (cider (require 'cider) - (or (nth 1 (nrepl-send-string-sync + (setq result + (or (cider-get-raw-value + (cider-eval-sync expanded (cider-current-ns) (nrepl-current-tooling-session))) - (error "nREPL not connected! Use M-x cider-jack-in RET"))) + (error "nREPL not connected! Use M-x cider-jack-in RET")))) (nrepl (require 'nrepl) - (if (nrepl-current-connection-buffer) - (let* ((result (nrepl-eval expanded)) - (s (plist-get result :stdout)) - (r (plist-get result :value))) - (if s (concat s "\n" r) r)) - (error "nREPL not connected! Use M-x nrepl-jack-in RET"))) + (setq result + (if (nrepl-current-connection-buffer) + (let* ((result (nrepl-eval expanded)) + (s (plist-get result :stdout)) + (r (plist-get result :value))) + (if s (concat s "\n" r) r)) + (error "nREPL not connected! Use M-x nrepl-jack-in RET")))) (slime (require 'slime) (with-temp-buffer (insert expanded) - ((lambda (result) - (let ((result-params (cdr (assoc :result-params params)))) - (org-babel-result-cond result-params - result - (condition-case nil (org-babel-script-escape result) - (error result))))) - (slime-eval - `(swank:eval-and-grab-output - ,(buffer-substring-no-properties (point-min) (point-max))) - (cdr (assoc :package params))))))))) + (setq result + (slime-eval + `(swank:eval-and-grab-output + ,(buffer-substring-no-properties (point-min) (point-max))) + (cdr (assoc :package params))))))) + (org-babel-result-cond (cdr (assoc :result-params params)) + result + (condition-case nil (org-babel-script-escape result) + (error result))))) (provide 'ob-clojure)