From: Oleh <ohwoeowho@gmail.com>
To: org mode <emacs-orgmode@gnu.org>
Subject: Re: ob-clojure.el alternative using nrepl
Date: Thu, 3 Oct 2013 17:46:28 +0200 [thread overview]
Message-ID: <CAA01p3qaaTHnHay6o5pAbs_e=RxWgNww9beLNuPdu1s+ptmmTg@mail.gmail.com> (raw)
In-Reply-To: <CAA01p3oZ6hrxA8zs9yqz1MXk1T9fTarAfkL9M=xB9-9O1Dnvmw@mail.gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 408 bytes --]
I guess that I forgot the attachment.
Oleh
On Thu, Oct 3, 2013 at 5:45 PM, Oleh <ohwoeowho@gmail.com> wrote:
> Hi all,
>
> Current method of clojure evaluation is through slime.
> I couldn't get it to work, when I tried long ago.
> So I attach one that uses nrepl.
> Switching between the two should be as easy as using
>
> (require 'ob-clojure)
> or
> (require 'ob-clojure-nrepl).
>
> regards,
> Oleh
>
[-- Attachment #1.2: Type: text/html, Size: 876 bytes --]
[-- Attachment #2: 0001-ob-clojure-nrepl.el-Added-nrepl-alternative-to-ob-cl.patch --]
[-- Type: application/octet-stream, Size: 2532 bytes --]
From e9e8b9c7b4b1aa9ee132e8a1a9a9d2df1898ba4b Mon Sep 17 00:00:00 2001
From: Oleh Krehel <ohwoeowho@gmail.com>
Date: Thu, 3 Oct 2013 17:37:14 +0200
Subject: [PATCH] ob-clojure-nrepl.el: Added nrepl alternative to
ob-clojure.el.
---
lisp/ob-clojure-nrepl.el | 59 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+)
create mode 100644 lisp/ob-clojure-nrepl.el
diff --git a/lisp/ob-clojure-nrepl.el b/lisp/ob-clojure-nrepl.el
new file mode 100644
index 0000000..cfae57d
--- /dev/null
+++ b/lisp/ob-clojure-nrepl.el
@@ -0,0 +1,59 @@
+;;; ob-clojure.el --- org-babel functions for clojure evaluation
+
+;; Copyright (C) 2009-2013 Free Software Foundation, Inc.
+
+;; Author: Oleh Krehel
+;; Keywords: literate programming, reproducible research
+;; Homepage: http://orgmode.org
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;; support for evaluating clojure code, relies on nrepl for eval
+
+;;; Requirements:
+
+;;; - clojure
+;;; - clojure-mode
+;;; - nrepl
+
+;;; Best way to get clojure is with https://github.com/technomancy/leiningen
+;;; Best way to get nrepl is from MELPA (clojure-mode is a dependency).
+
+;;; Code:
+(require 'ob)
+(require 'ob-tangle)
+
+(defvar org-babel-tangle-lang-exts)
+(add-to-list 'org-babel-tangle-lang-exts '("clojure" . "clj"))
+
+(defvar org-babel-default-header-args:clojure
+ '((:results . "value") (:tangle . "yes")))
+
+(defun org-babel-execute:clojure (body params)
+ "Execute a block of Clojure code with Babel and nREPL."
+ (require 'nrepl)
+ (if (nrepl-current-connection-buffer)
+ (let* ((result (nrepl-eval body))
+ (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.")))
+
+(provide 'ob-clojure-nrepl)
+
+;;; ob-clojure-nrepl.el ends here
--
1.8.4
next prev parent reply other threads:[~2013-10-03 15:46 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-03 15:45 ob-clojure.el alternative using nrepl Oleh
2013-10-03 15:46 ` Oleh [this message]
2013-10-03 15:54 ` Bastien
[not found] ` <CAA01p3rUCr=Q+7QORn_6EEjqqY0SKpKU=0FvRj9-kmDGs=-43w@mail.gmail.com>
[not found] ` <87hacynx1l.fsf@bzg.ath.cx>
2013-10-03 16:27 ` Oleh
2013-10-03 18:06 ` Eric Schulte
2013-10-03 18:37 ` Oleh
2013-10-03 21:47 ` Eric Schulte
2013-10-03 21:56 ` Bastien
2013-10-03 22:53 ` Eric Schulte
2013-10-04 8:26 ` Oleh
2013-10-04 17:05 ` Eric Schulte
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAA01p3qaaTHnHay6o5pAbs_e=RxWgNww9beLNuPdu1s+ptmmTg@mail.gmail.com' \
--to=ohwoeowho@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).