Last active
August 29, 2015 14:13
-
-
Save deadghost/dcf51ddcc7e4b0bfd09e to your computer and use it in GitHub Desktop.
Set up emacs for common lisp
This file contains 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
Install SBCL. In ubuntu this would be $ sudo apt-get install sbcl | |
Install emacs. In ubuntu this would be $ sudo apt-get install emacs | |
Put the following as your ~/.emacs file: | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;; Dependencies ;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(require 'cl) ; Enable Common Lisp functions(Does not actually use CL) | |
(defalias 'get-alist 'assoc-default) ; get-alist is gone | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;; Utility Functions ;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(defun add-list-to-list (list1 list2) | |
"Same as add-to-list but takes a list of elements to add." | |
(mapcar (lambda (element) (add-to-list list1 element)) | |
list2)) | |
(defun add-hook-functions (hook func-list) | |
"Same as add-hook but takes a list of functions to add." | |
(mapcar (lambda (function) (add-hook hook function)) | |
func-list)) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;; Packages ;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(require 'package) | |
(package-initialize) | |
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/") | |
("marmalade" . "http://marmalade-repo.org/packages/") | |
("melpa-stable" . | |
"http://melpa-stable.milkbox.net/packages/") | |
("melpa" . "http://melpa.milkbox.net/packages/"))) | |
;;; list of required packages | |
(setq packages '( | |
smex | |
rainbow-delimiters ; rainbow paren | |
;; lisp | |
slime | |
ac-slime ; slime auto-complete | |
paredit)) | |
(defun packages-installed-p () | |
"Installs and updates required packages" | |
(loop for pkg in packages | |
when (not (package-installed-p pkg)) do (return nil) | |
finally (return t))) | |
(unless (packages-installed-p) | |
(message "%s" "Refreshing package database...") | |
(package-refresh-contents) | |
(dolist (pkg packages) | |
(when (not (package-installed-p pkg)) | |
(package-install pkg)))) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;; General ;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; highlight matching paren | |
(show-paren-mode 1) | |
;; auto-indent | |
(global-set-key (kbd "RET") 'newline-and-indent) | |
;; rainbow paren | |
(require 'rainbow-delimiters) | |
(add-hook 'prog-mode-hook #'rainbow-delimiters-mode) | |
;; scroll one line at a time (less "jumpy" than defaults) | |
(setq mouse-wheel-scroll-amount '(1 ((shift) . 1)) ;; one line at a time | |
mouse-wheel-progressive-speed nil ;; don't accelerate scrolling | |
mouse-wheel-follow-mouse 't ;; scroll window under mouse | |
scroll-step 1 ;; keyboard scroll one line at a time | |
scroll-conservatively 10000 | |
auto-window-vscroll nil | |
;; horizontal smooth-scrolling | |
hscroll-margin 0 | |
hscroll-step 1) | |
;; can do M-x commands while minibuffer is open | |
(setq enable-recursive-minibuffers t) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;; prog-mode ;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(add-hook-functions 'prog-mode-hook | |
(list 'linum-mode)) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;; Slime ;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; required for slime | |
(setq inferior-lisp-program "sbcl") | |
(require 'slime) | |
(slime-setup) | |
;; required for ac-slime | |
(require 'ac-slime) | |
(add-hook 'slime-mode-hook 'set-up-slime-ac) | |
(add-hook 'slime-repl-mode-hook 'set-up-slime-ac) | |
(eval-after-load "auto-complete" '(add-to-list 'ac-modes 'slime-repl-mode)) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;; Smex ;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(require 'smex) ; Not needed if you use package.el | |
(smex-initialize) ; Can be omitted. This might cause a (minimal) delay | |
; when Smex is auto-initialized on its first run. | |
(global-set-key (kbd "M-x") 'smex) | |
(global-set-key (kbd "M-X") 'smex-major-mode-commands) | |
;; This is your old M-x. | |
(global-set-key (kbd "C-c C-c M-x") 'execute-extended-command) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;; Other ;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; elisp syntax highlighting for files named "emacs" | |
(add-to-list 'auto-mode-alist '("emacs" . emacs-lisp-mode)) | |
;; sh-mode | |
(add-to-list 'auto-mode-alist '("zshrc" . sh-mode)) | |
(add-to-list 'auto-mode-alist '("bashrc" . sh-mode)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment