Literate Programming in Emacs?

607 views
Skip to first unread message

Andrew

unread,
Nov 22, 2011, 5:28:30 PM11/22/11
to clo...@googlegroups.com
For those who do Literate Programming in Emacs, what do you use? I was looking at org-babel-clojure which says:
 
You will need to install the following packages: clojure-mode, swank-clojure, slime, slime-repl

But when I list-packages, swank-clojure is not in the list... It also says I ought to be able to M-x slime ... but that results in "no such file or directory, lisp"

Andrew

unread,
Nov 22, 2011, 5:34:38 PM11/22/11
to clo...@googlegroups.com
I should add that I am starting with a working setup (able to M-x clojure-jack-in and compile and execute stuff in the REPL as expected).

Andreas Kostler

unread,
Nov 22, 2011, 5:42:27 PM11/22/11
to clo...@googlegroups.com
It should work as expected if you follow
http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-clojure.html
and use the stand-alone version of swank-clojure (Section Connecting
with SLIME https://github.com/technomancy/swank-clojure).
Looking at ob-clojure.el http://kanis.fr/hg/lisp/org/ob-clojure.el
might give you some clues as well.
Hope that helps
Andreas

On 23 November 2011 09:04, Andrew <ach...@gmail.com> wrote:
> I should add that I am starting with a working setup (able to M-x
> clojure-jack-in and compile and execute stuff in the REPL as expected).
>

> --
> 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

--
**********************************************************
Andreas Koestler, Software Engineer
Leica Geosystems Pty Ltd
270 Gladstone Road, Dutton Park QLD 4102
Main: +61 7 3891 9772     Direct: +61 7 3117 8808
Fax: +61 7 3891 9336
Email: andreas....@leica-geosystems.com

************www.leica-geosystems.com*************

when it has to be right, Leica Geosystems

Please  consider the environment before printing this email.

Devin Walters

unread,
Nov 22, 2011, 8:12:49 PM11/22/11
to clo...@googlegroups.com, clo...@googlegroups.com
I have a bit of a weird setup I think. I put clojure-1.3.0.jar in ~/.clojure and set a variable for org-mode according to the advanced setup instructions. I also run org-mode from source. As a result I make sure to add org-mode's lisp/ dir to my load path.

Sent via mobile
--

Andrew

unread,
Nov 23, 2011, 12:00:16 PM11/23/11
to clo...@googlegroups.com
Here's my attempt at following the steps at http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-clojure.html. The result is org-babel-execute-src-block: No org-babel-execute function for clojure
  1. The recommendation was to follow "Connecting with SLIME" from https://github.com/technomancy/swank-clojure which involves M-x slime-connect, so I looked for that in http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-clojure.html ... It has a section called "Server/Set up Leiningen project.clj file" which says add a dev-dependency in my project.clj file for leiningen/lein-swank. So I picked [leiningen/lein-swank "1.2.0-SNAPSHOT"]
  2. lein deps
  3. lein swank
  4. It said I should add swank-clojure as a dev-dependency too. So I picked [swank-clojure "1.4.0-SNAPSHOT"]
  5. lein deps
  6. lein swank
  7. M-x slime-connect ... connected
  8. open tmp.org file and place cursor within a block of code and do C-c C-c
  9. Evaluate this block of code on your system? y
org-babel-execute-src-block: No org-babel-execute function for clojure!

What am I missing? I have the following:

  clojure-mode      1.11.4      installed
  org               20111122    installed
  slime             20100404.1  installed
  slime-repl        20100404    installed

... and lein plugin swank-clojure (1.3.3 I think)

ck

unread,
Nov 23, 2011, 3:38:29 PM11/23/11
to Clojure
Andrew:

Make sure you have

(require 'ob-clojure)

in your controlling emacs file (mine is <username>.el).

-ck

On Nov 23, 12:00 pm, Andrew <ache...@gmail.com> wrote:
> Here's my attempt at following the steps athttp://orgmode.org/worg/org-contrib/babel/languages/ob-doc-clojure.html. *The


> result is org-babel-execute-src-block: No org-babel-execute function for

> clojure *
>
>    1. The recommendation was to follow "Connecting with SLIME" from
>    https://github.com/technomancy/swank-clojurewhich involves M-x


>    slime-connect, so I looked for that in
>    http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-clojure.html...
>    It has a section called "Server/Set up Leiningen project.clj file" which
>    says add a dev-dependency in my project.clj file for leiningen/lein-swank.
>    So I picked [leiningen/lein-swank "1.2.0-SNAPSHOT"]

>    2. lein deps
>    3. lein swank
>    4. It said I should add swank-clojure as a dev-dependency too. So I
>    picked [swank-clojure "1.4.0-SNAPSHOT"]
>    5. lein deps
>    6. lein swank
>    7. M-x slime-connect ... connected
>    8. open tmp.org file and place cursor within a block of code and do C-c
>    C-c
>    9. Evaluate this block of code on your system? y

Andrew

unread,
Nov 23, 2011, 4:36:26 PM11/23/11
to clo...@googlegroups.com
Thanks! Next step: org-babel-execute:clojure:Cannot open load file: swank-clojure ...

ck

unread,
Nov 24, 2011, 8:06:20 AM11/24/11
to Clojure

I did not encounter that particular problem. But to compare, my
project file is

...
:dependencies [[org.clojure/clojure "1.3.0"]]
:dev-dependencies [[jline "0.9.94"]
[swank-clojure "1.3.0" :exclusions [org.clojure/
clojure]]]
...


and my current ~/.emacs.d/elpha folder contains

clojure-mode-1.11.4/
clojure-test-mode-1.6.0/
durendal-0.2/
org-20111123/
slime-20100404.1/
slime-repl-20100404/
swank-clojure-1.1.0/

using Phil Hagelberg's emacs-starter-kit (https://github.com/
technomancy/emacs-starter-kit).


I would also like to point to this excellent blog by Nurullah Akkaya

http://nakkaya.com/2010/12/12/using-clojure-with-org-babel-and-inferior-lisp/

for using org-babel-clojure with inferior-lisp.

Hope that helps.

-ck

Andrew

unread,
Nov 29, 2011, 11:34:10 AM11/29/11
to clo...@googlegroups.com
Thanks -- it does help somewhat...
  1. How is it that you have swank-clojure in your elpa directory? M-x list-packages does not have swank-clojure as an option.
  2. Why does your elpa directory have 1.1.0 and your project file have 1.3.0?
  3. Is there a choice between SLIME and inferior lisp when doing literate programming in emacs? I want to keep all of my crutches like paredit-mode, syntax highlighting, symbol completion, etc. Do I have to be in an inferior lisp and lose all that?

Phil Hagelberg

unread,
Nov 29, 2011, 1:37:13 PM11/29/11
to clo...@googlegroups.com
On Tue, Nov 29, 2011 at 8:34 AM, Andrew <ach...@gmail.com> wrote:
> How is it that you have swank-clojure in your elpa directory? M-x
> list-packages does not have swank-clojure as an option.

The swank-clojure elisp package is deprecated and should not be used.

> Why does your elpa directory have 1.1.0 and your project file have 1.3.0?

swank-clojure.el was hard-coded to use Clojure 1.1.0 way back in the
day, which is part of the reason it's deprecated.

-Phil

Stuart Sierra

unread,
Nov 29, 2011, 2:26:40 PM11/29/11
to Clojure
Here's the relevant bit of my .emacs for Babel + Clojure:
https://github.com/stuartsierra/dotfiles/blob/cb88b1ca020fd5beebb3de092f12aa27daddd779/.emacs#L203

This requires Org mode version 7.7.

I mostly use inferior-lisp mode instead of SWANK/SLIME.

-S

daly

unread,
Nov 29, 2011, 3:57:39 PM11/29/11
to clo...@googlegroups.com
I would be really interested to see some examples of
literate programs. Please consider releasing them as
open source, possibly pushed to github.

Tim Daly

Stuart Sierra

unread,
Nov 29, 2011, 8:31:42 PM11/29/11
to Clojure
Haven't done any recently. A long, long time ago I wrote a Common Lisp
FFI tool using a Literate Programming tool called noweb.

It's so old it predates GitHub: http://stuartsierra.com/software/perl-in-lisp

-S

Robert McIntyre

unread,
Dec 7, 2011, 11:59:44 AM12/7/11
to clo...@googlegroups.com
Here's a pew literate programs I've written, as well as the website on
which they are hosted.

http://hg.bortreb.com/abomination/
http://hg.bortreb.com/aurellem/
http://hg.bortreb.com/cortex/

http://www.aurellem.com

I use some emacs scripts to automate tangling and weaving.
http://hg.bortreb.com/org-tools/
http://hg.bortreb.com/repl/

sincerely,
--Robert McIntyre

Andrew

unread,
Jan 11, 2012, 3:38:43 PM1/11/12
to clo...@googlegroups.com
As you know, now I get 
org-babel-execute:clojure:Cannot open load file: swank-clojure

The method org-babel-execute:clojure in my .emacs.d/elpa/org-20111129/ob-clojure.el file says (require 'swank-clojure). Given that the swank-clojure elisp package is deprecated and should not be used what should I do?

Thanks in advance

Andrew

unread,
Jan 12, 2012, 10:25:02 AM1/12/12
to clo...@googlegroups.com
I found [1] from Eric Schulte which says to add certain package archives such that ELPA finds swank-clojure... But what about the swank-clojure elisp package being deprecated? (By the way, I do get further now... the clojure code evaluates)

Phil Hagelberg

unread,
Jan 12, 2012, 11:54:34 AM1/12/12
to clo...@googlegroups.com
Andrew <ach...@gmail.com> writes:

> I found [1] from Eric Schulte which says to add certain package
> archives such that ELPA finds swank-clojure... But what about the
> swank-clojure elisp package being deprecated?

swank-clojure.el is definitely deprecated, but there could still be code
out there in the wild depending upon it. If that's the case then a bug
should be opened for that package.

-Phil

Andrew

unread,
Jan 13, 2012, 2:53:03 AM1/13/12
to clo...@googlegroups.com
Eric asks: The only function ob-clojure uses from swank-clojure is `swank:interactive-eval-region' (used with `slime-eval') in the `org-babel-execute:clojure' function. Which function would now be used to evaluate a region of clojure code? Would `slime-eval-region' suffice?

Stuart Sierra

unread,
Jan 13, 2012, 9:36:29 AM1/13/12
to clo...@googlegroups.com
I was able to get org-babel evaluation working with Clojure. Requires latest versions of Clojure mode, Org mode, and Lein. Check out my dotfiles repo for examples.
https://github.com/stuartsierra/dotfiles

-S

Phil Hagelberg

unread,
Jan 13, 2012, 1:54:29 PM1/13/12
to clo...@googlegroups.com
Andrew <ach...@gmail.com> writes:

Yes, clojure-test-mode uses both slime-eval and slime-eval-async; he
should pick one of these like so:

(defun clojure-test-eval (string &optional handler)
(slime-eval-async `(swank:eval-and-grab-output ,string)
(or handler #'identity)))

(defun clojure-test-eval-sync (string)
(slime-eval `(swank:eval-and-grab-output ,string)))

Actually swank:interactive-eval-region and friends are not elisp
functions; they are Clojure functions.

-Phil

Reply all
Reply to author
Forward
0 new messages