all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: chris@grierwhite.com (Christopher J. White)
Subject: Re: A little lisp help
Date: Wed, 22 Jan 2003 17:55:02 -0500	[thread overview]
Message-ID: <m2lm1cu75l.fsf@bluesteel.grierwhite.com> (raw)
In-Reply-To: u1y36b08x.fsf@nospam.org


>>>>> "peter" == Peter Lee <spam@nospam.org> writes:

peter> (defun curly-brace-region (m p)
peter>   "Inserts curly braces around region and indents"
peter>   (interactive "r")
peter>   (if mark-active
peter>       (let ((transient-mark-mode nil))
peter>         (kill-region m p)
peter>         (insert-string "{")
peter>         (newline-and-indent)
peter>         (insert-string "}")
peter>         (newline-and-indent)
peter>         (forward-line -1)
peter>         (yank 1)
peter>         (forward-line 1)
peter>         (indent-region (- m 1) (point) nil))))

peter> Thanks for the help.

You have to be careful when using region end-points
and inserting text.  m and p above are numerical values
that reference offsets from the beginning of the file and
do not "move" when text is inserted before them.

Use markers if you really want to be able to move around
and insert text, but the best method was the previous
suggestion to narrow-to-region.  

...cj

-- 
------------------------------------------------------------------------------
 Christopher J. White                                    chris@grierwhite.com
------------------------------------------------------------------------------ 

  reply	other threads:[~2003-01-22 22:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-21 19:06 A little lisp help Peter Lee
2003-01-21 19:24 ` 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 [this message]
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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2lm1cu75l.fsf@bluesteel.grierwhite.com \
    --to=chris@grierwhite.com \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.