Code Monkey home page Code Monkey logo

swank-clojure's Introduction

Swank Clojure

Swank Clojure is a server that allows SLIME (the Superior Lisp Interaction Mode for Emacs) to connect to Clojure projects. To use it you must launch a swank server, then connect to it from within Emacs.

Usage

Add Swank Clojure to your project as a development dependency to your project. If you are using Leiningen, add it to your project.clj file under :dev-dependencies:

:dev-dependencies [[swank-clojure "1.2.1"]]

Once you run "lein deps" you can launch a swank server from the command line:

$ lein swank [PORT=4005] [HOST=localhost]

Note that the lein-swank plugin now comes with Swank Clojure; it does not need to be specified as a separate dependency any more.

If you're using Maven, add this to your pom.xml under the <dependencies> section:

<dependency>
  <groupId>swank-clojure</groupId>
  <artifactId>swank-clojure</artifactId>
  <version>1.2.1</version>
</dependency>

Then you can launch a swank server like so:

$ mvn -o clojure:swank

Note that due to a bug in clojure-maven-plugin, you currently cannot include it as a test-scoped dependency; it must be compile-scoped. You also cannot change the port from Maven; it's hard-coded to 4005.

Connecting with SLIME

Install the "slime-repl" package from ELPA using package.el. When you perform the installation, you will see warnings related to the byte-compilation of the packages. This is normal; the packages will work just fine even if there are problems byte-compiling it upon installation.

There is a known bug in the latest release of package.el that can cause packages to fail to install in certain circumstances. The version with the fixes applied is available on Github.

Then you should be able to connect to the swank server you launched:

M-x slime-connect

It will prompt you for your host (usually localhost) and port. It may also warn you that your SLIME version doesn't match your Swank version; this should be OK.

Having old versions of SLIME either manually installed or installed using a system-wide package manager like apt-get may cause issues.

SLIME Commands

Commonly-used SLIME commands:

  • C-c TAB: Autocomplete symbol at point
  • C-x C-e: Eval the form under the point
  • C-c C-k: Compile the current buffer
  • M-.: Jump to the definition of a var
  • C-c S-i: Inspect a value
  • C-c C-m: Macroexpand the call under the point
  • C-c C-d C-d: Look up documentation for a var
  • C-c C-z: Switch from a Clojure buffer to the repl buffer
  • C-c M-p: Switch the repl namespace to match the current buffer
  • C-c C-w c: List all callers of a given function

Pressing "v" on a stack trace a debug buffer will jump to the file and line referenced by that frame if possible.

Note that SLIME was designed to work with Common Lisp, which has a distinction between interpreted code and compiled code. Clojure has no such distinction, but many of the SLIME commands retain parallel load/compile commands that have the same effect in the context of Clojure.

Embedding

You can embed Swank Clojure in your project, start the server from within your own code, and connect via Emacs to that instance:

(ns my-app
  (:require [swank.swank]))
(swank.swank/start-repl) ;; optionally takes a port argument

Then use M-x slime-connect to connect from within Emacs.

You can also start the server directly from the "java" command-line launcher if you AOT-compile it and specify "swank.swank" as your main class.

Debug Repl

For now, see Hugo Duncan's blog for an explanation of this excellent feature. Further documentation to come.

swank-clojure.el

Previous versions of Swank Clojure bundled an Elisp library called swank-clojure.el that provided ways to launch your swank server from within your Emacs process. While swank-clojure is still distributed with the project, it's a much more error-prone way of doing things than the method outlined above.

If you have configured your Emacs to use M-x swank-clojure-project then it should still work, but it's not recommended for new users.

Community

The mailing list and clojure channel on Freenode are the best places to bring up questions/issues.

Contributions are preferred as either Github pull requests or using "git format-patch". Please use standard indentation with no tabs, trailing whitespace, or lines longer than 80 columns. See this post on submitting good patches for some tips. If you've got some time on your hands, reading this style guide wouldn't hurt either.

License

Copyright (C) 2008-2010 Jeffrey Chu, Phil Hagelberg, Hugo Duncan, and contributors

Licensed under the EPL. (See the file COPYING.)

swank-clojure's People

Contributors

bmillare avatar cosmin avatar drewr avatar drone29a avatar fbreuer avatar gilaras avatar hugoduncan avatar im-continuum avatar jeffvalk avatar jochu avatar joodie avatar juergenhoetzel avatar khinsen avatar kreg avatar kspi avatar marktriggs avatar njordhov avatar purcell avatar rnewman avatar robewald avatar rottcodd avatar stuarthalloway avatar swannodette avatar tayssir avatar tcrayford avatar technomancy avatar the-kenny avatar ubolonton avatar ucieee avatar ztellman avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.