org-mode Clojure babel

922 views
Skip to first unread message

Johannes

unread,
Nov 3, 2015, 3:25:51 AM11/3/15
to Clojure
Hi,

I am looking for a working environment for using org-mode with Clojure babel. Googleing for the issue I can only find some apparently outdated hints. I am using org-mode version 8.2.10, Clojure 1.6.0, Leiningen 2.5.1, and CIDER 0.10.0.

Any hints, where I can find the right configuration?

Johannes

Stuart Sierra

unread,
Nov 3, 2015, 8:03:12 AM11/3/15
to Clojure
Hi Johannes

I have a working Org babel & Clojure in my Emacs setup. It's idiosyncratic to my preferences, but maybe it will be useful:
github.com/stuartsierra/dotfiles

–S

Karsten Schmidt

unread,
Nov 3, 2015, 1:56:17 PM11/3/15
to clo...@googlegroups.com
Hi Johannes, checkout my leiningen template for org-mode projects
here: http://thi.ng/babel and an example project using this template
here: http://thi.ng/fabric
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Karsten Schmidt
http://postspectacular.com | http://thi.ng | http://toxiclibs.org

Johannes Brauer

unread,
Nov 4, 2015, 4:36:01 AM11/4/15
to clo...@googlegroups.com
Hi Stuart,

thanks a lot for your help. I’ve included your settings in my Emacs (Aquamacs) setup. After having activated CIDER I tried to compile (C-c C-c) a little code snippet:

#+begin_src clojure  :results silent
   (+ 1 2)
#+end_src

What happens, is:

Evaluate this clojure code block on your system? (y or n) y
executing Clojure code block...
let: Wrong number of arguments: (3 . 4), 1

What I am doing wrongly?

Johannes
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "Clojure" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/PldQTR3yB3A/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojure+u...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.





Staatlich anerkannte private Fachhochschule
NORDAKADEMIE
Gemeinnützige Aktiengesellschaft
Köllner Chaussee 11
25337 Elmshorn

Vorstand:
Prof. Dr. Georg Plate (Vorsitzender), Dipl.-Ing. Jörg Meier (stellv. Vorstand)

Vorsitzender des Aufsichtsrats:
Dr. h.c. Hans-Heinrich Bruns

Sitz:
Elmshorn, Amtsgericht Pinneberg, HRB 1682

Johannes Brauer

unread,
Nov 4, 2015, 4:39:29 AM11/4/15
to clo...@googlegroups.com
Hi Karsten,

thank you for the links to your project. But until now, I haven’t succeeded to setup my Emacs so that I can evaluate Clojure code snippets in an org file.

Johannes
> You received this message because you are subscribed to a topic in the Google Groups "Clojure" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/PldQTR3yB3A/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to clojure+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.


Stuart Sierra

unread,
Nov 4, 2015, 8:26:23 AM11/4/15
to Clojure
Hi, Johannes,

Sorry, I don't know. That error looks like an incompatibility of Elisp functions from different libraries.

There are just too many different moving pieces here: Emacs, org-mode, CIDER, and nREPL. These projects are not coordinated with regard to version numbers and API incompatibilities.

The code snippet I linked to only works on the specific versions I have: Emacs (GNU 24.5.1), org-mode (commit d3196f0), CIDER (0.9.1), and nREPL (0.9.1).

You will probably have to debug and tweak the Elisp code to work with your local Emacs installation. I don't know of any easier way to get org-babel & Clojure working together.

Good luck,
–S

Matching Socks

unread,
Nov 4, 2015, 10:06:35 PM11/4/15
to Clojure
If you and your Emacs are happy with cider and clojure-mode, then the leap to Org Babel with Clojure should be a short one.

One thing to do is look at your Org mode's ob-clojure.el and figure out whether it mentions cider.  (The older or "stable" versions use only slime or nrepl.)  The Org website is a house of mirrors, but somewhere you should find a tidy tar.gz of a nicely assembled Org whose ob-clojure.el covers cider.

Another thing that might go wrong, is that the cider-capable version of ob-clojure may try to detect whether it should use cider, nrepl, or slime.  Detection might reach an unfortunate conclusion if Emacs had not loaded cider.  Therefore, it might help to open a cider REPL buffer before opening any Org buffers.  (If I recall, Org Babel will need that REPL sooner or later anyway; it does not open its own REPL.)

Johannes Brauer

unread,
Nov 5, 2015, 4:19:35 AM11/5/15
to clo...@googlegroups.com
Hi!

Thank you for your hints.

...

One thing to do is look at your Org mode's ob-clojure.el and figure out whether it mentions cider.  (The older or "stable" versions use only slime or nrepl.)  The Org website is a house of mirrors, but somewhere you should find a tidy tar.gz of a nicely assembled Org whose ob-clojure.el covers cider.
indeed, my version of ob-clojure did not mention cider. I’ve one in the house of mirrors (http://orgmode.org/cgit.cgi/org-mode.git/plain/lisp/ob-clojure.el) which does.
But the error message
     executing Clojure code block...
     let: Wrong number of arguments: (3 . 4), 1
remains.

Another thing that might go wrong, is that the cider-capable version of ob-clojure may try to detect whether it should use cider, nrepl, or slime.  Detection might reach an unfortunate conclusion if Emacs had not loaded cider.  Therefore, it might help to open a cider REPL buffer before opening any Org buffers.  (If I recall, Org Babel will need that REPL sooner or later anyway; it does not open its own REPL.)
I tried this too, but without success

Johannes

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "Clojure" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/PldQTR3yB3A/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Phillip Lord

unread,
Nov 6, 2015, 12:10:58 PM11/6/15
to Johannes Brauer, clo...@googlegroups.com

If you are willing to entertain a slightly different interaction model,
you might want to take a look at the lentic package

https://github.com/phillord/lentic

Instead of Clojure snippets which you can pop out and edit, this gives
you two buffers, one entirely valid clojure (which syntax highlights,
you can eval, test and so forth) and one entirely valid org (which you
can publish, show-hide and so forth). You can edit either one (the
Clojure view or the Org-mode view) and changes percolate backward.

This video shows it working with org-mode and Emacs-lisp.

https://vimeo.com/116078853

And this video shows it working with latex and clojure.

https://vimeo.com/116141808

I don't have a video of it working with org and clojure, but it does
work with them. My tawny-owl library is being (slowly) ported to this
form of literate development.

https://github.com/phillord/tawny-owl/blob/master/src/tawny/owl.clj

It also allows integration with asciidoc, and clojure. I wrote these
slides:

http://homepages.cs.ncl.ac.uk/phillip.lord/download/tawny/icbo_2015/2015_lisbon.html

as literate clojure source.

Have fun.

Phil
--
Phillip Lord, Phone: +44 (0) 191 208 7827
Lecturer in Bioinformatics, Email: philli...@newcastle.ac.uk
School of Computing Science, http://homepages.cs.ncl.ac.uk/phillip.lord
Room 914 Claremont Tower, skype: russet_apples
Newcastle University, twitter: phillord
NE1 7RU

Johannes Brauer

unread,
Nov 7, 2015, 7:35:44 AM11/7/15
to Phillip Lord, clo...@googlegroups.com
it sounds exciting, I’ll give it a try.

Johannes

Johannes

unread,
Nov 10, 2015, 3:36:04 AM11/10/15
to Clojure, bra...@nordakademie.de
I am quite impressed about lentic. I think I will use it. Thank you, Phil. 

Nevertheless I am looking for a working configuration for Emacs org-mode with Clojure babel.

Johannes


Am Freitag, 6. November 2015 18:10:58 UTC+1 schrieb Phillip Lord:

If you are willing to entertain a slightly different interaction model,
you might want to take a look at the lentic package

https://github.com/phillord/lentic
 pInstead of Clojure snippets which you can pop out and edit, this gives

Matching Socks

unread,
Dec 10, 2015, 10:24:27 AM12/10/15
to Clojure
The latest stable Org Babel stopped working with the introduction of Cider 0.10.0. 

You can either go back to Cider 0.9.1, or
(1) get Org 8.3.2,
(2) git-clone Org's repo, and
(3) back-port to 8.3.2 the change in ob-clojure.el that accommodates the latest Cider.

The breakage was raised at https://github.com/clojure-emacs/cider/issues/1302 and closed with a comment, "I don't have nor the time nor the energy to sync up with everyone maintaining a 3rd party extension. I just hope they're following the development and will do the necessary changes when needed." 

But three considerations, which are not Cider's fault, argue for a kinder accommodation.  First, Org freezes for bundling into a major Emacs release only a few times a century, and the resulting Emacs release then enjoys wide distribution for many years.  Second, the bundled Org is unusually significant because overriding it with another version is not always fool-proof.  Third, Org with Clojure snippets is dynamite!  Therefore, I hope Org will get advice from Cider about a more durable technique, so the next Emacs+Org release might be useful even on the glacial Emacs time scale.



On Tuesday, November 3, 2015 at 3:25:51 AM UTC-5, Johannes wrote:

Johannes Brauer

unread,
Dec 20, 2015, 12:16:15 PM12/20/15
to clo...@googlegroups.com
Thanks, for the explanations. I hope for the best, that there will be an working org-babel version in the future. In the mean time I will continue using lentilc.

Johannes

martin_clausen

unread,
Dec 21, 2015, 10:12:09 AM12/21/15
to Clojure
I found that

Org-mode version 8.3.2 and CIDER 0.11.0 snapshot (package: 20151212.1044)

works great and can be easily be installed from repos.

Johannes Brauer

unread,
Dec 29, 2015, 7:01:30 AM12/29/15
to clo...@googlegroups.com
thanks for the hint; indeed it works 

Stuart Sierra

unread,
Jan 3, 2016, 5:00:19 PM1/3/16
to Clojure
I recently adapted my Emacs config to work with Org 8.3.2 and CIDER 0.10.0. Here it is. This is just my personal setup, not something I can support. Posting here in case someone else might find it useful.
–S

Johannes

unread,
Jan 6, 2016, 7:02:23 AM1/6/16
to Clojure
BUT!!!

With cider-nrepl set to 0.10.0 and cider set to 0.11.0-snapshot emacs complains:
WARNING: CIDER requires nREPL 0.2.12 (or newer) to work properly
WARNING: CIDER's version (0.11.0-snapshot) does not match cider-nrepl's version (0.10.1). Things will break!

That's not an org-bable problem, but perhaps there is a tip what to do.

Johannes

For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to a topic in the Google Groups "Clojure" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/PldQTR3yB3A/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojure+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Martin Clausen

unread,
Jan 6, 2016, 7:11:34 AM1/6/16
to Clojure
If you update to cider/cider-nrepl 0.11.0-snapshot in your .lein/profiles.clj that should fix the problem.

Johannes Brauer

unread,
Jan 6, 2016, 3:24:23 PM1/6/16
to clo...@googlegroups.com
I tried this before. But with
{:repl {:plugins [[cider/cider-nrepl " 0.11.0-snapshot"]]}}
in my profiles.clj and cider-jack-in I get a Java exception:
Starting nREPL server via lein repl :headless...
error in process sentinel: Could not start nREPL server: java.lang.IllegalArgumentException: Bad artifact coordinates cider:cider-nrepl:jar: 0.11.0-snapshot, expected format is <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>
 at org.sonatype.aether.util.artifact.DefaultArtifact.<init> (DefaultArtifact.java:73)
    org.sonatype.aether.util.artifact.DefaultArtifact.<init> (DefaultArtifact.java:56)
    cemerick.pomegranate.aether$artifact.invoke (aether.clj:222)
    cemerick.pomegranate.aether$dependency.invoke (aether.clj:230)
    cemerick.pomegranate.aether$resolve_dependencies_STAR_$fn__190.invoke (aether.clj:708)

Reid McKenzie

unread,
Jan 6, 2016, 5:23:07 PM1/6/16
to clo...@googlegroups.com
"0.11.0-SNAPSHOT". It's case sensitive.

Reid
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.

Johannes Brauer

unread,
Jan 7, 2016, 11:59:28 AM1/7/16
to clo...@googlegroups.com
okay, that I could have figured out myself, sorry. But now I get another exception:
error in process sentinel: Could not start nREPL server: java.lang.IllegalArgumentException: No value supplied for key: .
 at clojure.lang.PersistentHashMap.create (PersistentHashMap.java:77)
    leiningen.core.project$dependency_map.invoke (project.clj:77)
    leiningen.core.project$dep_key.invoke (project.clj:228)
    leiningen.core.project$reduce_dep_step.invoke (project.clj:232)
    clojure.lang.ArrayChunk.reduce (ArrayChunk.java:58)
???
Johannes

Johannes Brauer

unread,
Jan 7, 2016, 3:02:45 PM1/7/16
to clo...@googlegroups.com
now my profiles.clj looks like
{:repl {:plugins [[cider/cider-nrepl "0.11.0-SNAPSHOT"]
                  [lein-pprint "1.1.2"]]
        :dependencies [[org.clojure/tools.nrepl "0.2.12"]]}}

 But repl complains:
; CIDER 0.11.0snapshot (package: 20160104.1114) (Java 1.8.0_25, Clojure 1.6.0, nREPL 0.2.6)
WARNING: CIDER requires nREPL 0.2.12 (or newer) to work properly
WARNING: The following required nREPL ops are not supported: 
  apropos classpath complete eldoc format-code format-edn info inspect-pop inspect-push inspect-refresh macroexpand ns-list ns-vars ns-path refresh resource stacktrace toggle-trace-var toggle-trace-ns undef
  Please, install (or update) cider-nrepl 0.11.0-SNAPSHOT and restart CIDER
user> 

Is anything wrong with my profiles.clj?

Johannes

Martin Clausen

unread,
Jan 7, 2016, 3:06:07 PM1/7/16
to clo...@googlegroups.com
Have you tried updating leiningen?

Johannes Brauer

unread,
Jan 7, 2016, 3:18:51 PM1/7/16
to clo...@googlegroups.com
thanks a lot,Martin, upgrading leiningen from 2.5.1 to 2.5.3 solves the problem

Johannes
Reply all
Reply to author
Forward
0 new messages