From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tim Cross Subject: Re: ob-clojure evaluate error when Org-mode buffer has ns clojure code Date: Sat, 17 Jun 2017 11:46:01 +1000 Message-ID: <87zid7bd46.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53288) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dM2oY-0006KN-9e for emacs-orgmode@gnu.org; Fri, 16 Jun 2017 21:46:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dM2oX-0005jB-6R for emacs-orgmode@gnu.org; Fri, 16 Jun 2017 21:46:14 -0400 Received: from mail-pf0-x234.google.com ([2607:f8b0:400e:c00::234]:33958) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dM2oW-0005j4-Vi for emacs-orgmode@gnu.org; Fri, 16 Jun 2017 21:46:13 -0400 Received: by mail-pf0-x234.google.com with SMTP id s66so29581311pfs.1 for ; Fri, 16 Jun 2017 18:46:12 -0700 (PDT) In-reply-to: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: "numbchild@gmail.com" Cc: Org-mode 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 numbchild@gmail.com 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] 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