From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.devel Subject: Re: isearch-query-replace-regexp and stuff Date: 05 Jul 2004 21:07:57 +0200 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1089054509 4432 80.91.224.253 (5 Jul 2004 19:08:29 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 5 Jul 2004 19:08:29 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Mon Jul 05 21:08:18 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 1BhYp8-00055X-00 for ; Mon, 05 Jul 2004 21:08:18 +0200 Original-Received: from lists.gnu.org ([199.232.76.165]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BhYp8-0000hX-00 for ; Mon, 05 Jul 2004 21:08:18 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BhYr6-0002Nb-UZ for emacs-devel@quimby.gnus.org; Mon, 05 Jul 2004 15:10:20 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1BhYr4-0002N2-Bt for emacs-devel@gnu.org; Mon, 05 Jul 2004 15:10:18 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1BhYr3-0002Mb-H7 for emacs-devel@gnu.org; Mon, 05 Jul 2004 15:10:17 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BhYr3-0002MY-3m for emacs-devel@gnu.org; Mon, 05 Jul 2004 15:10:17 -0400 Original-Received: from [199.232.76.164] (helo=fencepost.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BhYp2-0008Nx-MJ for emacs-devel@gnu.org; Mon, 05 Jul 2004 15:08:13 -0400 Original-Received: from localhost ([127.0.0.1] helo=lola.goethe.zz) by fencepost.gnu.org with esmtp (Exim 4.34) id 1BhYov-00012E-3G; Mon, 05 Jul 2004 15:08:05 -0400 Original-To: rms@gnu.org In-Reply-To: Original-Lines: 52 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:25460 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:25460 Richard Stallman writes: > As far as I am able to judge from the current code that is just > checked in, if one types M-% from within a regexp isearch or C-M-% > from within an ordinary isearch, the history variable of the last > irrelevant search type gets consulted. > > That seems weird. I think that M-% from within a regexp isearch > should probably use the currently matched string, and C-M-% from > within an ordinary isearch should probably use regexp-quote of the > current search string. > > I think M-% in string search should do query-replace > and M-% in regexp search should do query-replace-regexp. > That is simple, easy to type, and involves fewer characters. Agreed. The change-type-of-search functionality is something weird enough that one does not want to spend to much time thinking about how to throw this at the user. It might be an idea to also bind C-M-% to the same, non-type-switching behavior for symmetry. If the user wants to switch behavior, he can do so with the existing M-r binding. To make this more useful than just exiting search and restarting replacement, we might consider letting M-r in isearches keep the search string if it non-empty. This might be done in one of several ways: a) keep the search string unmodified. This has the advantage that you can keep already typed search string characters even when you accidentally started with the wrong search type. b) start over. I think this might be the current behavior. It does not buy you anything over leaving the current isearch and starting over with a different one. c) regexp-quote the search string when going to regexp searches, do something useful when going backward. That was my original proposal. It has the advantage that an existing match remains an existing match. After thinking this over, I think that maybe something like option "a)" would more often agree with what the user could expect and which would offer the most _additional_ usefulness. The main question to resolve for that would be just _where_ to start looking for the next match under the changed conditions. Probably resuming the search from the last position that _did_ match anything? That might make sense if you repeat searching a few times, add something like [ and then notice (because of a non-match) that you really wanted a regexp search instead. -- David Kastrup, Kriemhildstr. 15, 44793 Bochum