From: "Bourgneuf Francois" <francois.bourgneuf@groupe-mma.fr>
To: <help-gnu-emacs@gnu.org>
Subject: RE: elisp, replace-regexp and re-search-forward
Date: Mon, 1 Oct 2007 11:08:56 +0200 [thread overview]
Message-ID: <8A921A5AACA1A64F936C730FC1F81721011F0AE8@zw67246c.societe.mma.fr> (raw)
You don't need to use a regexp.
(query-replace "\n" "\n\n") will do the job
Bour9
> -----Message d'origine-----
> De :
> help-gnu-emacs-bounces+francois.bourgneuf=groupe-mma.fr@gnu.or
> g
> [mailto:help-gnu-emacs-bounces+francois.bourgneuf=groupe-mma.f
> r@gnu.org] De la part de Seweryn Kokot
> Envoyé : lundi 1 octobre 2007 09:57
> À : help-gnu-emacs@gnu.org
> 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
> help-gnu-emacs@gnu.org
> http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
>
>
next reply other threads:[~2007-10-01 9:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-01 9:08 Bourgneuf Francois [this message]
[not found] <mailman.1531.1191229744.18990.help-gnu-emacs@gnu.org>
2007-10-01 11:36 ` elisp, replace-regexp and re-search-forward weber
2007-10-01 16:11 ` Seweryn Kokot
2007-10-01 16:21 ` Bastien
[not found] ` <mailman.1550.1191255727.18990.help-gnu-emacs@gnu.org>
2007-10-01 20:03 ` weber
2007-10-01 20:06 ` weber
-- strict thread matches above, loose matches on Subject: below --
2007-10-01 7:56 Seweryn Kokot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8A921A5AACA1A64F936C730FC1F81721011F0AE8@zw67246c.societe.mma.fr \
--to=francois.bourgneuf@groupe-mma.fr \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).