-
Notifications
You must be signed in to change notification settings - Fork 0
/
lisp.el
111 lines (94 loc) · 3.76 KB
/
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
;; LISP ---------------------
(defun lisp:shared-modes ()
(smartparens-global-strict-mode 1)
(show-paren-mode 1)
(projectile-mode 1)
(hs-minor-mode 1)
(company-mode 1)
(eldoc-mode 1))
(defun lisp:edit-modes ()
(prettify-symbols-mode 1)
(lisp:shared-modes)
(indent-guide-mode t)
(highlight-parentheses-mode 1)
(rainbow-delimiters-mode 1))
;; Emacs
(defun emacs:hook ()
(lisp:edit-modes))
(add-hook 'emacs-lisp-mode-hook 'emacs:hook)
(define-key emacs-lisp-mode-map (kbd "C-c C-c") 'eval-defun)
(define-key emacs-lisp-mode-map (kbd "C-c TAB") 'company-complete)
(define-key emacs-lisp-mode-map (kbd "C-c SPC") 'helm-company)
;; COMMON LISP -----------------
;(load (expand-file-name "~/.roswell/helper.el"))
;(setq inferior-lisp-program "ros -Q -l ~/.clinit run")
(setq slime-contribs '(slime-fancy
slime-asdf
slime-banner))
(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))
(defun cl:key (map func)
(let ((modes-map (list slime-mode-map slime-repl-mode-map lisp-mode-map))
(map (kbd map)))
(cl-loop for mode-map in modes-map do
(define-key mode-map map func))))
(defun cl:define-all-keys ()
(cl:key "C-c l" 'common-lisp-load-system)
(cl:key "C-c t" 'common-lisp-test-system)
(cl:key "C-c s w" 'common-lisp-pcwd)
(cl:key "C-c i" 'slime-inspect)
(cl:key "C-c d" 'slime-describe-symbol)
(cl:key "C-c <C-tab>" 'slime-complete-symbol)
(cl:key "C-c C-p" 'slime-repl-set-package)
(cl:key "C-c M-p" 'slime-repl-pop-package)
(cl:key "C-c s r" 'slime-restart-inferior-lisp)
(cl:key "C-c m" 'slime-macroexpand-1)
(cl:key "C-c w" 'slime-pprint-eval-last-expression)
(cl:key "C-c M-p" 'slime-repl-set-package)
(cl:key "M-." 'slime-edit-definition)
(cl:key "C-c TAB" 'auto-complete)
(cl:key "C-c SPC" 'ac-complete-with-helm))
(defun cl:edit-mode ()
(lisp:edit-modes)
(cl:define-all-keys)
(set (make-local-variable 'lisp-indent-function)
'common-lisp-indent-function)
(set-up-slime-ac)
(slime-mode)
(set (make-local-variable 'ac-ignore-case) nil))
(defun cl:repl-modes ()
(cl:define-all-keys)
(set-up-slime-ac)
(lisp:shared-modes))
(add-hook 'lisp-mode-hook 'cl:edit-mode)
(add-hook 'slime-repl-mode-hook 'cl:repl-modes)
(add-to-list 'auto-mode-alist '("\\.abclrc\\'" . common-lisp-mode))
(add-to-list 'auto-mode-alist '("\\.sbclrc\\'" . common-lisp-mode))
(defun common-lisp-repl ()
(interactive)
(slime))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; COMMON LISP - PROJECT RELOADING AND TEST HANDLING
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar common-lisp-last-project nil "Project to send to ASDF")
(defun* common-lisp-asdf-op (&key (load-system nil load?)
(test-system nil test?))
(let ((cmd (format (if load? "(ql:quickload %s)" "(asdf:test-system %s)")
common-lisp-last-project)))
(save-some-buffers)
(slime-repl-send-string cmd )
(message cmd)))
(defmacro* common-lisp-op-interactive (fname &rest body)
`(defun ,fname (project)
(interactive (list (read-string "ASDF Project Name: "
common-lisp-last-project)))
(setq common-lisp-last-project project)
,@body))
(common-lisp-op-interactive common-lisp-load-system
(common-lisp-asdf-op :load-system))
(common-lisp-op-interactive common-lisp-test-system
(common-lisp-asdf-op :test-system))
(defun* common-lisp-pcwd ()
(interactive)
(slime-repl-send-string "(UIOP/OS:GETCWD)"))