I followed the instructions here and wrote the following org-mode file:
#+BEGIN_SRC emacs-lisp
(princ (concat (format "Emacs version:\n%s\n" (emacs-version))
(format "\norg version: %s\n" (org-version))))
#+END_SRC
#+RESULTS:
: Emacs version:
: GNU Emacs 25.1.1 (x86_64-apple-darwin13.4.0, NS appkit-1265.21 Version 10.9.5 (Build 13F1911))
: of 2016-09-17
:
: org version: 9.0.5
#+BEGIN_SRC clojure :results value
(* 6 7)
#+END_SRC
#+RESULTS:
* COMMENT org babel settings
Local variables:
org-confirm-babel-evaluate: nil
End:
As you can see, the evaluation of the emacs-lisp block works and produces the
expected output. Incidentally, it also reports the versions of things I'm using. However, the clojure source block, when evaluated, leaves
Code block returned no value.
I tried many different Clojure expressions in the code block, such as printlns and more. Nothing shows up in the NREPL window, and the results in org mode are always the same: the message above in the minibuffer.
in the emacs minibuffer. Here are the specific steps I took:
$ lein new clojure-example
$ cd clojure-example
$ emacs clojure.example.org
keyboarded in the file above
run emacs command cider-jack-in
That produces a repl window with the following version info:
;; Connected to nREPL server - nrepl://localhost:52695
;; CIDER 0.15.0snapshot (package: 20170403.402), nREPL 0.2.12
;; Clojure 1.8.0, Java 1.8.0_121
etc.
put emacs cursor inside each block and type C-c C-c, which is bound to
org-babel-execute-src-block
Prior to that, I inserted the following code in my emacs initialization file:
(require 'org)
(require 'ob-clojure)
(org-babel-do-load-languages
'org-babel-load-languages
'( (clojure . t)
(emacs-lisp . t)
))
(setq org-babel-clojure-backend 'cider)
(require 'cider)
According to the cited instructions.
I'd be grateful for any help.
Yes, in the current stable release (9.0.5), the org-mode clojure backend is broken and does not work. I submitted a patch which has been applied and I expect will be in the next release.
See https://emacs.stackexchange.com/questions/30857/clojure-code-evaluation-in-org-mode-produces-no-output/31169#31169
Related
I am currently working through the Land of Lisp examples and have run into a compile exception: package EXT does not exist
from this line I suspect:
(ext:shell (concatenate 'string "dot -Tpng -O" fname))
I am running my repl inside emacs with slime and am unsure as to how to remedy this after some googling of the error.
Any help would be much appreciated.
It was in fact that SBCL was set as the default lisp program in emacs.
By replacing:
(setq inferior-lisp-program "/usr/bin/sbcl")
To:
(setq inferior-lisp-program "/usr/bin/clisp")
in my emacs configuration file fixed the issue. (On a Unix system at least)
I would like to learn some Clojure, and I'm trying to run REPL from Emacs, but I cannot get it to work.
I have created a basic project with lein. I open the generated file core.clj in Emacs, and when I try to run the REPL from it (by running the cider-jack-in), I just get the message:
Symbol's function definition is void: nil
I have toggled the debug-on-error, and the backtrace (several last lines) is:
Debugger entered--Lisp error: (void-function nil)
nil(#<buffer core.clj>)
#[257 " !\203\207\300\207" [exclude predicate] 3 "\n\n(fn ELT)"](#<buffer core.clj>)
seq-map(#[257 " !\203\207\300\207" [exclude predicate] 3 "\n\n(fn ELT)"] (#<buffer core.clj> #<buffer *Minibuf-1*> #<buffer *Warnings*> #<buffer *GNU Emacs*> #<buffer *scratch*> #<buffer *Minibuf-0*> #<buffer *Messages*> #<buffer *code-conversion-work*> #<buffer *Echo Area 0*> #<buffer *Echo Area 1*>))
seq-filter(#[257 "r\211q\210\300\301!)\207" [derived-mode-p cider-repl-mode] 3 "\n\n(fn BUFFER)"] (#<buffer core.clj> #<buffer *Minibuf-1*> #<buffer *Warnings*> #<buffer *GNU Emacs*> #<buffer *scratch*> #<buffer *Minibuf-0*> #<buffer *Messages*> #<buffer *code-conversion-work*> #<buffer *Echo Area 0*> #<buffer *Echo Area 1*>))
cider-repl-buffers()
cider-find-reusable-repl-buffer(nil "~/Development/languages/clojure/playground/test1/")
cider-jack-in(nil)
When I run lein run in the terminal, the code runs properly.
Also, when I run lein repl in the terminal, the REPL runs properly with the following info:
nREPL server started on port 62741 on host 127.0.0.1 - nrepl://127.0.0.1:62741
REPL-y 0.3.7, nREPL 0.2.12
Clojure 1.8.0
Java HotSpot(TM) 64-Bit Server VM 1.8.0_45-b14
Lein has Cider version 0.14.0, while Emacs has downloaded version 0.15.0.
Could anyone help me figure out which part of the setup I'm missing, or what I'm doing wrong?
Thanks for the help!
EDIT: Bellow is the contents of Emacs init file, with comments removed:
(require 'package)
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/") t)
(add-to-list 'package-archives
'("tromey" . "http://tromey.com/elpa/") t)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
(package-initialize)
(when (not package-archive-contents)
(package-refresh-contents))
(defvar ido-cur-item nil)
(defvar ido-default-item nil)
(defvar ido-cur-list nil)
(defvar predicate nil)
(defvar inherit-input-method nil)
(defvar my-packages
'(paredit
clojure-mode
clojure-mode-extra-font-locking
cider
ido-ubiquitous
smex
projectile
rainbow-delimiters
tagedit
magit))
(if (eq system-type 'darwin)
(add-to-list 'my-packages 'exec-path-from-shell))
(dolist (p my-packages)
(when (not (package-installed-p p))
(package-install p)))
(add-to-list 'load-path "~/.emacs.d/vendor")
(add-to-list 'load-path "~/.emacs.d/customizations")
(load "shell-integration.el")
(load "navigation.el")
(load "ui.el")
(load "editing.el")
(load "misc.el")
(load "elisp-editing.el")
(load "setup-clojure.el")
(load "setup-js.el")
here's my lein debugging checklist:
remove any meniton of cider-nrepl from ~/.lein/profiles.clj
run lein repl from a terminal, then cider-connect to localhost from emacs
run lein upgrade
upgrade to the latest version of the cider emacs package
ask in the cider channel on clojure slack before submitting bug reports.
It used to be required to add cider's nrepl middleware to your lein profile to get it included on the classpath when lein start up. Now cider does this automatically and chooses the matching version on it's own. Many people are following instructions from when this was a manual process and run into problems like this, so check that first.
Remove your ~/.emacs.d directory and install spacemacs instead
git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d
Once you run Emacs with the new spacemacs ~/.emacs.d directory, you can simply open up a Clojure file and spacemacs will load in the Clojure layer for you.
More details can be found at spacemacs.org and in this tutorial on clojure development with spacemacs https://practicalli.github.io/spacemacs/
So the error appears to be in cider-client.el at line 102 https://github.com/clojure-emacs/cider/blob/master/cider-client.el#L99. I've got the whole defun posted below:
(defun cider-repl-buffers ()
"Return the list of REPL buffers."
(seq-filter
(lambda (buffer)
(with-current-buffer buffer (derived-mode-p 'cider-repl-mode)))
(buffer-list)))
Can you visit this file in your CIDER copy and ensure that this definition looks like this. This code is just looking for repl buffers and is filtering the buffers that emacs knows about.
I installed Geiser from source and following this SO answer set the path to drracket.
Here is my part of my .emacs file. I'm on a GNU/linux distribution.
;;;;;;;;;;;;;;;;
;Geiser
;downloaded geiser from git rep and make install
;;;;;;;;;;;;;;
(add-to-list 'load-path "/usr/local/share/emacs/site-lisp/")
(require 'geiser-install)
(setq geiser-racket-binary "/usr/racket/bin/drracket")
In emacs when I M-x run-racket on emacs I get the following error:
drracket: unknown switch: -i
Do you have any solution?
Of course the solution was to use
(setq geiser-racket-binary "/usr/racket/bin/racket")
instead of :
(setq geiser-racket-binary "/usr/racket/bin/drracket")
I've setup Emacs + Ensime for scala.
I'm able to start sbt console inside emacs using C-c C-v s
If i start scala console inside emacs using C-c C-v z, I get the following error
Welcome to Scala version 2.9.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_33).
scala>
Failed to initialize compiler: class scala.reflect.BeanInfo not found
What is the fix for this error? How do i get scala console running inside Emacs?
I've ran into a similar error recently, but here's how I worked around it (but I don't know how to fix it, so this is only half the answer). What I did was to customize the ensime-inf-default-cmd-line variable to have the value: '("sbt" "console"). Which will indeed start the interactive Scala environment.
EDIT:
Here's relevant parts from .emacs, but I'm not sure it will matter / will be the same in every install:
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
;;
;; more stuff ...
;; I'm not sure this line is correct / makes any difference
'(ensime-inf-cmd-template (quote ("sbt" "console" "-classpath" :classpath)))
;; This variable is used to launch the interpreter
'(ensime-inf-default-cmd-line (quote ("sbt" "console"))))
(require 'scala-mode2)
(add-to-list 'auto-mode-alist '("\\.scala$" . scala-mode))
(add-to-list 'load-path "~/.emacs.d/ensime/elisp/")
(require 'ensime)
(add-hook 'scala-mode-hook 'ensime-scala-mode-hook)
I've installed scala-mode2 from MELPA. Installed sbt version 0.12.0 by downloading an RPM from their site. I had previously JRE and JDK installed, the active version is OpenJDK 1.7. Scala installed is 2.9.2. I don't know how to identify Ensime's version :|
I have the following from the slime repl (no clojure.contib functions found):
M-X slime
user=> (:require 'clojure.contrib.string)
nil
user=> (doc clojure.contrib.string/blank?)
java.lang.Exception: Unable to resolve var: clojure.contrib.string/blank? in this context (NO_SOURCE_FILE:10)
And the following when starting clojure from console (but here everything is being found OK):
adr#~/clojure/cloj-1.2$ java -cp /home/adr/clojure/cloj-1.2/clojure.jar:/home/adr/clojure/cloj-1.2/clojure-contrib.jar -server clojure.main
user=> (:require 'clojure.contrib.string)
nil
user=> (doc clojure.contrib.string/blank?)
-------------------------
clojure.contrib.string/blank?
([s])
True if s is nil, empty, or contains only whitespace.
nil
In my .emacs I have the following:
(setq inferior-lisp-program "java -cp /home/adr/clojure/cloj-1.2/clojure.jar:/home/adr/clojure/cloj-1.2/clojure-contrib.jar -server clojure.main")
My clojure jars (1.2) are at '/home/adr/clojure/cloj-1.2'.
I;m a newbie with emacs, been following some tutorials. For some time I've been trying to use the clojure.contrib library from Emacs, but "M-X slime" finds no clojure.contrib. Please, help
Edit: if that would help, now i saw that when using M-X slime there is a message:
(progn (load "/home/adr/.emacs.d/elpa/slime-20100404/swank-loader.lisp" :verbose t) (funcall (read-from-string "swank-loader:init")) (funcall (read-from-string "swank:start-server") "/tmp/slime.4493" :coding-system "iso-latin-1-unix"))
Clojure 1.2.0
user=> java.lang.Exception: Unable to resolve symbol: progn in this context (NO_SOURCE_FILE:1)
Edit2: But there is no such error message if I use M-X slime-connect after having started a "lein swank" in a directory (though even starting with "M-X slime-connect" there are no clojure-contrib libraries found in the REPL (though they are downloaded by leiningen as dependency)).
This line:
(progn (load "/home/adr/.emacs.d/elpa/slime-20100404/swank-loader.lisp" :verbose t) (funcall (read-from-string "swank-loader:init")) (funcall (read-from-string "swank:start-server") "/tmp/slime.4493" :coding-system "iso-latin-1-unix"))
is Common Lisp, not Clojure, but since you set inferior-lisp-program to Clojure, slime can't start a swank server.
See the following sections in swank-clojure project:
Connecting with SLIME
Embedding
swank-clojure.el
The functionality you want is probably in swank-clojure.el, but it is not recommended anymore.
As you're already using ELPA:
add-to-list 'package-archives
'("technomancy" . "http://repo.technomancy.us/emacs/") t)
M-x package-install ;(slime-repl)
M-x slime-connect
It seems to me that I was using the wrong way to "require" libraries in the REPL (due to my inexperience with clojure); when using a syntax such as:
user=> (require 'clojure.contrib.string)
nil
user=> (clojure.contrib.string/blank? "asd")
false
all the libraries are being found OK (no matter if using "M-X slime" for a non-swank REPL or "M-X slime-connect" for a swank server). So it was entirely my mistake (I have found hints about my mistake at this stackoverflow answer: Why do I get an error when I run (use 'clojure.contrib.repl-utils)?)