From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: luca.spinacci@seleniacomms.com Newsgroups: gmane.emacs.help Subject: Inserting spaces after/before braces... Date: Tue, 19 Apr 2005 11:14:22 +0200 Message-ID: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Trace: sea.gmane.org 1113902155 16610 80.91.229.2 (19 Apr 2005 09:15:55 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 19 Apr 2005 09:15:55 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Apr 19 11:15:52 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DNon0-0006Q0-Cl for geh-help-gnu-emacs@m.gmane.org; Tue, 19 Apr 2005 11:13:02 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DNorG-0006sc-Ga for geh-help-gnu-emacs@m.gmane.org; Tue, 19 Apr 2005 05:17:26 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DNopT-00061f-Lz for help-gnu-emacs@gnu.org; Tue, 19 Apr 2005 05:15:35 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DNopP-0005za-4b for help-gnu-emacs@gnu.org; Tue, 19 Apr 2005 05:15:34 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DNopO-00042E-FC for help-gnu-emacs@gnu.org; Tue, 19 Apr 2005 05:15:30 -0400 Original-Received: from [81.120.201.7] (helo=relay1.seleniacomms.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DNoqR-0008BQ-AJ for help-gnu-emacs@gnu.org; Tue, 19 Apr 2005 05:16:35 -0400 Original-Received: from gefss001 ([10.1.202.2]) by relay1.seleniacomms.com (8.12.11/8.12.11) with ESMTP id j3J9DeNE020530 for ; Tue, 19 Apr 2005 11:13:41 +0200 (CEST) Sensitivity: Original-To: help-gnu-emacs@gnu.org X-MIMETrack: Serialize by Router on mgeg01/S/EXT/MM1(Release 6.5.3|September 14, 2004) at 04/19/2005 11:14:27 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:25814 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:25814 I wrote a function to insert a space after an open brace and before a close brace in a selection. I would like it to work better skipping those occurences where I already have a space before or after the brace. (defun brace-and-space(start end) (interactive "*r") (save-excursion (save-restriction (narrow-to-region start end) (goto-char start) (while (re-search-forward "(" nil t) (replace-match "( " nil t)) (goto-char start) (while (re-search-forward ")" nil t) (replace-match " )" nil t))))) So, for instance if((a==1)) => if(_(_a==1_)_) as expected if(_(_a==1_)_ ) => if(__(__a==1__ ) __ ) as expected but I would like it to skip the replace operation having a space after/before the brace Any suggestions? Thank you very much. Luca.