From: Peter Lee <spam@nospam.org>
Subject: A little lisp help
Date: Tue, 21 Jan 2003 19:06:45 GMT [thread overview]
Message-ID: <u1y36cofu.fsf@nospam.org> (raw)
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.
next reply other threads:[~2003-01-21 19:06 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-21 19:06 Peter Lee [this message]
2003-01-21 19:24 ` A little lisp help Henrik Enberg
2003-01-21 20:13 ` Stefan Monnier <foo@acm.com>
2003-01-21 20:32 ` Peter Lee
2003-01-21 20:41 ` Barry Margolin
2003-01-21 21:52 ` Peter Lee
2003-01-21 22:34 ` Peter Lee
2003-01-22 22:55 ` Christopher J. White
2003-01-22 23:02 ` Stefan Monnier <foo@acm.com>
2003-01-24 7:39 ` Jim Janney
2003-01-27 14:48 ` Stefan Monnier <foo@acm.com>
2003-01-22 8:24 ` Kai Großjohann
-- strict thread matches above, loose matches on Subject: below --
2003-01-24 16:51 Bingham, Jay
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=u1y36cofu.fsf@nospam.org \
--to=spam@nospam.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).