Created
July 1, 2013 16:06
-
-
Save hiredman/5902187 to your computer and use it in GitHub Desktop.
clojure ob
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (when (locate-file "ob" load-path load-suffixes) | |
| (require 'ob) | |
| (require 'ob-tangle) | |
| (add-to-list 'org-babel-tangle-lang-exts '("clojure" . "clj")) | |
| (org-babel-do-load-languages | |
| 'org-babel-load-languages | |
| '((emacs-lisp . t) | |
| (clojure . t))) | |
| (defun org-babel-execute:clojure (body params) | |
| "Evaluate a block of Clojure code with Babel." | |
| (let* ((result (nrepl-send-string-sync body (nrepl-current-ns))) | |
| (value (plist-get result :value)) | |
| (out (plist-get result :stdout)) | |
| (out (when out | |
| (if (string= "\n" (substring out -1)) | |
| (substring out 0 -1) | |
| out))) | |
| (stdout (when out | |
| (mapconcat (lambda (line) | |
| (concat ";; " line)) | |
| (split-string out "\n") | |
| "\n")))) | |
| (concat stdout | |
| (when (and stdout (not (string= "\n" (substring stdout -1)))) | |
| "\n") | |
| ";;=> " value))) | |
| (provide 'ob-clojure) | |
| (setq org-src-fontify-natively t) | |
| (setq org-confirm-babel-evaluate nil)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment