all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* query-replace-regexp-eval is quite nice, but...
@ 2004-02-02  8:53 David Kastrup
  2004-02-02 10:24 ` Andreas Schwab
  0 siblings, 1 reply; 11+ messages in thread
From: David Kastrup @ 2004-02-02  8:53 UTC (permalink / raw)



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.

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?

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2004-02-03 13:22 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-02  8:53 query-replace-regexp-eval is quite nice, but David Kastrup
2004-02-02 10:24 ` Andreas Schwab
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

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.