瀏覽代碼

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.
Bastien Guerry 11 年之前
父節點
當前提交
de087d0bbe
共有 1 個文件被更改,包括 22 次插入19 次删除
  1. 22 19
      lisp/ob-clojure.el

+ 22 - 19
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)