emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] ob-clojure evaluate error when Org-mode buffer has ns clojure co


From: Tim Cross
Subject: Re: [O] ob-clojure evaluate error when Org-mode buffer has ns clojure code
Date: Sat, 17 Jun 2017 11:46:01 +1000
User-agent: mu4e 0.9.18; emacs 25.2.1

My guess is that cider is not finding the incanter package in the
classpath when the first block attempts to evaluate. Another issue is
that your not using any session options, so your two blocks will be
evaluated in separate environments - not a real problem with your
current example, but will be an issue if you expect to access incanter
functions from separate babel blocks.

There are a number of working parts which all need to be lined up
correctly before babel clojure support will work correctly. Getting
things to work when your just using core clojure functions is fairly
trivial, but getting it to work when you have to pull in other
dependencies can be a little tricky.

You might find this article useful to get started

http://fgiasson.com/blog/index.php/2016/06/21/optimal-emacs-settings-for-org-mode-for-literate-programming/

I also notice you have not set the org-babel-clojure-backend, which you
need to do. My recommendation would be to do the following

1. Create a leinegen project to experiment with i.e.
lein new app my-kk

2. Make sure you can edit and evaluate clojure just using clojure-mode
and cider in emacs

3. Add the incanter package to your project.clj dependencies key

4. Modify core.clj (using clojure-mode) to include the code in your
clojure blocks and run with cider to make sure they work as expected.

5. Create the org file you want to experiment with in the root of your
project. This should ensure that when you try to evaluate clojure
blocks, the cider backend will be loaded with the dependencies in the
project.clj file.

6. Copy the code in your core.clj file into ONE babel src block and see
if you can get it to evaluate correctly. Experiment with the block
configuration options like :output etc. 

7. Break the code up into different blocks and experiment with block
options, especially session options.

Once you get to that point, you should be across the various moving
parts with sufficient understanding to then look at how you can tweak
things to get exactly the behaviour and workflow you want. 

HTH

Tim

address@hidden writes:

> When Org-mode buffer like this:
>
> #+BEGIN_SRC clojure
> (ns my.kk
>   (:require '[incanter.core :as kk]))
> #+END_SRC
>
> #+BEGIN_SRC clojure
> (print "hi")
> (def kkkk "hello")
> #+END_SRC
>
> #+RESULTS:
>
> When I have `(ns ..)` namespace clojure code in buffer, the second `(print
> ..)` clojure result nothing. But when I remove the first src block, the
> `(print ..)` clojure src block works fine.
>
> I'm using Org-mode version from `master` with `use-package` like this:
>
> (use-package org
>   :load-path "~/Code/Emacs/org-mode/lisp/"
>   :pin manual
>   :mode (("\\.org$" . org-mode))
>   :config
>   (use-package org-plus-contrib
>     :load-path "~/Code/Emacs/org-mode/contrib/lisp/"
>     :pin manual)
>   )
>
>
> [stardiviner]           <Hack this world!>      GPG key ID: 47C32433
> IRC(freeenode): stardiviner                     Twitter:  @numbchild
> Key fingerprint = 9BAA 92BC CDDD B9EF 3B36  CB99 B8C4 B8E5 47C3 2433
> Blog: http://stardiviner.github.io/


-- 
Tim Cross



reply via email to

[Prev in Thread] Current Thread [Next in Thread]