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: Paul Pogonyshev
Subject: Re: [patch] Re: regexp repacement, how to present replacement to user?
Date: Mon, 22 Oct 2007 00:15:24 +0300
User-agent: KMail/1.7.2

Juri Linkov wrote:
> > 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.

Mm, but they don't really replace anything, while such a name would
suggest it otherwise.  Though I don't really care, names in the patches
are certainly not optimal.

> 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.

OK.  I just followed `buffer-substring' and something else pattern.
Second function can certainly be dropped.

> > 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).

I agree.  But having this patch applied is a pre-requisite :)

Paul




reply via email to

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