Paredit-mode

From WikEmacs
Revision as of 14:12, 8 July 2013 by 74.50.56.165 (talk) (Suggest enable-paredit-mode rather than (lambda () (paredit-mode +1)). Fix indentation. Call the quick reference what it is; don't dignify it by calling it `documentation'.)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Paredit
Description structural editing of S-expression data
Author Taylor Campbell
Maintainer Taylor Campbell
Source http://mumble.net/~campbell/emacs/paredit.el

Paredit is a minor mode for performing structured editing of S-expression data. The typical example of this would be Lisp or Scheme source code.

Paredit helps keep parentheses balanced and adds many keys for moving S-expressions and moving around in S-expressions.

Basic setup

(autoload 'enable-paredit-mode "paredit"
  "Turn on pseudo-structural editing of Lisp code."
  t)
(add-hook 'emacs-lisp-mode-hook       'enable-paredit-mode)
(add-hook 'lisp-mode-hook             'enable-paredit-mode)
(add-hook 'lisp-interaction-mode-hook 'enable-paredit-mode)
(add-hook 'scheme-mode-hook           'enable-paredit-mode)

Helpful keybindings

[C-M-f]
Forward sexp
[C-M-b]
Backward sexp

Common Customization

SLIME REPL

(add-hook 'slime-repl-mode-hook 'enable-paredit-mode)

SLIME’s REPL has the very annoying habit of grabbing DEL which interferes with paredit’s normal operation. To alleviate this problem use the following code:

;; Stop SLIME's REPL from grabbing DEL,
;; which is annoying when backspacing over a '('
(defun override-slime-repl-bindings-with-paredit ()
  (define-key slime-repl-mode-map
    (read-kbd-macro paredit-backward-delete-key)
    nil))
(add-hook 'slime-repl-mode-hook 'override-slime-repl-bindings-with-paredit)

See Also

Project Pages

Tutorial Pages

External Links