emacs-devel
[Top][All Lists]
Advanced

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

Re: [patch] Re: regexp repacement, how to present replacement to user?


From: Juri Linkov
Subject: Re: [patch] Re: regexp repacement, how to present replacement to user?
Date: Sun, 21 Oct 2007 23:43:34 +0300
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/23.0.50 (gnu/linux)

> These functions basically perform part of what `replace-match' does.
> The latter substitutes replacement group references (`\N' and `\&')
> and replaces match in the buffer with the result text.  Proposed
> functions only generate and return that text, without modyfing the
> buffer.

Since new functions are similar to `replace-match', I think they
should also have similar names, e.g. `replace-match-string' or
`replace-match-as-string' meaning that it returns the replacement
as a string.  Also I think it should have exactly the same arguments
as `replace-match'.  And one function should be enough - there is no need
for -no-properties function because properties can be easily stripped
on the returned string when needed.

> Currently, Emacs doesn't use this or similar functionality to my
> knowledge.  However, this can be used in UI to present the user.
> Especially useful if the user doesn't write regular expression and
> replacement himself, but instead invokes some command that uses a
> predefined regexp written by someone else.  E.g., for instance, it
> would be quite cryptic if a user saw
>
>     Replace \\([[:digit:]]+\\)\\.\\([[:digit:]]+\\) with \1,\2 (decimal 
> comma)?
>
> since he doesn't really care how this works internally at all.
> Instead, seeing
>
>     Replace 12.345 with 12,345 (decimal comma)?
>
> is more understandable.

I think there should be an option that will enable such understandable
replacements in the prompt (but not for multi-line replacements).

-- 
Juri Linkov
http://www.jurta.org/emacs/




reply via email to

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