[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
A little lisp help
From: |
Peter Lee |
Subject: |
A little lisp help |
Date: |
Tue, 21 Jan 2003 19:06:45 GMT |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) Emacs/21.2 |
I'm learning lisp atm, and decided to write a macro to insert curly
braces around a region and re-indent.
So for this,
if (x)
y=0;
z=0;
w=0;
*
setting mark at begining of line y=0 and setting point at * would
produce the following.
if (x)
{
y=0;
z=0;
w=0;
}
This is what I have so far, but it doesn't work very well.
(defun curly-brace-region (mark point)
"Inserts curly braces around region and indents"
(interactive "r")
(message "point=%d, mark=%d" point mark)
(goto-char mark)
(insert-string "{")
(newline-and-indent)
(goto-char point)
(insert-string "}")
(newline-and-indent)
(fill-region mark point))
There's probably functions to make this trivial and I'm just missing
them due to lack of familiarity.
TIA.
- A little lisp help,
Peter Lee <=