Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 148 lines (104 sloc) 5.292 kb
8be1cc8 @purcell Remove unnecessary autoloads, and tidy up various bits & pieces
purcell authored
1 (autoload 'turn-on-pretty-mode "pretty-mode")
06a4b47 @purcell Modularise init.el
purcell authored
2
8ba1edd @purcell Uniformly apply paredit, hl-sexp etc. in lisp-related modes
purcell authored
3 ;; ----------------------------------------------------------------------------
4 ;; Paredit
5 ;; ----------------------------------------------------------------------------
36ac9f8 @purcell Remove workaround for missing 'enable-paredit-mode
purcell authored
6 (autoload 'enable-paredit-mode "paredit")
8ba1edd @purcell Uniformly apply paredit, hl-sexp etc. in lisp-related modes
purcell authored
7
8
9 (defun maybe-map-paredit-newline ()
10 (unless (or (eq major-mode 'inferior-emacs-lisp-mode) (minibufferp))
11 (local-set-key (kbd "RET") 'paredit-newline)))
12
13 (add-hook 'paredit-mode-hook 'maybe-map-paredit-newline)
14
28b5342 @purcell Use symbol style for 'eval-after-load
purcell authored
15 (eval-after-load 'paredit
8ba1edd @purcell Uniformly apply paredit, hl-sexp etc. in lisp-related modes
purcell authored
16 '(progn
17 ;; These are handy everywhere, not just in lisp modes
18 (global-set-key (kbd "M-(") 'paredit-wrap-round)
19 (global-set-key (kbd "M-[") 'paredit-wrap-square)
20 (global-set-key (kbd "M-{") 'paredit-wrap-curly)
21
22 (global-set-key (kbd "M-)") 'paredit-close-round-and-newline)
23 (global-set-key (kbd "M-]") 'paredit-close-square-and-newline)
24 (global-set-key (kbd "M-}") 'paredit-close-curly-and-newline)
25
26 (dolist (binding (list (kbd "C-<left>") (kbd "C-<right>")
27 (kbd "C-M-<left>") (kbd "C-M-<right>")))
28 (define-key paredit-mode-map binding nil))
29
30 ;; Disable kill-sentence, which is easily confused with the kill-sexp
31 ;; binding, but doesn't preserve sexp structure
32 (define-key paredit-mode-map [remap kill-sentence] nil)
33 (define-key paredit-mode-map [remap backward-kill-sentence] nil)))
34
35
36 ;; Compatibility with other modes
37
93326db @purcell Add autopair-mode and enable it in all but paredit buffers
purcell authored
38 (defadvice enable-paredit-mode (before disable-autopair activate)
39 (setq autopair-dont-activate t)
40 (autopair-mode -1))
41
8ba1edd @purcell Uniformly apply paredit, hl-sexp etc. in lisp-related modes
purcell authored
42 (suspend-mode-during-cua-rect-selection 'paredit-mode)
8cbd1bc @purcell Convert each 'load' call for initialisation scripts into a 'require'
purcell authored
43
44
8ba1edd @purcell Uniformly apply paredit, hl-sexp etc. in lisp-related modes
purcell authored
45 ;; Use paredit in the minibuffer
f21305d @purcell Enable paredit-mode when executing eval-expression in the minibuffer
purcell authored
46 (add-hook 'minibuffer-setup-hook 'conditionally-enable-paredit-mode)
8ba1edd @purcell Uniformly apply paredit, hl-sexp etc. in lisp-related modes
purcell authored
47
58fc416 @purcell Ensure paredit still works in minibuffer when eldoc-eval is active
purcell authored
48 (defvar paredit-minibuffer-commands '(eval-expression
49 pp-eval-expression
50 eval-expression-with-eldoc)
8ba1edd @purcell Uniformly apply paredit, hl-sexp etc. in lisp-related modes
purcell authored
51 "Interactive commands for which paredit should be enabled in the minibuffer.")
52
f21305d @purcell Enable paredit-mode when executing eval-expression in the minibuffer
purcell authored
53 (defun conditionally-enable-paredit-mode ()
8ba1edd @purcell Uniformly apply paredit, hl-sexp etc. in lisp-related modes
purcell authored
54 "Enable paredit during lisp-related minibuffer commands."
55 (if (memq this-command paredit-minibuffer-commands)
56 (enable-paredit-mode)))
f21305d @purcell Enable paredit-mode when executing eval-expression in the minibuffer
purcell authored
57
494a7bb @purcell Suspend paredit-mode during cua rectangle selection
purcell authored
58
f21305d @purcell Enable paredit-mode when executing eval-expression in the minibuffer
purcell authored
59
8ba1edd @purcell Uniformly apply paredit, hl-sexp etc. in lisp-related modes
purcell authored
60 ;; ----------------------------------------------------------------------------
61 ;; Hippie-expand
62 ;; ----------------------------------------------------------------------------
7146ee4 @purcell Hook symbol completion into auto-complete and hippie-expand in emacs-lis...
purcell authored
63 (defun set-up-hippie-expand-for-elisp ()
24d8b44 @purcell Tidy up set-up-hippie-expand-for-elisp
purcell authored
64 "Locally set `hippie-expand' completion functions for use with Emacs Lisp."
65 (make-local-variable 'hippie-expand-try-functions-list)
cdc9f97 @purcell Add lisp completion sources to the end of the source lists, since dabbre...
purcell authored
66 (add-to-list 'hippie-expand-try-functions-list 'try-complete-lisp-symbol t)
67 (add-to-list 'hippie-expand-try-functions-list 'try-complete-lisp-symbol-partially t))
7146ee4 @purcell Hook symbol completion into auto-complete and hippie-expand in emacs-lis...
purcell authored
68
153fd62 @purcell Also colourise auto-complete results for elisp symbols in emacs-lisp-mod...
purcell authored
69
70 ;; ----------------------------------------------------------------------------
71 ;; Auto-complete tweaks for emacs-lisp mode
72 ;; ----------------------------------------------------------------------------
73
74 (defface ac-symbol-menu-face
75 '((t (:background "lightgray" :foreground "darkgreen")))
76 "Face for slime candidate menu."
77 :group 'auto-complete)
78
79 (defface ac-symbol-selection-face
80 '((t (:background "darkgreen" :foreground "white")))
81 "Face for the slime selected candidate."
82 :group 'auto-complete)
83
84 ;; Modify ac-source-symbols to add colours
28b5342 @purcell Use symbol style for 'eval-after-load
purcell authored
85 (eval-after-load 'auto-complete
153fd62 @purcell Also colourise auto-complete results for elisp symbols in emacs-lisp-mod...
purcell authored
86 '(progn
9c48287 @purcell Rework auto-completion config, including adding pop-up documentation for...
purcell authored
87 (add-to-list 'ac-source-symbols '(candidate-face . ac-symbol-menu-face))
88 (add-to-list 'ac-source-symbols '(selection-face . ac-symbol-selection-face))))
153fd62 @purcell Also colourise auto-complete results for elisp symbols in emacs-lisp-mod...
purcell authored
89
9050c48 @purcell More elegantly disable kill-sentence and C-<arrow> keys when paredit is ...
purcell authored
90
5caffc0 @purcell Automatically byte-recompile .el files when saving
purcell authored
91 (defun maybe-byte-compile ()
92 (when (and (eq major-mode 'emacs-lisp-mode) buffer-file-name)
93 (save-excursion (byte-compile-file buffer-file-name))))
94
95
96 (add-hook 'after-save-hook 'maybe-byte-compile)
97
98
8ba1edd @purcell Uniformly apply paredit, hl-sexp etc. in lisp-related modes
purcell authored
99 ;; ----------------------------------------------------------------------------
100 ;; Highlight current sexp
101 ;; ----------------------------------------------------------------------------
aeaa5cd @purcell Add hl-sexp, and activate it wherever paredit is enabled
purcell authored
102
376a19a @purcell Monkey-patch hl-sexp to prevent flickery behaviour
purcell authored
103 ;; Prevent flickery behaviour due to hl-sexp-mode unhighlighting before each command
28b5342 @purcell Use symbol style for 'eval-after-load
purcell authored
104 (eval-after-load 'hl-sexp
a542b78 @purcell Autoload hl-sexp
purcell authored
105 '(defadvice hl-sexp-mode (after unflicker (turn-on) activate)
106 (when turn-on
107 (remove-hook 'pre-command-hook #'hl-sexp-unhighlight))))
376a19a @purcell Monkey-patch hl-sexp to prevent flickery behaviour
purcell authored
108
2fd3d5b @purcell Make M-. and M-, work in elisp like they do in slime
purcell authored
109
8ba1edd @purcell Uniformly apply paredit, hl-sexp etc. in lisp-related modes
purcell authored
110
111 ;; ----------------------------------------------------------------------------
112 ;; Enable desired features for all lisp modes
113 ;; ----------------------------------------------------------------------------
114
115 (defun smp-lisp-setup ()
911a35f @purcell Don't enable hl-sexp by default in lispy modes
purcell authored
116 "Enable features useful in any Lisp mode."
8ba1edd @purcell Uniformly apply paredit, hl-sexp etc. in lisp-related modes
purcell authored
117 (enable-paredit-mode)
118 (turn-on-eldoc-mode)
119 (turn-on-pretty-mode))
120
121 (defun smp-emacs-lisp-setup ()
122 "Enable features useful when working with elisp."
ed3969e @purcell Enable rainbow-delimiters-mode when editing emacs lisp (but not Clojure)
purcell authored
123 (rainbow-delimiters-mode t)
8ba1edd @purcell Uniformly apply paredit, hl-sexp etc. in lisp-related modes
purcell authored
124 (elisp-slime-nav-mode t)
125 (set-up-hippie-expand-for-elisp)
126 (ac-emacs-lisp-mode-setup)
127 (checkdoc-minor-mode))
128
129 (let* ((elispy-hooks '(emacs-lisp-mode-hook
130 ielm-mode-hook))
131 (lispy-hooks (append elispy-hooks '(lisp-mode-hook
132 inferior-lisp-mode-hook
133 lisp-interaction-mode-hook))))
134 (dolist (hook lispy-hooks)
135 (add-hook hook 'smp-lisp-setup))
136 (dolist (hook elispy-hooks)
137 (add-hook hook 'smp-emacs-lisp-setup)))
138
139
d40fb00 @purcell Add eldoc-eval
purcell authored
140 (require 'eldoc-eval)
141
8ba1edd @purcell Uniformly apply paredit, hl-sexp etc. in lisp-related modes
purcell authored
142 (add-to-list 'auto-mode-alist '("\\.emacs-project$" . emacs-lisp-mode))
143
144 (define-key emacs-lisp-mode-map (kbd "C-x C-a") 'pp-macroexpand-last-sexp)
46d93dd @purcell Ensure etags is loaded for M-. and M-, in emacs-lisp
purcell authored
145
2fd3d5b @purcell Make M-. and M-, work in elisp like they do in slime
purcell authored
146
8cbd1bc @purcell Convert each 'load' call for initialisation scripts into a 'require'
purcell authored
147 (provide 'init-lisp)
Something went wrong with that request. Please try again.