forked from purcell/emacs.d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init-paredit.el
51 lines (37 loc) · 1.88 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
(require-package 'paredit)
(autoload 'enable-paredit-mode "paredit")
(defun maybe-map-paredit-newline ()
(unless (or (memq major-mode '(inferior-emacs-lisp-mode nrepl-mode))
(minibufferp))
(local-set-key (kbd "RET") 'paredit-newline)))
(add-hook 'paredit-mode-hook 'maybe-map-paredit-newline)
(eval-after-load 'paredit
'(progn
(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)))
;; Compatibility with other modes
(suspend-mode-during-cua-rect-selection 'paredit-mode)
;; Use paredit 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)
(provide 'init-paredit)