[Top][All Lists]

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

Re: isearch-query-replace-regexp and stuff

From: Juri Linkov
Subject: Re: isearch-query-replace-regexp and stuff
Date: Fri, 02 Jul 2004 09:55:57 +0300
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux)

David Kastrup <address@hidden> writes:
> As far as I am able to judge from the current code that is just
> checked in, if one types M-% from within a regexp isearch or C-M-%
> from within an ordinary isearch, the history variable of the last
> irrelevant search type gets consulted.  That seems weird.

That might seem weird, but it allows users to do weird things if they
want so.  Users may want to search with C-s for a regexp in the
buffer and start C-M-% with a regexp copied literally from the search

Actually, I don't know what users may want to do in these two cases
(`C-s string C-M-%' and `C-M-s regexp M-%').  There are too many
possibilities here, so I chose the most straightforward one which is
based with a simple WYSIWYG principle: what you see in the echo area
in isearch mode is what you get as the replacement string.

> I think that M-% from within a regexp isearch should probably use
> the currently matched string, and C-M-% from within an ordinary
> isearch should probably use regexp-quote of the current search
> string.
> I have no brilliant idea of what to do if we type M-% in a regexp
> isearch and there is no currently matched string.  Probably just beep
> and refuse, which would also be the sanest option if the regexp is
> currently incomplete.  Of course, if query-replace-interactive is
> 'initial, one might possibly just provide an empty string as initial
> value (leaving the history in peace), and if it is nil, we need not
> bother anyhow.

All this makes sense.  We could implement this for the sake of user
convenience provided that this is what most users would expect, but
often mandatory conveniences are too annoying.

> While we are at it: maybe M-s should turn an ordinary search into a
> regexp search (while regexp-quoting the current search string to make
> it fitting for a regexp search), and vice versa (by using the
> currently matched string, if any, as search string).

Do you propose a new key binding M-s or do you actually mean
modifying the existing M-r?  M-r currently toggles regular-expression
mode, but it neither quotes the regexp nor turns the search regexp
into the matched string.  We could use a prefix argument of M-r
to implement these things instead of adding a new key binding.

Juri Linkov

reply via email to

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