From: Andreas Schwab <schwab@suse.de>
Cc: emacs-devel@gnu.org
Subject: Re: query-replace-regexp-eval is quite nice, but...
Date: Mon, 02 Feb 2004 11:24:34 +0100 [thread overview]
Message-ID: <jevfmpeq3h.fsf@sykes.suse.de> (raw)
In-Reply-To: <x5fzdtooaz.fsf@lola.goethe.zz> (David Kastrup's message of "02 Feb 2004 09:53:08 +0100")
David Kastrup <dak@gnu.org> writes:
> The description tells us
>
> [...]
>
> TO-EXPR is a Lisp expression evaluated to compute each
> replacement. It may reference `replace-count' to get the number
> of replacements already made. If the result of TO-EXPR is not a
> string, it is converted to one using `prin1-to-string' with the
> NOESCAPE argument (which see).
>
> For convenience, when entering TO-EXPR interactively, you can use
> `\&' or `\0' to stand for whatever matched the whole of REGEXP,
> and `\N' (where N is a digit) to stand for whatever matched the
> Nth `\(...\)' in REGEXP. Use `\#&' or `\#N' if you want a number
> instead of a string.
>
> So the idea is to build your replacement string with Lisp, and this
> is quite an excellent thing. It is completely defeated because the
> replacement is then done non-literally. Which means that if
> \0
> would have matched \footnote, replacing the string just with \0 (which
> one would expect to do nothing in effect) will barf because the
> regexp replacer will not know what \f is supposed to be.
I agree this is a bug.
> Is there anybody that would make a case for a non-literal
> replacement? If not, is there anybody with enough of a clue to find
> out how to fix this? I have taken a look at perform-replace, but it
> does not seem to offer an option for literal replacement for
> regexps. Should we add one?
Currently, perform-replace uses literal replacement for all non-regexp
searches, and non-literal otherwise. What we could do is offer a special
version of match-string that quotes backslashes and use that in
replace-match-string-symbols.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
next prev parent reply other threads:[~2004-02-02 10:24 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-02 8:53 query-replace-regexp-eval is quite nice, but David Kastrup
2004-02-02 10:24 ` Andreas Schwab [this message]
2004-02-02 11:19 ` David Kastrup
2004-02-02 12:16 ` Ehud Karni
2004-02-02 12:17 ` David Kastrup
2004-02-02 13:10 ` Andreas Schwab
2004-02-02 15:01 ` David Kastrup
2004-02-02 15:52 ` Stefan Monnier
2004-02-03 13:22 ` Andreas Schwab
2004-02-02 13:03 ` Andreas Schwab
2004-02-02 15:03 ` David Kastrup
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jevfmpeq3h.fsf@sykes.suse.de \
--to=schwab@suse.de \
--cc=emacs-devel@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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.