Last active
February 3, 2017 23:57
-
-
Save pandeiro/3a86154eee15be3b3dc8fff495274b21 to your computer and use it in GitHub Desktop.
An elisp snippet for quickly getting Clojure and tooling support into Emacs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; | |
;; 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