From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: query-replace-interactive Date: Tue, 06 Jul 2004 12:56:21 +0300 Organization: JURTA Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <871xjp5uii.fsf@mail.jurta.org> References: <876594drn6.fsf@mail.jurta.org> <87k6xjouj5.fsf@mail.jurta.org> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1089109542 15307 80.91.224.253 (6 Jul 2004 10:25:42 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 6 Jul 2004 10:25:42 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Tue Jul 06 12:25:29 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1Bhn8i-0004hG-00 for ; Tue, 06 Jul 2004 12:25:28 +0200 Original-Received: from lists.gnu.org ([199.232.76.165]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1Bhn8i-0007Xi-00 for ; Tue, 06 Jul 2004 12:25:28 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BhnAj-0008Oc-0S for emacs-devel@quimby.gnus.org; Tue, 06 Jul 2004 06:27:33 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1BhnAa-0008OP-I3 for emacs-devel@gnu.org; Tue, 06 Jul 2004 06:27:24 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1BhnAZ-0008Nq-B5 for emacs-devel@gnu.org; Tue, 06 Jul 2004 06:27:23 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BhnAZ-0008Ng-8p for emacs-devel@gnu.org; Tue, 06 Jul 2004 06:27:23 -0400 Original-Received: from [66.33.219.6] (helo=knife.dreamhost.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Bhn8S-0004yE-UA for emacs-devel@gnu.org; Tue, 06 Jul 2004 06:25:13 -0400 Original-Received: from mail.jurta.org (80-235-32-73-dsl.mus.estpak.ee [80.235.32.73]) by knife.dreamhost.com (Postfix) with ESMTP id 997DAE40A5; Tue, 6 Jul 2004 03:25:09 -0700 (PDT) Original-To: Stefan In-Reply-To: (Stefan's message of "05 Jul 2004 08:44:43 -0400") User-Agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:25475 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:25475 Stefan 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/