paredit.el
) 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.
The latest stable version is available at paredit.el. Reference Table. Release Notes.
Here is one page cheatsheet: PareditCheatsheet
The latest development version (recommended) is available at paredit-beta.el Reference Table.
A spinoff of ParEdit (by the same author) is also now available in the current CVS version of EdWin, MIT Scheme’s Emacs clone. Type M-x paredit-mode RET
to enable it, or add the following code to your .edwin
file to enable it automatically in the Scheme mode:
(add-event-receiver! (ref-variable scheme-mode-hook)
(lambda (buffer)
(enable-buffer-minor-mode! buffer (ref-mode-object paredit))))
(You can substitute other modes for scheme-mode
also.)
Contents
This is what I am currently using to activate paredit in EmacsLispMode? and LispMode? (plus SlimeMode too):
(mapc (lambda (mode)
(let ((hook (intern (concat (symbol-name mode)
"-mode-hook"))))
(add-hook hook (lambda () (paredit-mode +1)))))
'(emacs-lisp lisp inferior-lisp))
(Ok actually I commented it out in my DotEmacs. To know the reasons why, look at #Questions)
Patch
Autoload won’t work as expected since paredit-beta.el lacks the autoload cookie.
Add it to enable this
Questions
I downloaded paredit a long time ago but I did not succeed in using it daily. I have two questions here:
1. What is really *useful* with paredit that we can't get with
standard skeletons ?
Check out the ParEdit reference table mentioned above, especially the parts “Depth-Changing Commands” and “Barfage & Slurpage”. Skeletons are like templates, they’re static. ParEdit can modify the structure of Lisp code. So basically, they have different purposes. – PeterBarabas
2. How do you delete a parenthesis ? I often end up with unbalanced
parentheses when coding something (without paredit) and activating
paredit prevents me from deleting the leading parenthesis.
It takes a bit of getting used to, but after that you’ll never end up with unbalanced parentheses. Just use ParEdit’s commands, e.g. paredit-open-parenthesis, paredit-wrap-sexp instead of manually typing/editing parentheses. ParEdit really makes transforming Lisp code easy. – PeterBarabas
C-u DEL
falls back to ‘backward-delete-char’
. Similarly, you can insert single parentheses with C-q (
and C-q )
– YannHodique
0 commenti:
Post a Comment