Skip to content

Instantly share code, notes, and snippets.

@pandeiro
Last active February 3, 2017 23:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pandeiro/3a86154eee15be3b3dc8fff495274b21 to your computer and use it in GitHub Desktop.
Save pandeiro/3a86154eee15be3b3dc8fff495274b21 to your computer and use it in GitHub Desktop.
An elisp snippet for quickly getting Clojure and tooling support into Emacs
;;
;; Evaluate the form below or add it to your Emacs initialization file
;; to add Clojure support to Emacs.
;;
;; Required system dependencies:
;; - JDK 1.7+
;; - wget
;;
(let* ((github-url "https://raw.githubusercontent.com/")
(lein-url (concat github-url "technomancy/leiningen/stable/bin/lein"))
(lein-install-path (concat user-emacs-directory "lein"))
(lein-installed? (not (string= "" (shell-command-to-string "which lein")))))
(when (not lein-installed?)
(message "Installing Clojure runtime (may take a while)...")
(shell-command-to-string
(concat "wget -O " lein-install-path " " lein-url))
(shell-command-to-string
(concat "chmod +x " lein-install-path))
(shell-command-to-string
lein-install-path))
(when (or (not (boundp 'package-archives))
(not (assoc "melpa" package-archives))
(not (fboundp 'cider-jack-in)))
(message "Configuring Emacs package manager...")
(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t)
(package-initialize)
(package-refresh-contents))
(message "Checking Clojure support in Emacs...")
(when (not (package-installed-p 'cider))
(package-install 'cider)
(customize-set-variable 'cider-allow-jack-in-without-project t))
(when (not lein-installed?)
(customize-set-variable 'cider-lein-command lein-install-path))
(when (not (package-installed-p 'paredit))
(package-install 'paredit)
(add-hook 'clojure-mode-hook 'enable-paredit-mode)
(add-hook 'cider-repl-mode-hook 'enable-paredit-mode))
(when (not (package-installed-p 'company))
(package-install 'company)
(add-hook 'clojure-mode-hook 'company-mode)
(add-hook 'cider-repl-mode-hook 'company-mode))
(message "Ready. Run `M-x cider-jack-in' to start a Clojure REPL."))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment