Difference between revisions of "Paredit-mode"

From WikEmacs
Jump to: navigation, search
(added basic paredit page)
 
(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'.)
(6 intermediate revisions by one user not shown)
Line 2: Line 2:
 
|name=Paredit
 
|name=Paredit
 
|description=structural editing of S-expression data
 
|description=structural editing of S-expression data
 +
|author=Taylor Campbell
 
|maintainer=Taylor Campbell
 
|maintainer=Taylor Campbell
 
|source=http://mumble.net/~campbell/emacs/paredit.el
 
|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''' 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.
 
Paredit helps '''keep parentheses balanced''' and adds many keys for moving S-expressions and moving around in S-expressions.
= Basic setup =
+
 
 +
== Basic setup ==
  
 
<source lang="lisp">
 
<source lang="lisp">
(autoload 'paredit-mode "paredit"
+
(autoload 'enable-paredit-mode "paredit"
      "Minor mode for pseudo-structurally editing Lisp code." t)
+
  "Turn on pseudo-structural editing of Lisp code."
(add-hook 'emacs-lisp-mode-hook      (lambda () (paredit-mode +1)))
+
  t)
(add-hook 'lisp-mode-hook            (lambda () (paredit-mode +1)))
+
(add-hook 'emacs-lisp-mode-hook      'enable-paredit-mode)
(add-hook 'lisp-interaction-mode-hook (lambda () (paredit-mode +1)))
+
(add-hook 'lisp-mode-hook            'enable-paredit-mode)
(add-hook 'scheme-mode-hook          (lambda () (paredit-mode +1)))
+
(add-hook 'lisp-interaction-mode-hook 'enable-paredit-mode)
 +
(add-hook 'scheme-mode-hook          'enable-paredit-mode)
 
</source>
 
</source>
  
= Helpful keybindings =
+
== Helpful keybindings ==
  
 
; {{Keys|C-M-f}}
 
; {{Keys|C-M-f}}
Line 28: Line 31:
 
: Backward sexp
 
: Backward sexp
  
= Common Customization =
+
== Common Customization ==
  
== SLIME REPL ==
+
=== SLIME REPL ===
  
 
<source lang="lisp">
 
<source lang="lisp">
(add-hook 'slime-repl-mode-hook (lambda () (paredit-mode +1)))
+
(add-hook 'slime-repl-mode-hook 'enable-paredit-mode)
 
</source>
 
</source>
  
Line 39: Line 42:
  
 
<source lang="lisp">
 
<source lang="lisp">
;; Stop SLIME's REPL from grabbing DEL,
+
;; Stop SLIME's REPL from grabbing DEL,
;; which is annoying when backspacing over a '('
+
;; which is annoying when backspacing over a '('
(defun override-slime-repl-bindings-with-paredit ()
+
(defun override-slime-repl-bindings-with-paredit ()
  (define-key slime-repl-mode-map
+
  (define-key slime-repl-mode-map
      (read-kbd-macro paredit-backward-delete-key) nil))
+
    (read-kbd-macro paredit-backward-delete-key)
      (add-hook 'slime-repl-mode-hook 'override-slime-repl-bindings-with-paredit)
+
    nil))
 +
(add-hook 'slime-repl-mode-hook 'override-slime-repl-bindings-with-paredit)
 
</source>
 
</source>
  
= See Also =
+
== See Also ==
 +
 
 +
* [[autopair-mode]]
 +
* [[rainbow delimiters]]
 +
* [[electric-pair-mode]]
 +
 
 +
== Project Pages ==
  
= Project Pages =
 
 
* [http://mumble.net/~campbell/emacs/paredit.el Stable Version]
 
* [http://mumble.net/~campbell/emacs/paredit.el Stable Version]
 
* [http://mumble.net/~campbell/emacs/paredit-beta.el Beta Version]
 
* [http://mumble.net/~campbell/emacs/paredit-beta.el Beta Version]
 +
* [http://mumble.net/~campbell/emacs/paredit.html Quick reference]
 +
 +
== Tutorial Pages ==
 +
 +
== External Links ==
  
= Tutorial Pages =
+
* [http://emacswiki.org/emacs/PareditCheatsheet Cheat Sheet]
 +
* [http://www.slideshare.net/mudphone/paredit-preso Paredit Preso]
  
[[Category:Project Management]][[Category:Convenience]][[Category:Third Party Package]]
+
[[Category:Lisp]][[Category:Convenience]][[Category:Third Party Package]]

Revision as of 09:12, 8 July 2013

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