From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Peter Lee Newsgroups: gmane.emacs.help Subject: Re: A little lisp help Date: Tue, 21 Jan 2003 22:34:38 GMT Organization: Prodigy Internet http://www.prodigy.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 1043188536 31283 80.91.224.249 (21 Jan 2003 22:35:36 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 21 Jan 2003 22:35:36 +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 18b6zV-000884-00 for ; Tue, 21 Jan 2003 23:35:33 +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 18b6zU-0002ZW-02 for gnu-help-gnu-emacs@m.gmane.org; Tue, 21 Jan 2003 17:35:32 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!prodigy.com!newsmst01.news.prodigy.com!prodigy.com!postmaster.news.prodigy.com!newssvr12.news.prodigy.com.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 27 User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/21.2 Original-NNTP-Posting-Host: 216.62.199.3 Original-X-Complaints-To: abuse@prodigy.net Original-X-Trace: newssvr12.news.prodigy.com 1043188478 ST000 216.62.199.3 (Tue, 21 Jan 2003 17:34:38 EST) Original-NNTP-Posting-Date: Tue, 21 Jan 2003 17:34:38 EST X-UserInfo1: [[PAPDCAO@RYB\\YQCHN_TTDFRYB@GXLN@GZ_GYO^BSZUSAANVUEAE[YETZPIWWI[FCIZA^NBFXZ_D[BFNTCNVPDTNTKHWXKB@X^B_OCJLPZ@ET_O[G\XSG@E\G[ZKVLBL^CJINM@I_KVIOR\T_M_AW_M[_BWU_HFA_]@A_A^SGFAUDE_DFTMQPFWVW[QPJN Original-Xref: shelby.stanford.edu gnu.emacs.help:109325 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:5848 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:5848 Peter Lee writes: > It works great when I mark a region and type: M-x curly-brace-region. > However, it doesn't work the same way when I M-]. In this case the > first curly brace is never inserted and the formatting is way off. > Anyone know why they would behave differently ? I've solved my problem, the docs advocated using forward-line with negative arg vs. previous-line from a lisp program. When I changed that it started working correctly when bound to a key. (defun curly-brace-region (m p) "Inserts curly braces around region and indents" (interactive "r") (if mark-active (let ((transient-mark-mode nil)) (kill-region m p) (insert-string "{") (newline-and-indent) (insert-string "}") (newline-and-indent) (forward-line -1) (yank 1) (forward-line 1) (indent-region (- m 1) (point) nil)))) Thanks for the help.