This repository has been archived by the owner on Nov 30, 2022. It is now read-only.
forked from technomancy/emacs-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
starter-kit-lisp.el
87 lines (74 loc) · 3.09 KB
/
starter-kit-lisp.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
;;; starter-kit-lisp.el --- Some helpful Lisp code
;;
;; Part of the Emacs Starter Kit
(define-key read-expression-map (kbd "TAB") 'lisp-complete-symbol)
(define-key lisp-mode-shared-map (kbd "C-c l") "lambda")
(define-key lisp-mode-shared-map (kbd "RET") 'reindent-then-newline-and-indent)
(define-key lisp-mode-shared-map (kbd "C-\\") 'lisp-complete-symbol)
(define-key lisp-mode-shared-map (kbd "C-c v") 'eval-buffer)
(defface esk-paren-face
'((((class color) (background dark))
(:foreground "grey50"))
(((class color) (background light))
(:foreground "grey55")))
"Face used to dim parentheses."
:group 'starter-kit-faces)
;;; Emacs Lisp
(add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)
(add-hook 'emacs-lisp-mode-hook 'esk-remove-elc-on-save)
(defun esk-remove-elc-on-save ()
"If you're saving an elisp file, likely the .elc is no longer valid."
(make-local-variable 'after-save-hook)
(add-hook 'after-save-hook
(lambda ()
(if (file-exists-p (concat buffer-file-name "c"))
(delete-file (concat buffer-file-name "c"))))))
(define-key emacs-lisp-mode-map (kbd "M-.") 'find-function-at-point)
;;; Clojure
(eval-after-load 'find-file-in-project
'(add-to-list 'ffip-patterns "*.clj"))
(defun clojure-project (path)
"Setup classpaths for a clojure project and starts a new SLIME session.
Kills existing SLIME session, if any."
(interactive (list
(ido-read-directory-name
"Project root: "
(locate-dominating-file default-directory "src"))))
(require 'swank-clojure)
(require 'slime)
(when (get-buffer "*inferior-lisp*")
(kill-buffer "*inferior-lisp*"))
(add-to-list 'swank-clojure-extra-vm-args
(format "-Dclojure.compile.path=%s"
(expand-file-name "target/classes/" path)))
(setq swank-clojure-binary nil
swank-clojure-jar-path (expand-file-name "target/dependency/" path)
swank-clojure-extra-classpaths
(append (mapcar (lambda (d) (expand-file-name d path))
'("src/" "target/classes/" "test/"))
(let ((lib (expand-file-name "lib" path)))
(if (file-exists-p lib)
(directory-files lib t ".jar$"))))
slime-lisp-implementations
(cons `(clojure ,(swank-clojure-cmd) :init swank-clojure-init)
(remove-if #'(lambda (x) (eq (car x) 'clojure))
slime-lisp-implementations)))
(message "Deprecated: use swank-clojure-project from swank-clojure.")
(save-window-excursion
(slime)))
;;; Enhance Lisp Modes
(eval-after-load 'paredit-mode
;; need a binding that works over SSH
'(define-key paredit-mode-map (kbd "M-)") 'paredit-forward-slurp-sexp))
(dolist (x '(scheme emacs-lisp lisp clojure))
(font-lock-add-keywords
(intern (concat (symbol-name x) "-mode"))
'(("(\\|)" . 'esk-paren-face)))
(add-hook
(intern (concat (symbol-name x) "-mode-hook"))
(lambda ()
(paredit-mode +1)
(idle-highlight +1)
(run-coding-hook))))
(provide 'starter-kit-lisp)
;; starter-kit-lisp.el ends here