I created a new project with lein. I open core.clj in emacs. I make sure to run M-x clojure-mode, and M-x nrepl-enable-on-existing-clojure-buffers.
Then I run M-x nrepl-jack-in and in the mini-buffer I get
Starting nREPL server...
followed by a message such as:
Connected. You're bound to be unhappy if you optimize everything.
-Donald Knuth
I see that the buffer name is *nrepl*, but the buffer does not contain a Clojure Repl and instead is completely blank.
If I type anything (meaning anything at all,) I get:
Wrong type argument: integer-or-marker-p, nil
If I switch back to my core.clj buffer, and hit C-c C-l,I get the namespaced name of the last function in my buffer in the minibuffer as a result. And if I put my cursor at the end of a function definition and hit C-x C-e, I get:
CompilerException java.lang.RuntimeException: Unable to resolve
symbol: x in this context, compiling:(NO_SOURCE_PATH:1:1)
I tried making a new lein directory with no dependencies using lein new project-name and tried the same steps as above and got the same results.
What else can I check and/or what am I doing wrong?
EDIT: Additional Information
When I type something into the empty *nrepl* buffer and try to press C-x C-e on what I typed, in the mini buffer I get the message:
No Lisp subprocess; see variable `inferior-lisp-buffer'
Also, I am running:
GNU Emacs 24.3.1
Leiningen 2.1.2 on Java 1.6.0_27 OpenJDK 64-Bit Server VM
I just fixed this exact issue on my own setup. Move your .emacs.d to a backup location, and make a backup copy of your .emacs. Make a new .emacs with only the following lines:
(require 'package)
(add-to-list 'package-archives
'("marmalade" .
"http://marmalade-repo.org/packages/"))
(package-initialize)
(require 'clojure-mode)
(require 'nrepl)
Once you install nrepl and clojure-mode via running M-x package-list-packages and installing their respective entries, you will be able to use nrepl.
Add your custom .emacs back in one logical unit at a time, and you should be able to figure out where the conflict was and eliminate it. Be suspicious of anything related to slime / swank.
Related
I've recently updated SLIME from package-list-packages in Emacs. However, when I try to run it using M-x slime, I get this:
(progn (load "/home/koz/.emacs.d/elpa/slime-20140913.730/swank-loader.lisp" :verbose t) (funcall (read-from-string "swank-loader:init")) (funcall (read-from-string "swank:start-server") "/tmp/slime.3081"))
*
; loading #P"/home/koz/.emacs.d/elpa/slime-20140913.730/swank-loader.lisp"
;;
;; Error while compiling /home/koz/.emacs.d/elpa/slime-20140913.730/swank/backend.lisp:
;; Failed to find the TRUENAME of /home/koz/.emacs.d/elpa/slime-20140913.730/swank/backend.lisp:
;; No such file or directory
;; Aborting.
;; *
I still have a REPL afterwards, but I think this is very strange, and I'd like to know what's going on and why.
On Freenode's #lisp channel, I talked to one person who agreed that the current version of SLIME in MELPA (20140913.730) is broken. On my system, the whole $HOME/.emacs.d/elpa/slime-20140913.730/swank/ directory is missing, which presumably is why it can't compile Lisp files found therein.
Other members of the channel suggested installing SLIME from Quicklisp; I did that and it worked, although the SLIME version there is slightly older (dated 2014-08-01). Here is what I did (I didn't already have Quicklisp installed); adjust to match your system and preferences:
Uninstall SLIME from Emacs's package list (do M-x list-packages, go to the line for SLIME, press d, then press x).
Visit http://www.quicklisp.org/beta/ and download the file in the green box (in my case, it went in ~/Downloads).
Upgrade SBCL to 1.2.2 or later. This is probably overkill.
Launch sbcl.
Evaluate (load "~/Downloads/quicklisp.lisp").
Evaluate (quicklisp-quickstart:install); optionally, if you don't want it to go in ~/quicklisp, add :path "~/.quicklisp/" (substituting whatever directory you actually do want it installed in).
Install SLIME and SWANK by evaluating (ql:quickload "swank").
Optional: evaluate (ql:add-to-init-file) to patch your .sbclrc to always load Quicklisp in SBCL.
Exit SBCL with Ctrl+D.
Adjust your Emacs config file as shown in SLIME's readme. For the path entry, use "~/quicklisp/dists/quicklisp/software/slime-2.9" (adjusted for whatever path you installed Quicklisp in).
Restart Emacs and M-x slime should work.
This is caused by losing the swank sub-directory in your slime folder. To fix it, you can simple download slime from github and copy the folder swank to your slime installed path, for your situation is /home/koz/.emacs.d/elpa/slime-20140913.730/ then restart your slime. it will be load correctly.
I just installed the emacs package dired-details from inside emacs via
M-x package-list-packages
clicked on the package name and then install in the newly opened buffer.
Then I put those lines into my .emacs:
(require 'dired-details)
(setq-default dired-details-hidden-string ">---< ")
(dired-details-install)
When I restart emacs, I get the following error:
File error: Cannot open load file, dired-details
The interesting thing is, that when I mark the code region above and apply
M-x eval-region
everything works as expected.
emacs --version
>> GNU Emacs 24.3.1
package version:
dired-details-20130328.1119
Packages you installed with package.el need to be initialized if you want to access them during emacs initialization.
Add the line
(package-initialize)
to the very beginning of your .emacs .
Also follow phil's recommendation and see the variable
package-enable-at-startup
I am in the process of configuring slime for emacs. So far I have read about basic functionality for common lisp such as C-c C-q which invokes the command slime-close-parens-at-point which places the proper number of parens where your mouse is. Another command that seemed cool was invoked by C-c C-c and it would pass the code you are editing in a buffer to the REPL, and "compile" it.
Why won't these commands work for me?
Anyway, I have downloaded slime via M-x list-packages and do not seem to have this functionality (C-h w and then any of these commands tells me that these commands do note exist). So, I saw a bunch of other slime extensions such as slime-repl', 'slime-fuzzy' and 'hippie-expand-slime'. So I again usedM-x list-packages` and downloaded them.
Still I did not have these commands. Here is the content of my emacs file relevant to slime:
;;;Common Lisp and Slime
(add-to-list 'load-path "/home/s2s2/.emacs.d/elpa/slime-20130626.1151")
(add-to-list 'load-path "/home/s2s2/.emacs.d/elpa/slime-repl-201000404")
(add-to-list 'load-path "/home/s2s2/.emacs.d/elpa/hippie-expand-slime-20130226.1656")
(add-to-list 'load-path "/home/s2s2/.emacs.d/elpa/slime-fuzzy-20100404")
(require 'slime)
(setq slime-lisp-implementations
`((sbcl ("/usr/bin/sbcl"))
(ecl ("/usr/bin/ecl"))
(clisp ("/usr/bin/clisp" "-q -I"))))
(require 'slime-repl)
(require 'slime-fuzzy)
(require 'hippie-expand-slime)
When I execute M-x slime I get the following message in the inferior-lisp buffer where I can execute common lisp code (however, shouldn't this be the slime-repl since I required it?):
STYLE-WARNING: redefining EMACS-INSPECT (#<BUILT-IN-CLASS T>) in DEFMETHOD
STYLE-WARNING:
Implicitly creating new generic function STREAM-READ-CHAR-WILL-HANG-P.
WARNING: These Swank interfaces are unimplemented:
(DISASSEMBLE-FRAME SLDB-BREAK-AT-START SLDB-BREAK-ON-RETURN)
;; Swank started at port: 46533.
Then a slime-error buffer is created with the contents:
Invalid protocol message:
Symbol "CREATE-REPL" not found in the SWANK package.
Line: 1, Column: 28, File-Position: 28
Stream: #<SB-IMPL::STRING-INPUT-STREAM {10056B9C33}>
(:emacs-rex (swank:create-repl nil) "COMMON-LISP-USER" t 5)
How should I modify my emacs file to give me the functionality of those commands? In my emacs file am I not loading the necessary files? Do I need to install an additional package?
Or if you have better ideas let me know!
If you need more information let me know! All help is much appreciated!
Swank is the server in common lisp (in your case, it's SBCL) as the backend of SLIME. SLIME is the frontend in emacs lisp.
slime-repl won't work by itself, it needs the corresponding plugin at the server side. You should ensure that there is swank-repl.lisp in the directory of swank. It's swank-repl.lisp including the "CREATE-REPL" function.
Your slime-repl doesn't work. So you cannot see the *slime-repl* buffer in emacs.
I prefer to use SLIME from the its official GIT repo (https://github.com/slime/slime).
How to install the slime into emacs under Win7?
I download a compact package with '.tgz'. But it seems for linux. But there is really not one thing for windows(win 32 OS).
I unfold this package and I find there are lots of documents.
It's actually the same as for other operating systems, as far as I can tell. (At least, it always worked for me under FreeBSD/ArchLinux/Win7.) First, you unpack to a location you like, then add something like this to your .emacs (assuming you unpacked somewhere under your user directory):
(add-to-list 'load-path "~/my/path/to/slime/")
;; (add-to-list 'load-path "~/my/path/to/slime/contrib/") ; for optional features
(slime-setup
;; '(slime-fancy slime-asdf slime-references ; optional features
;; slime-indentation slime-xref-browser)
)
(setq slime-lisp-implementations
'((ccl ("~/path/to/ccl/wx86cl"))
(clisp ("~/path/to/clisp-2.49/clisp" "-modern"))) ; giving a command arg
slime-default-lisp 'ccl)
Restart Emacs or type C-x C-e behind each of these toplevel forms. Then, type M-x slime RET (or C-u M-x slime RET if you want to choose between the implementations in slime-lisp-implementations, otherwise slime-lisp-default will be used) and it should just work (it does for me). The setting of slime-lisp-implementations is optional – you can also give the path to your lisp implementation executable by hand when starting Slime.
Assuming you want to use Slime with CL, since there is no Clojure tag. If you want to use it with Clojure, things are unfortunately a little different and both versions don't play very nicely together. The recommended way for use with Clojure, last time I checked, would be installation using the package system of Emacs 24 or, if you're using an older version, ELPA (which is essentially the same).
This worked for me,
Get a Slime copy from https://github.com/slime/slime, either by git clone or by downloading the zip. Unzip and save it in D:/myuser/slime-2.13, for example
Download and install CLISP
Add this to the .emacs file, usually located in C:/users/myuser/AppData/Roaming:
; This is the path where you've saved Slime in the first step
(add-to-list 'load-path "D:/myuser/slime-2.13/")
(require 'slime-autoloads)
; This is the path where CLISP was installed.
; Use Progra~1 for "Program Files" and Progra~2 for "Program Files (x86)"
(setq inferior-lisp-program "/C/Progra~2/clisp-2.49/clisp.exe")
I can run emacs and start slime (with M-x slime). At this point I get the REPL in the inferior-lisp buffer and can run lisp there. But when I open up lisp code in another buffer none of the slime-goodness works (C-x C-e, C-c C-k etc.) and I keep seeing this in the Messages buffer (with an increasing count-number):
slime-connection: Not connected.
Polling
"/var/folders/B9/B9B5J15dH+aNt5J5gkROEk+++TI/-Tmp-/slime.3202".. (Abort with `M-x
slime-abort-connection'.) [69 times]
Makes me think slime is not connecting to the correct lisp interpreter, but since I am very new to emacs and lisp I am stuck here. My setup is:
Mac OSX Snow Leopard
GNU Emacs 23.2
emacs-starter-kit
very few customizations: arnab.el and the files under arnab/
The following is what I did to get Common Lisp and Clojure to work in the same Emacs installation, along with the excellent emacs-starter-kit. This won't let you use both at the same time (you have to restart Emacs to switch from CL to Clojure or vice versa)
I believe that the version of SLIME in ELPA is old, but works for Clojure. Newer version of SLIME won't work for Clojure. Additionally, this version of SLIME seems to be stripped down (no swank-loader.el?) and won't work with Common Lisp.
These are the steps I did to get this to work, it's just what worked for me. All of the bits are under active development, so I think breakage in this area is pretty likely.
With a fresh Emacs (no configuration at all, so move anything .emacs somewhere else for the moment) install ELPA:
http://tromey.com/elpa/install.html
From within Emacs, install the packages "slime" and "slime-repl". (M-x package-list-packages then C-s slime then i to select and x to install)
Move the files in ~/.emacs.d/elpa/slime-20100404 and ~/.emacs.d/elpa/slime-repl-20100404 to a new directory like ~/hacking/lisp/elpa-slime.
Throw out the ELPA install: $ rm -rf .emacs.d.
Now clone the emacs-starter-kit and move it to .emacs.d. I only did this with a fresh copy from technomancy's Github, so try that first if you have problems.
Get the latest SLIME with CVS:
cvs -d :pserver:anonymous:anonymous#common-lisp.net:/project/slime/cvsroot co cvs-slime
I don't think OS X comes with CVS installed, so you'll need to install it from Macports, Homebrew or something.
I put cvs-slime in ~/hacking/lisp.
Hopefully it's obvious what the Emacs Lisp below does:
(defun slime-common-lisp ()
(interactive)
(setq inferior-lisp-program "/usr/local/bin/sbcl") ; your Common Lisp impl
(add-to-list 'load-path "~/hacking/lisp/cvs-slime/") ; your SLIME from CVS directory
(require 'slime)
(slime-setup '(slime-repl))
(slime))
(defun slime-clojure ()
(interactive)
(add-to-list 'load-path "~/hacking/lisp/elpa-slime")
(require 'slime)
(slime-setup '(slime-repl))
(slime-connect "localhost" 4005))
For Clojure you'd have to start the Clojure runtime and swank-clojure on port 4005, I think using Leiningen is the approved method:
Create a new project:
$ lein new project
$ cd project
In project.clj:
(defproject newclj "1.0.0-SNAPSHOT"
:description "FIXME: write"
:dependencies [[org.clojure/clojure "1.2.0"]
[org.clojure/clojure-contrib "1.2.0"]]
:dev-dependencies [[swank-clojure "1.2.1"]])
Then:
$ lein deps
$ lein swank
Edited to add:
If you find that Paredit in the SLIME REPL is broken while using this setup, check this out:
http://www.emacswiki.org/emacs/ParEdit#toc3
At least one other potential issue with this is that, AFAICT, if you open a Common Lisp source file and then start SLIME, you won't be able to send forms from the first buffer to the SLIME buffer. So open a SLIME buffer before opening any Common Lisp source files, and it should work. This doesn't seem to apply to Clojure.
References:
emacs setup for both clojure and common lisp with slime-fancy (slime-autodoc)
https://github.com/technomancy/swank-clojure/issues/closed#issue/31/comment/544166
If u have correctly install slime in your system then better use sbcl and add the following line in your ~/.emacs
(setq inferior-lisp-program "/usr/bin/sbcl")
/usr/bin/sbcl can be different according to your sbcl installation path.