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: Sun, 29 Jan 2012 18:11:43 +0200 Message-ID: References: <87pqe5x6ju.fsf@mail.jurta.org> <87ty3h2uvp.fsf@mail.jurta.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=f46d044788776c028504b7acfc46 X-Trace: dough.gmane.org 1327853515 25218 80.91.229.3 (29 Jan 2012 16:11:55 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 29 Jan 2012 16:11:55 +0000 (UTC) Cc: emacs-devel@gnu.org To: Juri Linkov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jan 29 17:11:55 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 1RrXM6-0005B9-LB for ged-emacs-devel@m.gmane.org; Sun, 29 Jan 2012 17:11:50 +0100 Original-Received: from localhost ([::1]:55176 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RrXM6-0008I8-0P for ged-emacs-devel@m.gmane.org; Sun, 29 Jan 2012 11:11:50 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:50800) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RrXM2-0008Hs-MK for emacs-devel@gnu.org; Sun, 29 Jan 2012 11:11:47 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RrXM1-0002Nv-8u for emacs-devel@gnu.org; Sun, 29 Jan 2012 11:11:46 -0500 Original-Received: from mail-tul01m020-f169.google.com ([209.85.214.169]:46015) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RrXM0-0002Nl-UZ for emacs-devel@gnu.org; Sun, 29 Jan 2012 11:11:45 -0500 Original-Received: by obbta7 with SMTP id ta7so4111358obb.0 for ; Sun, 29 Jan 2012 08:11:44 -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=AM0fVvemuW7VmlEwFbkbFCLwfq5WPiCpz08p35Ho8C4=; b=nXnXoi0CxpkGZOmwHW3pLZCzFLzZKnFR7BE+21LCnb/trAXm/2A46OlXZTgx9B1DMK i9jlkpTbisXz2oh+h6mTqFIUJSIDEUv3GkT1RzfMLVyY3ZhxV3smVk9rPC9QoLqYJ/ph YONAiLHE/yW66caC/d2Vh/Mo9vjABlgkq4Fdg= Original-Received: by 10.182.231.7 with SMTP id tc7mr21702288obc.29.1327853504037; Sun, 29 Jan 2012 08:11:44 -0800 (PST) Original-Received: by 10.182.242.41 with HTTP; Sun, 29 Jan 2012 08:11:43 -0800 (PST) In-Reply-To: <87ty3h2uvp.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:148005 Archived-At: --f46d044788776c028504b7acfc46 Content-Type: multipart/alternative; boundary=f46d044788776c028204b7acfc44 --f46d044788776c028204b7acfc44 Content-Type: text/plain; charset=ISO-8859-1 Hi Juri, 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. Thanks, Gideon. On Fri, Jan 27, 2012 at 2:07 PM, Juri Linkov wrote: > > Thank you for your comments Juri. Do you have a thought on how to > > implement this functionality as a package the way Stefan asked for? > > Adding a new count argument to `isearch-repeat-forward' is a pretty > unobtrusive change and is standard Emacs practice. But if you want > to do fancy stuff with hint display then you could add a hook to > `isearch-lazy-highlight-update' and implement fancy features in a separate > package whose functionality is added by the hook. > > > Negative arguments in particular seem to be challenging. Right now I > > implemented negative argument navigation by calling isearch-repeat with > the > > opposite functionality but that has all kinds of odd effects. > > For example the search message changes, C-- C-1 isearch-forward does > > not go back one matched string but rather just switches to > > isearch-backward and so on. > > Then you need to take into account this situation and to add 1 to the > counter when isearch-forward switches to isearch-backward with C-- C-1. > > > I did implement visual hints for the negative arguments because that > > would require changing the way lazy highlight works significantly > > (lazy-highlight loop wraps around back to the first line and at that > > point you can't know the negative argument for the current match). > > There are other problems with negative arguments: sometimes backward > regexp search finds more matches than forward regexp search. > For instance, trying to search a regexp like "a+" forward on a string > like "aaa" finds all occurrences of "aaa" as one match, but backward > regexp search matches every "a" individually. > --f46d044788776c028204b7acfc44 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Hi Juri,

I am attaching a short patch which impleme= nts prefix arg support for 'isearch-repeat-forward' and 'isearc= h-repeat-backward'. It does not contain any visual hints or even hooks = for visual support because it seems worthwhile to test this functionality f= or a while before adding anything "fancy" as you say.=A0 Negative= arguments are supported in what seems to me a reasonable way, though clear= ly not ideal for regex searches as point out.

Please let me know if you think any more changes are required.

T= hanks, Gideon.


On Fri, Jan 27, 2012 a= t 2:07 PM, Juri Linkov <juri@jurta.org> wrote:
> Thank you for your co= mments Juri. =A0Do you have a thought on how to
> implement this functionality as a package the way Stefan asked for?
Adding a new count argument to `isearch-repeat-forward' is a pret= ty
unobtrusive change and is standard Emacs practice. =A0But if you want
to do fancy stuff with hint display then you could add a hook to
`isearch-lazy-highlight-update' and implement fancy features in a separ= ate
package whose functionality is added by the hook.

> Negative arguments in particular seem to be challenging. Right now I > implemented negative argument navigation by calling isearch-repeat wit= h the
> opposite functionality but that has all kinds of odd effects.
> For example the search message changes, C-- C-1 isearch-forward does > not go back one matched string but rather just switches to
> isearch-backward and so on.

Then you need to take into account this situation and to add 1 to the=
counter when isearch-forward switches to isearch-backward with C-- C-1.

> I did implement visual hints for the negative arguments because that > would require changing the way lazy highlight works significantly
> (lazy-highlight loop wraps around back to the first line and at that > point you can't know the negative argument for the current match).=

There are other problems with negative arguments: sometimes backward<= br> regexp search finds more matches than forward regexp search.
For instance, trying to search a regexp like "a+" forward on a st= ring
like "aaa" finds all occurrences of "aaa" as one match,= but backward
regexp search matches every "a" individually.

--f46d044788776c028204b7acfc44-- --f46d044788776c028504b7acfc46 Content-Type: application/octet-stream; name="isearch_repeat_prefix_arg_support.patch" Content-Disposition: attachment; filename="isearch_repeat_prefix_arg_support.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_gy09b3zj0 ZGlmZiAtLWdpdCBhL2xpc3AvaXNlYXJjaC5lbCBiL2xpc3AvaXNlYXJjaC5lbAppbmRleCBjZTc1 OTExLi5jZTEyNTUyIDEwMDY0NAotLS0gYS9saXNwL2lzZWFyY2guZWwKKysrIGIvbGlzcC9pc2Vh cmNoLmVsCkBAIC0xMzQwLDE1ICsxMzQwLDM3IEBAIFVzZSBgaXNlYXJjaC1leGl0JyB0byBxdWl0 IHdpdGhvdXQgc2lnbmFsaW5nLiIKICAgKGlzZWFyY2gtcHVzaC1zdGF0ZSkKICAgKGlzZWFyY2gt dXBkYXRlKSkKIAotKGRlZnVuIGlzZWFyY2gtcmVwZWF0LWZvcndhcmQgKCkKKyhkZWZ1biBpc2Vh cmNoLXJlcGVhdC1mb3J3YXJkICgmb3B0aW9uYWwgYXJnKQogICAiUmVwZWF0IGluY3JlbWVudGFs IHNlYXJjaCBmb3J3YXJkcy4iCi0gICh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