From: Juri Linkov <juri@jurta.org>
Cc: emacs-devel@gnu.org
Subject: Re: query-replace-interactive
Date: Tue, 06 Jul 2004 12:56:21 +0300 [thread overview]
Message-ID: <871xjp5uii.fsf@mail.jurta.org> (raw)
In-Reply-To: <m1zn6ey6qf.fsf-monnier+emacs@gnu.org> (Stefan's message of "05 Jul 2004 08:44:43 -0400")
Stefan <monnier@iro.umontreal.ca> 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/
next prev parent reply other threads:[~2004-07-06 9:56 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-07-03 22:59 query-replace-interactive Stefan
2004-07-04 9:54 ` query-replace-interactive Juri Linkov
2004-07-04 16:13 ` query-replace-interactive Stefan
2004-07-05 6:08 ` query-replace-interactive Juri Linkov
2004-07-05 12:44 ` query-replace-interactive Stefan
2004-07-06 9:56 ` Juri Linkov [this message]
2004-07-06 22:00 ` query-replace-interactive Richard Stallman
2004-07-07 5:11 ` query-replace-interactive Juri Linkov
2004-07-07 5:42 ` query-replace-interactive Miles Bader
2004-07-07 9:35 ` query-replace-interactive David Kastrup
2004-07-07 20:58 ` query-replace-interactive Richard Stallman
2004-07-06 22:00 ` query-replace-interactive Richard Stallman
2004-07-06 22:11 ` query-replace-interactive David Kastrup
2004-07-06 11:53 ` query-replace-interactive Richard Stallman
2004-07-06 12:24 ` query-replace-interactive Stefan
2004-07-07 6:41 ` query-replace-interactive Richard Stallman
2004-07-06 11:53 ` query-replace-interactive Richard Stallman
2004-07-06 12:09 ` query-replace-interactive David Kastrup
2004-07-07 6:41 ` query-replace-interactive Richard Stallman
-- strict thread matches above, loose matches on Subject: below --
2004-10-11 1:10 query-replace-interactive Luc Teirlinck
2004-10-11 1:18 ` query-replace-interactive Luc Teirlinck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871xjp5uii.fsf@mail.jurta.org \
--to=juri@jurta.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).