From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Stefan Newsgroups: gmane.emacs.devel Subject: Re: query-replace-interactive Date: 04 Jul 2004 12:13:36 -0400 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: References: <876594drn6.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 1088957638 19647 80.91.224.253 (4 Jul 2004 16:13:58 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 4 Jul 2004 16:13:58 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Sun Jul 04 18:13:50 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 1Bh9ck-0008LI-00 for ; Sun, 04 Jul 2004 18:13:50 +0200 Original-Received: from lists.gnu.org ([199.232.76.165]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1Bh9cj-0007Xl-00 for ; Sun, 04 Jul 2004 18:13:49 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1Bh9ee-00027e-W5 for emacs-devel@quimby.gnus.org; Sun, 04 Jul 2004 12:15:49 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1Bh9ec-00027Y-DV for emacs-devel@gnu.org; Sun, 04 Jul 2004 12:15:46 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1Bh9ea-00027J-NY for emacs-devel@gnu.org; Sun, 04 Jul 2004 12:15:46 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1Bh9ea-00027G-LD for emacs-devel@gnu.org; Sun, 04 Jul 2004 12:15:44 -0400 Original-Received: from [206.47.199.166] (helo=simmts8-srv.bellnexxia.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Bh9cX-0005nA-U5 for emacs-devel@gnu.org; Sun, 04 Jul 2004 12:13:38 -0400 Original-Received: from empanada.local ([67.71.25.81]) by simmts8-srv.bellnexxia.net (InterMail vM.5.01.06.10 201-253-122-130-110-20040306) with ESMTP id <20040704161307.ZNIV28685.simmts8-srv.bellnexxia.net@empanada.local>; Sun, 4 Jul 2004 12:13:07 -0400 Original-Received: by empanada.local (Postfix, from userid 502) id EAF012421FB; Sun, 4 Jul 2004 12:13:36 -0400 (EDT) Original-To: Juri Linkov In-Reply-To: <876594drn6.fsf@mail.jurta.org> Original-Lines: 81 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 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:25442 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:25442 > 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