forked from purcell/emacs.d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init-paredit.el
56 lines (41 loc) · 2.13 KB
/
init-paredit.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
(require-package 'paredit)
(autoload 'enable-paredit-mode "paredit")
(defun maybe-map-paredit-newline ()
(unless (or (memq major-mode '(inferior-emacs-lisp-mode cider-repl-mode))
(minibufferp))
(local-set-key (kbd "RET") 'paredit-newline)))
(add-hook 'paredit-mode-hook 'maybe-map-paredit-newline)
(after-load 'paredit
(diminish 'paredit-mode " Par")
(dolist (binding (list (kbd "C-<left>") (kbd "C-<right>")
(kbd "C-M-<left>") (kbd "C-M-<right>")))
(define-key paredit-mode-map binding nil))
;; Disable kill-sentence, which is easily confused with the kill-sexp
;; binding, but doesn't preserve sexp structure
(define-key paredit-mode-map [remap kill-sentence] nil)
(define-key paredit-mode-map [remap backward-kill-sentence] nil)
;; Allow my global binding of M-? to work when paredit is active
(define-key paredit-mode-map (kbd "M-?") nil))
;; Compatibility with other modes
(suspend-mode-during-cua-rect-selection 'paredit-mode)
;; Use paredit in the minibuffer
;; TODO: break out into separate package
;; http://emacsredux.com/blog/2013/04/18/evaluate-emacs-lisp-in-the-minibuffer/
(add-hook 'minibuffer-setup-hook 'conditionally-enable-paredit-mode)
(defvar paredit-minibuffer-commands '(eval-expression
pp-eval-expression
eval-expression-with-eldoc
ibuffer-do-eval
ibuffer-do-view-and-eval)
"Interactive commands for which paredit should be enabled in the minibuffer.")
(defun conditionally-enable-paredit-mode ()
"Enable paredit during lisp-related minibuffer commands."
(if (memq this-command paredit-minibuffer-commands)
(enable-paredit-mode)))
;; ----------------------------------------------------------------------------
;; Enable some handy paredit functions in all prog modes
;; ----------------------------------------------------------------------------
(require-package 'paredit-everywhere)
(add-hook 'prog-mode-hook 'paredit-everywhere-mode)
(add-hook 'css-mode-hook 'paredit-everywhere-mode)
(provide 'init-paredit)