[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: query-replace-interactive
From: |
Stefan |
Subject: |
Re: query-replace-interactive |
Date: |
05 Jul 2004 08:44:43 -0400 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 |
> But even in case with the default to repeat the last replacement it is
> possible to use the last search string/regexp as a default value only
> for the sake of making it available by M-n. But the real default value
> (such as used when the user types RET with empty input) could be
> interpreted as repeating the last replacement, since if the user
> enters empty input, `read-from-minibuffer' returns the empty string,
> not the argument `default-value'.
But as you said regarding the "a -> b" default, "such use of the default
value is non-standard in Emacs". And more importantly, it's unimportant.
If you want to reuse a previous search string for replacement, just do
C-s C-s M-%
instead of
M-% M-n RET
this also has the advantage of being more general, so you can also do
a replacement on the penultimate search string if you want:
C-s M-p M-p C-s M-%
>>> C-s C-w C-w ... M-%
>>
>> C-SPC M-f M-f ... M-w M-% C-y
> Yes, currently this is the most convenient method to do that but it
> requires more keystrokes and wastes the kill ring.
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.
> There are other cases where making the last search string accessible
> by M-n is useful. For example, users might want to start replacing
> the current search string from the beginning of the buffer. To not
> type C-r several times to reach the beginning of the buffer the user
> can type:
> C-s C-w C-w ... RET M-< M-% M-n RET
Why is that better than
C-s C-w C-w ... RET M-< C-s M-%
> So, in conclusion, I agree that M-% in isearch should not ask for
> the from-string with initial content of the last search string,
> but M-% invoked not from isearch could provide the last search string
> by M-n.
I don't think it's worth the trouble.
>> 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.
>> The point about using perform-replace is that it allows us to obey
>> both isearch-regexp and isearch-word without doing any if-gymnastic.
> Using `isearch-regexp' to call either `query-replace' or
> `query-replace-regexp' is easy. Using the value of `isearch-word' for
> replacement might be tricky but currently this is possible with the
> prefix argument C-u M-% or C-u C-M-% even in isearch.
And if you call perform-replace it's neither tricky nor requires
remembering any particular C-u combination.
Stefan
- 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 <=
- Re: query-replace-interactive, Juri Linkov, 2004/07/06
- 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