[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: |
04 Jul 2004 12:13:36 -0400 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 |
> But the last search string still could be used as the `default'
> argument of `read-from-minibuffer'. This is not quite a "default"
> value but rather what the Emacs manual names as "future history" value,
> i.e. the value available with M-n.
I think we've already agreed that M-% should offer
Query replace (default foo -> bar):
i.e. default to redo the same replace as last time, rather than use the
last search string.
> I implemented it having in mind users' requests for the ability to
> copy words from the buffer into the from-string. Now this is possible
> by typing:
> C-s C-w C-w ... M-%
C-SPC M-f M-f ... M-w M-% C-y
with the advantage that it works not just for "take words and pass them to
M-%" but for non-words as well and for other commands than M-%.
Other cases could be
M-C-SPC M-C-SPC ... M-w M-% C-y
> But with using the last search string as a "default" value there is
> no need for an additional prompt, because to edit the from-string
> before making replacements, the user can type:
> C-s C-w C-w ... RET M-% M-n
Nowadays, I never use M-% directly other than to redo the last replace.
I.e. instead of
M-% foo RET bar RET
I always do
C-s foo M-% bar RET
that also allows me to easily choose regexp-or-no, delimited-or-no, and
case-fold-or-no without having to remember whether it's C-M-% or C-u M-%
or ...
> I agree. But I also think we should revert its definition from
> defcustom back to defvar,
Sure.
>> I also incidentally suggest that
>> isearch-query-replace don't do (call-interactively 'query-replace) but use
>> (perform-replace isearch-string nil t isearch-regexp isearch-word) instead.
> ===
> If the argument `replacements' is nil, this function signals an error.
> Moreover, it's impossible to guess the to-string, so asking for it from
> the user is still inevitable.
Oh, right, I forgot that part of my local hacks
--- orig/lisp/replace.el
+++ mod/lisp/replace.el
@@ -1336,6 +1366,10 @@
(funcall (car replacements) (cdr replacements)
replace-count)
noedit nil))
+ (unless next-replacement
+ (setq next-replacement
+ (read-string "Replace with: " nil nil
+ from-string)))
(if (not query-flag)
(let ((inhibit-read-only
query-replace-skip-read-only))
Obviously, it's not good enough. But we can easily take out the "read
`to'" part of query-replace-read-args. The point about using
perform-replace is that it allows us to obey both isearch-regexp and
isearch-word without doing any if-gymnastic.
Stefan
- query-replace-interactive, Stefan, 2004/07/03
- Re: query-replace-interactive, Juri Linkov, 2004/07/04
- Re: query-replace-interactive,
Stefan <=
- Re: query-replace-interactive, Juri Linkov, 2004/07/05
- Re: query-replace-interactive, Stefan, 2004/07/05
- 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