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: isearch-query-replace-regexp and stuff Date: Fri, 02 Jul 2004 09:55:57 +0300 Organization: JURTA Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <87d63ec1py.fsf@mail.jurta.org> References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1088753925 22433 80.91.224.253 (2 Jul 2004 07:38:45 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 2 Jul 2004 07:38:45 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Fri Jul 02 09:38:37 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 1BgId3-0005Es-00 for ; Fri, 02 Jul 2004 09:38:37 +0200 Original-Received: from lists.gnu.org ([199.232.76.165]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BgId3-00014p-00 for ; Fri, 02 Jul 2004 09:38:37 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BgIeq-00081P-Ug for emacs-devel@quimby.gnus.org; Fri, 02 Jul 2004 03:40:28 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1BgIek-00080g-7e for emacs-devel@gnu.org; Fri, 02 Jul 2004 03:40:22 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1BgIeg-0007xo-HT for emacs-devel@gnu.org; Fri, 02 Jul 2004 03:40:20 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BgIeg-0007xe-A4 for emacs-devel@gnu.org; Fri, 02 Jul 2004 03:40:18 -0400 Original-Received: from [66.33.219.6] (helo=knife.dreamhost.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BgIcS-0005wX-Ot; Fri, 02 Jul 2004 03:38:01 -0400 Original-Received: from mail.jurta.org (80-235-32-26-dsl.mus.estpak.ee [80.235.32.26]) by knife.dreamhost.com (Postfix) with ESMTP id 8179EE4147; Fri, 2 Jul 2004 00:37:17 -0700 (PDT) Original-To: David Kastrup In-Reply-To: (David Kastrup's message of "02 Jul 2004 01:18:36 +0200") 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.4 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:25375 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:25375 David Kastrup 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. That might seem weird, but it allows users to do weird things if they want so. Users may want to search with C-s for a regexp in the buffer and start C-M-% with a regexp copied literally from the search string. Actually, I don't know what users may want to do in these two cases (`C-s string C-M-%' and `C-M-s regexp M-%'). There are too many possibilities here, so I chose the most straightforward one which is based with a simple WYSIWYG principle: what you see in the echo area in isearch mode is what you get as the replacement string. > 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 have no brilliant idea of what to do if we type M-% in a regexp > isearch and there is no currently matched string. Probably just beep > and refuse, which would also be the sanest option if the regexp is > currently incomplete. Of course, if query-replace-interactive is > 'initial, one might possibly just provide an empty string as initial > value (leaving the history in peace), and if it is nil, we need not > bother anyhow. All this makes sense. We could implement this for the sake of user convenience provided that this is what most users would expect, but often mandatory conveniences are too annoying. > While we are at it: maybe M-s should turn an ordinary search into a > regexp search (while regexp-quoting the current search string to make > it fitting for a regexp search), and vice versa (by using the > currently matched string, if any, as search string). Do you propose a new key binding M-s or do you actually mean modifying the existing M-r? M-r currently toggles regular-expression mode, but it neither quotes the regexp nor turns the search regexp into the matched string. We could use a prefix argument of M-r to implement these things instead of adding a new key binding. -- Juri Linkov http://www.jurta.org/emacs/