From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Seweryn Kokot Newsgroups: gmane.emacs.help Subject: elisp, replace-regexp and re-search-forward Date: Mon, 1 Oct 2007 07:56:54 +0000 (UTC) Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1191225454 32078 80.91.229.12 (1 Oct 2007 07:57:34 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 1 Oct 2007 07:57:34 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Oct 01 09:57:31 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 1IcG9h-0001mi-3b for geh-help-gnu-emacs@m.gmane.org; Mon, 01 Oct 2007 09:57:29 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IcG9d-0001eO-A3 for geh-help-gnu-emacs@m.gmane.org; Mon, 01 Oct 2007 03:57:25 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IcG9M-0001bA-FI for help-gnu-emacs@gnu.org; Mon, 01 Oct 2007 03:57:08 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IcG9L-0001Yx-9n for help-gnu-emacs@gnu.org; Mon, 01 Oct 2007 03:57:08 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IcG9L-0001Yl-5O for help-gnu-emacs@gnu.org; Mon, 01 Oct 2007 03:57:07 -0400 Original-Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IcG9K-0007de-LR for help-gnu-emacs@gnu.org; Mon, 01 Oct 2007 03:57:06 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1IcG9E-0001Mv-15 for help-gnu-emacs@gnu.org; Mon, 01 Oct 2007 07:57:02 +0000 Original-Received: from nat-katowicka.po.opole.pl ([217.173.199.130]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 01 Oct 2007 07:57:00 +0000 Original-Received: from skokot by nat-katowicka.po.opole.pl with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 01 Oct 2007 07:57:00 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 32 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: main.gmane.org User-Agent: Loom/3.14 (http://gmane.org/) X-Loom-IP: 217.173.199.130 (Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7) X-Detected-Kernel: Linux 2.6, seldom 2.4 (older, 4) 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:48012 Archived-At: Hello, I try to write a function that operate on a region and which inserts a newline between each line, for example. from: aaa bbb ccc to: aaa bbb ccc ------- 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)) however in Emacs help for replace-regexp I see that it is not good to use replace-regexp function. Instead it is recommended to use re-search-forward and replace-match. So I try with such a function, but it does not work. (defun my-test-two (beg end) (interactive "r") (while (re-search-forward "\n" end t) (replace-match "\n\n" nil nil))) Any idea what is wrong?