help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: elisp, replace-regexp and re-search-forward


From: Bourgneuf Francois
Subject: RE: elisp, replace-regexp and re-search-forward
Date: Mon, 1 Oct 2007 11:08:56 +0200

 You don't need to use a regexp.
(query-replace "\n" "\n\n") will do the job
Bour9

> -----Message d'origine-----
> De : 
> address@hidden
> g 
> [mailto:help-gnu-emacs-bounces+francois.bourgneuf=groupe-mma.f
> address@hidden De la part de Seweryn Kokot
> Envoyé : lundi 1 octobre 2007 09:57
> À : address@hidden
> Objet : elisp, replace-regexp and re-search-forward
> 
> 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?
> 
> 
> 
> 
> _______________________________________________
> help-gnu-emacs mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
> 
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]