Giter VIP home page Giter VIP logo

clojure-mode's Introduction

Clojure Mode

Provides Emacs font-lock, indentation, and navigation for the Clojure language.

Manual Installation

You can do a manual install by downloading clojure-mode.el and placing it in the ~/.emacs.d/ directory, creating it if it doesn't exist. Then add this to the file ~/.emacs.d/init.el:

(add-to-list 'load-path "~/.emacs.d/")
(require 'clojure-mode)

Marmalade

It can be more convenient to use Emacs's package manager to handle installation for you if you use many elisp libraries. If you have package.el but haven't added Marmalade, the community package source, yet, add this to ~/.emacs.d/init.el:

(require 'package)
(add-to-list 'package-archives
             '("marmalade" . "http://marmalade-repo.org/packages/"))
(package-initialize)

Then do this to load the package listing:

  • M-x eval-buffer
  • M-x package-refresh-contents

If you use a version of Emacs prior to 24 that doesn't include package.el, you can get it from http://bit.ly/pkg-el23.

If you have an older ELPA package.el installed from tromey.com, you should upgrade in order to support installation from multiple sources. The ELPA archive is deprecated and no longer accepting new packages, so the version there (1.7.1) is very outdated.

Clojure Test Mode

This source repository also includes clojure-test-mode.el, which provides support for running Clojure tests (using the clojure.test framework) via SLIME and seeing feedback in the test buffer about which tests failed or errored. The installation instructions above should work for clojure-test-mode as well.

Once you have a SLIME session active (see below), you can run the tests in the current buffer with C-c C-,. Failing tests and errors will be highlighted using overlays. To clear the overlays, use C-c k.

You can jump between implementation and test files with C-c t if your project is laid out in a way that clojure-test-mode expects. Your project root should have a src/ directory containing files that correspond to their namespace. It should also have a test/ directory containing files that correspond to their namespace, and the test namespaces should mirror the implementation namespaces with the addition of "test" as the second-to-last segment of the namespace.

So my.project.frob would be found in src/my/project/frob.clj and its tests would be in test/my/project/test/frob.clj in the my.project.test.frob namespace.

Paredit

Using clojure-mode with paredit is highly recommended. It is also available using package.el from the above archive.

Use paredit as you normally would with any other mode; for instance:

;; (require 'paredit) if you didn't install via package.el
(defun turn-on-paredit () (paredit-mode 1))
(add-hook 'clojure-mode-hook 'turn-on-paredit)

Basic REPL

Use M-x run-lisp to open a simple REPL subprocess using Leiningen. Once that has opened, you can use C-c C-r to evaluate the region or C-c C-l to load the whole file.

If you don't use Leiningen, you can set inferior-lisp-program to a different REPL command.

SLIME

You can also use Leiningen to start an enhanced REPL via SLIME. Install the lein-swank plugin as per the Swank Clojure Readme and then from a file inside a Clojure project run M-x clojure-jack-in. This will handle installing Slime for you; it's best if you do not install it by hand.

License

Copyright © 2007-2012 Jeffrey Chu, Lennart Staflin, Phil Hagelberg, and contributors.

Distributed under the GNU General Public License; see C-h t to view.

clojure-mode's People

Contributors

technomancy avatar ucieee avatar jochu avatar tavisrudd avatar amalloy avatar kototama avatar drone29a avatar samaaron avatar scottjad avatar jeffvalk avatar jsnikeris avatar juergenhoetzel avatar bonifaido avatar pjstadig avatar hugoduncan avatar kriyative avatar scgilardi avatar candera avatar semperos avatar edw avatar joegallo avatar ninjudd avatar michalmarczyk avatar michel-slm avatar thraxil avatar raynes avatar dsedivec avatar danlarkin avatar duck1123 avatar davidbody 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.