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: Sat, 03 Jul 2004 09:59:14 +0300 Organization: JURTA Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <87n02h374e.fsf@mail.jurta.org> References: <87d63ec1py.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 1088839057 2724 80.91.224.253 (3 Jul 2004 07:17:37 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 3 Jul 2004 07:17:37 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Sat Jul 03 09:17:30 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 1BgemA-0001VA-00 for ; Sat, 03 Jul 2004 09:17:30 +0200 Original-Received: from lists.gnu.org ([199.232.76.165]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1Bgem9-0000Ir-00 for ; Sat, 03 Jul 2004 09:17:30 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1Bgeo0-0006B0-ML for emacs-devel@quimby.gnus.org; Sat, 03 Jul 2004 03:19:24 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1Bgeny-0006Af-2t for emacs-devel@gnu.org; Sat, 03 Jul 2004 03:19:22 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1Bgenw-00069e-Dr for emacs-devel@gnu.org; Sat, 03 Jul 2004 03:19:21 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1Bgenw-00069b-C0 for emacs-devel@gnu.org; Sat, 03 Jul 2004 03:19:20 -0400 Original-Received: from [66.33.205.9] (helo=spatula.dreamhost.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Bgelv-0007ry-JM; Sat, 03 Jul 2004 03:17:15 -0400 Original-Received: from mail.jurta.org (80-235-33-115-dsl.mus.estpak.ee [80.235.33.115]) by spatula.dreamhost.com (Postfix) with ESMTP id C982417D01E; Sat, 3 Jul 2004 00:17:10 -0700 (PDT) Original-To: David Kastrup In-Reply-To: (David Kastrup's message of "02 Jul 2004 09:55:49 +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:25405 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:25405 David Kastrup writes: > The other thing that might make sense is to just define M-% and use it > to start regexp replacements in regexp searches, and non-regexp > replaced in normal isearch. It might be confusing. OTOH, the C-s > binding during searches already has this sort of split personality. Yes, it makes sense to use M-% to start regexp replacements in regexp search. I often mistakenly type M-% even if I want to start regexp replacements, and then cancel it and retype C-M-%. Using M-% to start regexp replacements in regexp isearch will reduce such mistakes. If users have switched to regexp search mode there is a high probability than they want regexp replacements and mistyped M-% instead of C-M-%. >> We could use a prefix argument of M-r to implement these things >> instead of adding a new key binding. > > No, we couldn't. Prefix arguments exit the search. Prefix arguments don't exit the search. IIRC, this is a relatively recent change in isearch.el. > It might make sense when switching to use the respective search > history's last entry _if_ it happens to match at point. This is useless. It's possible to type M-p just after switching the search mode to use the respective search history's last entry. But the current non-intrusive behavior of M-r is much better for users who use it to switch the search type invoked by mistake (`C-s' instead of `C-M-s') or by other reasons (e.g. want to add regexp constructs to the current search string). BTW, M-p currently does not work right. When typing it after starting isearch mode (i.e. `C-s M-p') it uses not the most recent item in the search ring, but the second history item. The patch below fixes this problem. It makes M-p to start visiting previous search strings from the index 0 instead of 1. And in those places where the last search string is reused after typing `C-s C-s' it calls `isearch-ring-adjust1' to adjust the isearch ring to the first element to prepare the correct index for further M-p and M-n commands. Index: lisp/isearch.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/isearch.el,v retrieving revision 1.230 diff -u -w -b -r1.230 isearch.el --- lisp/isearch.el 1 Jul 2004 09:54:51 -0000 1.230 +++ lisp/isearch.el 3 Jul 2004 07:32:43 -0000 @@ -911,6 +911,7 @@ ;; Empty isearch-string means use default. (if (= 0 (length isearch-string)) + (progn (setq isearch-string (or (car (if isearch-regexp regexp-search-ring search-ring)) @@ -919,6 +920,7 @@ isearch-message (mapconcat 'isearch-text-char-description isearch-string "")) + (isearch-ring-adjust1 nil)) ;; This used to set the last search string, ;; but I think it is not right to do that here. ;; Only the string actually used should be saved. @@ -989,6 +991,7 @@ ;; C-s in forward or C-r in reverse. (if (equal isearch-string "") ;; If search string is empty, use last one. + (progn (setq isearch-string (or (if isearch-regexp (car regexp-search-ring) @@ -998,6 +1001,7 @@ (mapconcat 'isearch-text-char-description isearch-string "") isearch-case-fold-search isearch-last-case-fold-search) + (isearch-ring-adjust1 nil)) ;; If already have what to search for, repeat it. (or isearch-success (progn @@ -1650,11 +1654,10 @@ () (set yank-pointer-name (setq yank-pointer - (mod (+ (or yank-pointer 0) + (mod (+ (or yank-pointer (if advance 0 -1)) (if advance -1 1)) length))) (setq isearch-string (nth yank-pointer ring) @@ -1693,13 +1695,11 @@ () (set yank-pointer-name (setq yank-pointer - (mod (- (or yank-pointer 0) n) + (mod (- (or yank-pointer (if (> n 0) 0 -1)) n) length))) (delete-field) (insert (nth yank-pointer ring)) -- Juri Linkov http://www.jurta.org/emacs/