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.
This commit is contained in:
parent
cf2c7e9f18
commit
de087d0bbe
|
@ -101,37 +101,40 @@
|
||||||
|
|
||||||
(defun org-babel-execute:clojure (body params)
|
(defun org-babel-execute:clojure (body params)
|
||||||
"Execute a block of Clojure code with Babel."
|
"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
|
(case org-babel-clojure-backend
|
||||||
(cider
|
(cider
|
||||||
(require 'cider)
|
(require 'cider)
|
||||||
(or (nth 1 (nrepl-send-string-sync
|
(setq result
|
||||||
|
(or (cider-get-raw-value
|
||||||
|
(cider-eval-sync
|
||||||
expanded
|
expanded
|
||||||
(cider-current-ns)
|
(cider-current-ns)
|
||||||
(nrepl-current-tooling-session)))
|
(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
|
(nrepl
|
||||||
(require 'nrepl)
|
(require 'nrepl)
|
||||||
|
(setq result
|
||||||
(if (nrepl-current-connection-buffer)
|
(if (nrepl-current-connection-buffer)
|
||||||
(let* ((result (nrepl-eval expanded))
|
(let* ((result (nrepl-eval expanded))
|
||||||
(s (plist-get result :stdout))
|
(s (plist-get result :stdout))
|
||||||
(r (plist-get result :value)))
|
(r (plist-get result :value)))
|
||||||
(if s (concat s "\n" r) r))
|
(if s (concat s "\n" r) r))
|
||||||
(error "nREPL not connected! Use M-x nrepl-jack-in RET")))
|
(error "nREPL not connected! Use M-x nrepl-jack-in RET"))))
|
||||||
(slime
|
(slime
|
||||||
(require 'slime)
|
(require 'slime)
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
(insert expanded)
|
(insert expanded)
|
||||||
((lambda (result)
|
(setq 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
|
(slime-eval
|
||||||
`(swank:eval-and-grab-output
|
`(swank:eval-and-grab-output
|
||||||
,(buffer-substring-no-properties (point-min) (point-max)))
|
,(buffer-substring-no-properties (point-min) (point-max)))
|
||||||
(cdr (assoc :package params)))))))))
|
(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)
|
(provide 'ob-clojure)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue