[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: query-replace-interactive
From: |
Juri Linkov |
Subject: |
Re: query-replace-interactive |
Date: |
Tue, 06 Jul 2004 12:56:21 +0300 |
User-agent: |
Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux) |
Stefan <address@hidden> writes:
> But as you said regarding the "a -> b" default, "such use of the default
> value is non-standard in Emacs".
Using the "a -> b" default would be a good improvement, but it seems
still unfinished in its current implementation. There are several
problems with it:
1. When users see "(default a -> b)" text in the prompt and want
to change the last replacement slightly, the first reaction is to type
M-n to insert it into the minibuffer for editing, since this is the
standard Emacs behavior. Instead of that, they will get an error
"End of history; no default available". Then they might try M-p,
but this doesn't insert the last replacement into the minibuffer either.
2. It is limited only to the last replacement. As such, it is not
a big improvement, since to repeat other replacements, users still
need to use old and inconvenient methods: C-x ESC ESC or messing
in the minibuffer history with intermixed `from' and `to' history elements.
3. The last replacement `from' and `to' strings might be too long
so that displaying them in the prompt becomes undesirable.
To cope with these problems we could maintain a separate history list
for *all* replacements in the form '("a -> b" "x -> y") and
to make it available for history commands in `read-from-minibuffer'.
This requires choosing such a separator which will have low probability
to appear in text to replace. But maybe even " -> " is a good default
separator.
> For what it's worth, I can also do
>
> M-% C-w C-w C-w RET
>
> since I've added a C-w binding in minibuffer-local-map that mimics
> isearch's C-w.
Why not add something like this to Emacs? Or maybe more general
character-based command like typing C-f in the end of the minibuffer
to pull text from the source buffer character by character to the minibuffer.
>>> Obviously, it's not good enough. But we can easily take out the "read
>>> `to'" part of query-replace-read-args.
>
>> Calling `perform-replace' directly is not good because it skips many
>> useful things implemented in interactive commands which call it.
>> Most useful of them is recently added handling of \, and \# in
>> `query-replace-read-args'.
>
> That's exactly what I meant by the "read `to'" part. We can take it out of
> query-replace-read-args and call it explicitly.
Using `perform-replace' directly still has at least three problems:
1. It doesn't take into account the region boundaries in transient-mark
mode. But this is useful even when M-% is called from isearch: to put
the upper bound, then to search for the first occurrence of a string
and to start the replacement in the region, i.e. with transient-mark
mode to type:
C-SPC M-< C-s C-s M-%
Though, this can be fixed by adding to (region-beginning) and (region-end)
explicitly as last two arguments of the `perform-replace' call.
2. It doesn't put the last replacement invoked from isearch to the
command history available by C-x ESC ESC. This might be unnecessary
if all replacements were available by the history command M-n in the
minibuffer as proposed above.
3. It doesn't put the last search string into the history. In its
current implementation it provides it as a default value available
by M-n in the to-string minibuffer, but it's not where users expect
to find it. The standard method to access the last value of from-string
in the to-string minibuffer is M-p.
This can be fixed by pushing the last search string into from-history
before calling `query-replace-read-to'.
--
Juri Linkov
http://www.jurta.org/emacs/
- query-replace-interactive, Stefan, 2004/07/03
- Re: query-replace-interactive, Juri Linkov, 2004/07/04
- Re: query-replace-interactive, Stefan, 2004/07/04
- Re: query-replace-interactive, Juri Linkov, 2004/07/05
- Re: query-replace-interactive, Stefan, 2004/07/05
- Re: query-replace-interactive,
Juri Linkov <=
- Re: query-replace-interactive, Richard Stallman, 2004/07/06
- Re: query-replace-interactive, Juri Linkov, 2004/07/07
- Re: query-replace-interactive, Miles Bader, 2004/07/07
- Re: query-replace-interactive, David Kastrup, 2004/07/07
- Re: query-replace-interactive, Richard Stallman, 2004/07/07
- Re: query-replace-interactive, Richard Stallman, 2004/07/06
- Re: query-replace-interactive, David Kastrup, 2004/07/06
- Re: query-replace-interactive, Richard Stallman, 2004/07/06
- Re: query-replace-interactive, Stefan, 2004/07/06
- Re: query-replace-interactive, Richard Stallman, 2004/07/07