emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [EXPERIMENTAL PATCH] Extending Isearch-repeat-forward/backward to su


From: Gideon Stupp
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



On Mon, Jan 30, 2012 at 2:38 AM, Juri Linkov <address@hidden> 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-<number> isearch-repeat-forward -| switch to forward search (if necessary) and search <number> times forward.
C-u isearch-repeat-forward              -| like C-4

C-- C-<number> isearch-repreat-forward -| go back <number> 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.







reply via email to

[Prev in Thread] Current Thread [Next in Thread]