From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: chris@grierwhite.com (Christopher J. White) Newsgroups: gmane.emacs.help Subject: Re: A little lisp help Date: Wed, 22 Jan 2003 17:55:02 -0500 Organization: Posted via Supernews, http://www.supernews.com Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1043276106 22538 80.91.224.249 (22 Jan 2003 22:55:06 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 22 Jan 2003 22:55:06 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18bTlt-0005qc-00 for ; Wed, 22 Jan 2003 23:55:01 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18bTmf-00080V-02 for gnu-help-gnu-emacs@m.gmane.org; Wed, 22 Jan 2003 17:55:49 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!nntp.cs.ubc.ca!logbridge.uoregon.edu!tethys.csu.net!nntp!sn-xit-02!sn-xit-03!sn-xit-01!sn-post-02!sn-post-01!supernews.com!corp.supernews.com!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.090007 (Oort Gnus v0.07) Emacs/21.2 (powerpc-apple-darwin) Cancel-Lock: sha1:SpOy+4Nva8mAzQ5RNRLYDZvQGA8= Original-X-Complaints-To: abuse@supernews.com Original-Lines: 35 Original-Xref: shelby.stanford.edu gnu.emacs.help:109364 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:5886 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:5886 >>>>> "peter" == Peter Lee 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 ------------------------------------------------------------------------------