From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Gideon Stupp Newsgroups: gmane.emacs.devel Subject: Re: [EXPERIMENTAL PATCH] Extending Isearch-repeat-forward/backward to support a prefix argument following suggesion by Juri Linkov Date: Mon, 30 Jan 2012 11:53:33 +0200 Message-ID: References: <87pqe5x6ju.fsf@mail.jurta.org> <87ty3h2uvp.fsf@mail.jurta.org> <87r4yiav0w.fsf@mail.jurta.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=f46d0445179bcf9dd304b7bbd180 X-Trace: dough.gmane.org 1327917230 12733 80.91.229.3 (30 Jan 2012 09:53:50 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 30 Jan 2012 09:53:50 +0000 (UTC) Cc: emacs-devel@gnu.org To: Juri Linkov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jan 30 10:53:49 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Rrnvo-00007h-F8 for ged-emacs-devel@m.gmane.org; Mon, 30 Jan 2012 10:53:48 +0100 Original-Received: from localhost ([::1]:50048 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rrnvn-0002NN-Qi for ged-emacs-devel@m.gmane.org; Mon, 30 Jan 2012 04:53:47 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:43589) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rrnvf-0002N5-6e for emacs-devel@gnu.org; Mon, 30 Jan 2012 04:53:45 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rrnva-0001Zn-Ni for emacs-devel@gnu.org; Mon, 30 Jan 2012 04:53:39 -0500 Original-Received: from mail-tul01m020-f169.google.com ([209.85.214.169]:52090) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rrnva-0001Zj-FX for emacs-devel@gnu.org; Mon, 30 Jan 2012 04:53:34 -0500 Original-Received: by obbta7 with SMTP id ta7so4787791obb.0 for ; Mon, 30 Jan 2012 01:53:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=HWwtQWDz6bw43mMtMcIhLiK1QhrMh+NijGgOg6gteQM=; b=iJwc7gI3tjAtGUaWcg5HOwqwL77SkNvwTI4qHp5H8FO+ewoNAPzPMQF3ffn11K1m/n l+gECdv6zABAHZj1hpdOXvPP6MXbfnCsiUu3lLVvLjxkbiWjJLkmhvxmEpRxO0Ue4scm Zrnj9m/kS6Gyqs9Ny4pGZ2tNNLJGPE18ewVEQ= Original-Received: by 10.182.41.5 with SMTP id b5mr27306953obl.79.1327917213654; Mon, 30 Jan 2012 01:53:33 -0800 (PST) Original-Received: by 10.182.242.41 with HTTP; Mon, 30 Jan 2012 01:53:33 -0800 (PST) In-Reply-To: <87r4yiav0w.fsf@mail.jurta.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.214.169 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:148033 Archived-At: --f46d0445179bcf9dd304b7bbd180 Content-Type: text/plain; charset=ISO-8859-1 On Mon, Jan 30, 2012 at 2:38 AM, Juri Linkov wrote: > > I am attaching a short patch which implements prefix arg support for > > 'isearch-repeat-forward' and 'isearch-repeat-backward'. It does not > contain > > any visual hints or even hooks for visual support because it seems > > worthwhile to test this functionality for a while before adding anything > > "fancy" as you say. Negative arguments are supported in what seems to > me a > > reasonable way, though clearly not ideal for regex searches as point out. > > > > Please let me know if you think any more changes are required. > > It's not yet clear what is the most expected behavior. > > With your patch, typing `C-s a C-3 C-s C- C-3 C-s' returns the isearch > point > to the original position - this is good, thanks. > > But its behavior is not deterministic: it depends on the current search > direction before calling these commands with a numeric argument. > So e.g. `C-s a C-3 C-s C-r C- C-3 C-s' (where `C-r' just switches > the search direction) doesn't return it to the original position. > Perhaps you need to check the current direction defined in the variable > `isearch-forward' and take it into account. > > This is bug; I did not think of this scenario. Thanks for pointing it out. > Another question is why e.g. `C-s a C-3 C-s C-3 C-r' doesn't handle > switching of search direction and does not return to the original position? > In terms of implementation, the question is: why in > `isearch-repeat-forward' and `isearch-repeat-backward' you don't add code > that switches the current direction to the `(> arg 0)' code branch? > I did not add code that switches the current direction in the (> arg 0) case for compatibility reasons; I wanted C-3 C-s to behave exactly like C-s C-s C-s. But I do see your point. So how about the following behavior (for brevity I will describe only isearch-repeat-forward): (1) if you use isearch-repeat-forward then at the end of the operation you must be in a search-forward state; (2) the numerical value decides how many searches are done and (3) the sign defines the direction. More specifically isearch-repeat-forward -| the usual "interactive" mode. C-0 isearch-repeat-forward -| if in backward search switch to forward search but don't do any actual search, otherwise don't do anything. C- isearch-repeat-forward -| switch to forward search (if necessary) and search times forward. C-u isearch-repeat-forward -| like C-4 C-- C- isearch-repreat-forward -| go back times of search but make sure to finish in forward-search state. C-- isearch-repeat-forward -| like C- C-1 isearch-repeat-forward. Thanks, Gideon. --f46d0445179bcf9dd304b7bbd180 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable


On Mon, Jan 30, 2012 at= 2:38 AM, Juri Linkov <juri@jurta.org> wrote:
> I am attaching a short patch which implements prefix= arg support for
> 'isearch-repeat-forward' and 'isearch-repeat-backward'= . It does not contain
> any visual hints or even hooks for visual support because it seems
> worthwhile to test this functionality for a while before adding anythi= ng
> "fancy" as you say. =A0Negative arguments are supported in w= hat seems to me a
> reasonable way, though clearly not ideal for regex searches as point o= ut.
>
> Please let me know if you think any more changes are required.

It's not yet clear what is the most expected behavior.

With your patch, typing `C-s a C-3 C-s C- C-3 C-s' returns the isearch = point
to the original position - this is good, thanks.

But its behavior is not deterministic: it depends on the current search
direction before calling these commands with a numeric argument.
So e.g. `C-s a C-3 C-s C-r C- C-3 C-s' (where `C-r' just switches the search direction) doesn't return it to the original position.
Perhaps you need to check the current direction defined in the variable
`isearch-forward' and take it into account.

This is bug; I did not think of this scenario. Thanks= for pointing it out.
=A0
Another question is why e.g. `C-s a C-3 C-s C-3 C-r' doesn't handle=
switching of search direction and does not return to the original position?=
In terms of implementation, the question is: why in
`isearch-repeat-forward' and `isearch-repeat-backward' you don'= t add code
that switches the current direction to the `(> arg 0)' code branch?<= br>

I did not add code that switches the current directi= on in the (> arg 0) case for compatibility reasons; I wanted C-3 C-s to = behave exactly like C-s C-s C-s.
But I do see your point. So how about t= he following behavior (for brevity I will describe only isearch-repeat-forw= ard):=A0 (1) if you use isearch-repeat-forward then at the end of the opera= tion you must be in a search-forward state; (2) the numerical value decides= how many searches are done and (3) the sign defines the direction. More sp= ecifically

isearch-repeat-forward=A0=A0 -|=A0 the usual "interactive" mo= de.

C-0 isearch-repeat-forward -|=A0 if in backward search switch to= forward search but don't do any actual search, otherwise don't do = anything.
C-<number> isearch-repeat-forward -| switch to forward search (if nec= essary) and search <number> times forward.
C-u isearch-repeat-forw= ard=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 -| like C-4

C-- C-<num= ber> isearch-repreat-forward -| go back <number> times of search b= ut make sure to finish in forward-search state.
C-- isearch-repeat-forward=A0 -|=A0 like C- C-1 isearch-repeat-forward.
=
Thanks, Gideon.






--f46d0445179bcf9dd304b7bbd180--