From: Eric Schulte <schulte.eric@gmail.com>
To: Oleh <ohwoeowho@gmail.com>
Cc: Bastien <bzg@gnu.org>, org mode <emacs-orgmode@gnu.org>
Subject: Re: ob-clojure.el alternative using nrepl
Date: Thu, 03 Oct 2013 12:06:34 -0600 [thread overview]
Message-ID: <8761temdp1.fsf@gmail.com> (raw)
In-Reply-To: <CAA01p3q2L1oFRNSsu_OMxN8szt0df201n2U5mUB1V2d3cMv5BA@mail.gmail.com> (Oleh's message of "Thu, 3 Oct 2013 18:27:13 +0200")
Thanks for this update.
Oleh <ohwoeowho@gmail.com> writes:
> Here's an updated patch.
> I use defalias, is that OK?
>
Two changes.
1. instead of customization through a defalias, use defcustom and a
variable which determines which function (eval-slime or eval-nrepl)
is called.
2. ob-*.el files should not require ob-tangle.
If you prefer not to make these changes I can apply your patch, and then
make the required changes myself over-top.
Best,
>
> Oleh
>
>
> On Thu, Oct 3, 2013 at 6:23 PM, Bastien <bzg@gnu.org> wrote:
>
>> Hi Oleh,
>>
>> Oleh <ohwoeowho@gmail.com> writes:
>>
>> > Should I rather put the code in ob-clojure.el with something like
>> > (defcustom ob-clojure-method nrepl)?
>>
>> Yes, I think it's better. Maybe
>>
>> (defcustom ob-clojure-repl 'nrepl)
>>
>> Let's discuss this on the list so that others can chime in.
>>
>> Thanks for bringing this up!
>>
>> --
>> Bastien
>>
>
> From ab5c9a8844b4103e40cd4c135f297a7089cd7cdf Mon Sep 17 00:00:00 2001
> From: Oleh Krehel <ohwoeowho@gmail.com>
> Date: Thu, 3 Oct 2013 18:23:16 +0200
> Subject: [PATCH] ob-clojure.el: switch to nREPL as the main method of
> evaluating Clojure.
>
> Get the old behavior with:
> (defalias 'org-babel-execute:clojure 'org-babel--execute-clojure-slime)
> ---
> lisp/ob-clojure.el | 34 ++++++++++++++++++++++++++--------
> 1 file changed, 26 insertions(+), 8 deletions(-)
>
> diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el
> index bc2bbc0..3b82f0a 100644
> --- a/lisp/ob-clojure.el
> +++ b/lisp/ob-clojure.el
> @@ -2,8 +2,8 @@
>
> ;; Copyright (C) 2009-2013 Free Software Foundation, Inc.
>
> -;; Author: Joel Boehland
> -;; Eric Schulte
> +;; Author: Joel Boehland, Eric Schulte, Oleh Krehel
> +;;
> ;; Keywords: literate programming, reproducible research
> ;; Homepage: http://orgmode.org
>
> @@ -24,20 +24,26 @@
>
> ;;; Commentary:
>
> -;;; support for evaluating clojure code, relies on slime for all eval
> +;;; support for evaluating clojure code, relies either on slime or
> +;;; on nrepl for all eval
>
> ;;; Requirements:
>
> ;;; - clojure (at least 1.2.0)
> ;;; - clojure-mode
> -;;; - slime
> +;;; - either slime or nrepl
>
> -;;; By far, the best way to install these components is by following
> -;;; the directions as set out by Phil Hagelberg (Technomancy) on the
> -;;; web page: http://technomancy.us/126
> +;;; For SLIME-way, the best way to install these components is by
> +;;; following the directions as set out by Phil Hagelberg (Technomancy)
> +;;; on the web page: http://technomancy.us/126
> +
> +;;; For nREPL-way:
> +;;; get clojure is with https://github.com/technomancy/leiningen
> +;;; get nrepl from MELPA (clojure-mode is a dependency).
>
> ;;; Code:
> (require 'ob)
> +(require 'ob-tangle)
>
> (declare-function slime-eval "ext:slime" (sexp &optional package))
>
> @@ -72,7 +78,7 @@
> (format "(clojure.core/with-out-str %s)" body))
> (t body))))
>
> -(defun org-babel-execute:clojure (body params)
> +(defun org-babel--execute-clojure-slime (body params)
> "Execute a block of Clojure code with Babel."
> (require 'slime)
> (with-temp-buffer
> @@ -88,6 +94,18 @@
> ,(buffer-substring-no-properties (point-min) (point-max)))
> (cdr (assoc :package params))))))
>
> +(defun org-babel--execute-clojure-nrepl (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.")))
> +
> +(defalias 'org-babel-execute:clojure 'org-babel--execute-clojure-nrepl)
> +
> (provide 'ob-clojure)
--
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D
next prev parent reply other threads:[~2013-10-03 18:07 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
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 [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8761temdp1.fsf@gmail.com \
--to=schulte.eric@gmail.com \
--cc=bzg@gnu.org \
--cc=emacs-orgmode@gnu.org \
--cc=ohwoeowho@gmail.com \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.