From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Bourgneuf Francois" Newsgroups: gmane.emacs.help Subject: RE: elisp, replace-regexp and re-search-forward Date: Mon, 1 Oct 2007 11:08:56 +0200 Message-ID: <8A921A5AACA1A64F936C730FC1F81721011F0AE8@zw67246c.societe.mma.fr> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1191230184 14623 80.91.229.12 (1 Oct 2007 09:16:24 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 1 Oct 2007 09:16:24 +0000 (UTC) To: Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Oct 01 11:16:21 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IcHNz-0007Gg-12 for geh-help-gnu-emacs@m.gmane.org; Mon, 01 Oct 2007 11:16:19 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IcHNu-0008Oq-BN for geh-help-gnu-emacs@m.gmane.org; Mon, 01 Oct 2007 05:16:14 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IcHGv-00012w-TG for help-gnu-emacs@gnu.org; Mon, 01 Oct 2007 05:09:01 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IcHGt-0000zT-Tr for help-gnu-emacs@gnu.org; Mon, 01 Oct 2007 05:09:01 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IcHGt-0000zF-Fu for help-gnu-emacs@gnu.org; Mon, 01 Oct 2007 05:08:59 -0400 Original-Received: from relais.groupe-mma.fr ([195.101.229.226] helo=razor73-1.mma-rg.fr) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IcHGt-0002oK-1u for help-gnu-emacs@gnu.org; Mon, 01 Oct 2007 05:08:59 -0400 Original-Received: from ZW67253I.societe.mma.fr by razor73-1.mma-rg.fr with ESMTP id ASI79764; Mon, 1 Oct 2007 11:08:56 +0200 (CEST) Original-Received: from ZW67246C.societe.mma.fr ([10.200.3.36]) by ZW67253I.societe.mma.fr with Microsoft SMTPSVC(5.0.2195.6713); Mon, 1 Oct 2007 11:08:56 +0200 content-class: urn:content-classes:message X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 Thread-Topic: elisp, replace-regexp and re-search-forward Thread-Index: AcgEAL/uWK/+F0VSRDGEufKyiz82VQACItiQ X-OriginalArrivalTime: 01 Oct 2007 09:08:56.0726 (UTC) FILETIME=[B2474B60:01C8040A] X-Detected-Kernel: Genre and OS details not recognized. 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:48013 Archived-At: You don't need to use a regexp. (query-replace "\n" "\n\n") will do the job Bour9 > -----Message d'origine----- > De :=20 > help-gnu-emacs-bounces+francois.bourgneuf=3Dgroupe-mma.fr@gnu.or > g=20 > [mailto:help-gnu-emacs-bounces+francois.bourgneuf=3Dgroupe-mma.f > r@gnu.org] De la part de Seweryn Kokot > Envoy=E9 : lundi 1 octobre 2007 09:57 > =C0 : help-gnu-emacs@gnu.org > Objet : elisp, replace-regexp and re-search-forward >=20 > Hello, >=20 > I try to write a function that operate on a region and which=20 > inserts a newline > between each line, for example. > from: > aaa > bbb > ccc > to: > aaa >=20 > bbb >=20 > ccc > ------- >=20 > My first attempt is the following function which does the job > (defun my-test (beg end) > (interactive "r") > (replace-regexp "\n" "\n\n" nil beg end)) >=20 > however in Emacs help for replace-regexp I see that it is not=20 > good to use > replace-regexp function. Instead it is recommended to use=20 > re-search-forward and > replace-match. So I try with such a function, but it does not work. >=20 > (defun my-test-two (beg end) > (interactive "r") > (while (re-search-forward "\n" end t) > (replace-match "\n\n" nil nil))) >=20 > Any idea what is wrong? >=20 >=20 >=20 >=20 > _______________________________________________ > help-gnu-emacs mailing list > help-gnu-emacs@gnu.org > http://lists.gnu.org/mailman/listinfo/help-gnu-emacs >=20 >=20