-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-elisp.el
111 lines (89 loc) · 3.79 KB
/
setup-elisp.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
;;; emacs lisp, of course
(use-package elisp-slime-nav
:ensure elisp-slime-nav
:bind (("C-c M-." . de/jump-to-elisp-definition))
:config
(defun de/jump-to-elisp-definition ()
"See the elisp definition of something.
This is a weird way to do this, but switching to a temp buffer
and trying to slime-nav with nothing at point always prompts for
a symbol."
(interactive)
(with-temp-buffer
(call-interactively #'elisp-slime-nav-find-elisp-thing-at-point))))
(require 'elisp-slime-nav)
(require 'paredit)
(require 'setup-lisps)
(defvar de/scratch-yeah ";; ___ ___ _________ _____ __ __ __
;; \\ \\ / / / ______/ / | | | | | | |
;; \\ \\ / / / / / | | | | | | |
;; \\ \\ / / / / / | | | | | | |
;; \\ \\/ / / / / | | | | | | |
;; \\ / / /____ / | | |_____| | | |
;; / / / _____/ / | | _______ | | |
;; / / / / / _____ | | | | | | |
;; / / / / / / | | | | | | | |
;; / / / / / / | | | | | | |__|
;; __/ / / /______ / / | | | | | | __
;; |____/ /_________/ /__/ |__| |__| |__| |__|
;;
" "YEAH")
(defun de/elisp-scratch-buffer-message ()
"create the message at the top of an elisp scratch buffer"
(format ";;; elisp scratch buffer, opened %s
;;; in %s
"
(format-time-string "%A, %B %d, %Y at %H:%M %p")
default-directory))
(setq initial-scratch-message (de/elisp-scratch-buffer-message))
(defun de/switch-to-scratch-buffer-here ()
"create an elisp interaction buffer in the current directory (if necessary)
and switch to it."
(interactive)
(let ((local-scratch-buffer-name (format "*scratch: %s*" default-directory)))
(if (get-buffer local-scratch-buffer-name)
(switch-to-buffer local-scratch-buffer-name)
(de/initialize-scratch-buffer-here local-scratch-buffer-name))))
(defun de/initialize-scratch-buffer-here (name)
"create a elisp interaction buffer in the current directory"
(switch-to-buffer (get-buffer-create name))
(goto-char (point-min))
(lisp-interaction-mode)
(insert (de/elisp-scratch-buffer-message)))
(defun de/elisp-mode-hook ()
"hook for emacs lisp mode"
(paredit-mode 1) ;; use paredit
(elisp-slime-nav-mode 1)
(eldoc-mode 1)
(paredit-mode 1)
(define-key evil-insert-state-local-map (kbd "S-SPC")
(lambda () (interactive) (insert "-")))
(define-key evil-emacs-state-local-map (kbd "S-SPC")
(lambda () (interactive) (insert "-")))
(define-key evil-normal-state-local-map (kbd "M-.") 'elisp-slime-nav-find-elisp-thing-at-point)
(turn-on-elisp-slime-nav-mode)
(local-set-key (kbd "C-c C-j") 'imenu)
(local-set-key (kbd "C-c eb") #'eval-buffer)
;; (if (fboundp 'helm)
;; (local-set-key (kbd "C-M-i") 'helm-lisp-completion-at-point))
(local-set-key (kbd "C-RET") 'de/evil-paredit-open-below))
(add-hook 'emacs-lisp-mode-hook 'de/elisp-mode-hook)
(add-hook 'emacs-lisp-mode-hook 'de/lisps-mode-hook)
;; (add-hook 'ielm-mode-hook 'de/elisp-mode-hook)
;; (add-hook 'ielm-mode-hook 'de/lisps-mode-hook)
(add-hook 'lisp-mode-hook 'de/lisps-mode-hook)
(add-hook 'minibuffer-setup-hook
(defun de/minibuffer-setup-hook ()
(local-set-key (kbd "S-SPC") (lambda () (interactive) (insert "-")))
(if (eq this-command 'eval-expression)
(progn ;; Setup paredit for elisp
(paredit-mode 1)
(paredit-open-round)))))
(add-hook 'ielm-mode-hook
(defun de/ielm-mode-hook ()
"Hook for setting up IELM (interactive emacs lisp mode)"
(de/elisp-mode-hook)))
(require 'setup-lisps)
(add-hook 'emacs-lisp-mode-hook 'de/lisps-mode-hook)
(add-hook 'lisps-mode-hook 'de/lisps-mode-hook)
(provide 'setup-elisp)