From: Julien Cubizolles <j.cubizolles@free.fr>
To: help-gnu-emacs@gnu.org
Subject: Re: Using lisp code in query-replace-regexp
Date: Tue, 04 Nov 2014 21:58:06 +0100 [thread overview]
Message-ID: <8761euadk1.fsf@free.fr> (raw)
In-Reply-To: 54591D09.1060108@easy-emacs.de
Andreas Röhler <andreas.roehler@easy-emacs.de> writes:
> When writing a program, for example start with
>
> (narrow-to-region beg end)
> (goto-char (point-min))
> (while (re-search-forward RE end)
> (replace-match ...
Thanks for this example, it allows me to add the test I needed in the
mix. However, I'd rather be prompted for each replace. I tried with
replace-match-maybe-edit:
--8<---------------cut here---------------start------------->8---
(defun test_gen (begin end from to)
(save-excursion
(save-restriction
(let (deactivate-mark)
(narrow-to-region begin end)
(goto-char (point-min))
(while (re-search-forward from end t)
(replace-match-maybe-edit to t nil nil (match-data) nil)))
)))
--8<---------------cut here---------------end--------------->8---
but it messes up the excursion. If I use replace-match, the excursion is
preserved however.
Julien.
prev parent reply other threads:[~2014-11-04 20:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-04 14:49 Using lisp code in query-replace-regexp Julien Cubizolles
2014-11-04 18:38 ` Andreas Röhler
2014-11-04 20:58 ` Julien Cubizolles [this message]
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=8761euadk1.fsf@free.fr \
--to=j.cubizolles@free.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).