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.