zsh-users
 help / color / mirror / code / Atom feed
* vi-history-incremental-search?
@ 2002-08-29 20:49 Steve Talley
  2002-08-30  3:26 ` vi-history-incremental-search? Bart Schaefer
  2002-08-30 18:44 ` vi-history-incremental-search? Wayne Davison
  0 siblings, 2 replies; 4+ messages in thread
From: Steve Talley @ 2002-08-29 20:49 UTC (permalink / raw)
  To: Zsh Users

Hello,

I am using the vi keymap (bindkey -v).  I have these lines in my
.zshrc:

    bindkey -M vicmd "?" vi-history-search-backward
    bindkey -M vicmd "/" vi-history-search-forward

I really like the ability to see incremental searches, so I changed
this to:

    bindkey -M vicmd "?" history-incremental-search-backward
    bindkey -M vicmd "/" history-incremental-search-forward

Unfortunately, now "n" (vi-repeat-search) and "N" (vi-rev-repeat-
search) don't seem to work after the search is completed.  That is,
they don't perform the same search from that point in the history.

For example, with this history:

    ...
    100 echo foobar
    101 echo blah
    102 echo woofoo

When I use vi-history-search-backward to search for "foo" (matched at
102), I can use "n" (vi-repeat-search) to perform the same search
again (matched at 100).  But if I initially use
history-incremental-search-backward to search for "foo", then "n"
(vi-repeat-search) doesn't continue the search for "foo".

Is there any way to modify either vi-history-search-* or
history-incremental-search-* to come up with a hybrid
vi-history-incremental-search*?

Thanks,

Steve


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: vi-history-incremental-search?
  2002-08-29 20:49 vi-history-incremental-search? Steve Talley
@ 2002-08-30  3:26 ` Bart Schaefer
  2002-08-30 18:44 ` vi-history-incremental-search? Wayne Davison
  1 sibling, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2002-08-30  3:26 UTC (permalink / raw)
  To: Steve Talley, Zsh Users

On Aug 29,  2:49pm, Steve Talley wrote:
}
} Is there any way to modify either vi-history-search-* or
} history-incremental-search-* to come up with a hybrid
} vi-history-incremental-search*?

Unfortunately, without rewriting some C code, it's very difficult.

Even in emacs mode you can't exit from incremental search and then resume
the same search again later.

You can tell the search what string to begin searching for, by calling
(in a widget function) e.g.
	zle history-incremental-search-backward foo
but there's no way at the end of a search to capture and save the string
that was last searched for, so the ability to set the starting string
doesn't help much.

You *could* implement your own incremental search, modeled after the
input loop in the incremental-complete-word function that's in the
distribution, but that would get pretty hairy.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: vi-history-incremental-search?
  2002-08-29 20:49 vi-history-incremental-search? Steve Talley
  2002-08-30  3:26 ` vi-history-incremental-search? Bart Schaefer
@ 2002-08-30 18:44 ` Wayne Davison
  2002-08-30 20:16   ` vi-history-incremental-search? Bart Schaefer
  1 sibling, 1 reply; 4+ messages in thread
From: Wayne Davison @ 2002-08-30 18:44 UTC (permalink / raw)
  To: Steve Talley; +Cc: Zsh Users

On Thu, 29 Aug 2002, Steve Talley wrote:
> When I use vi-history-search-backward to search for "foo" (matched at
> 102), I can use "n" (vi-repeat-search) to perform the same search
> again (matched at 100).  But if I initially use
> history-incremental-search-backward to search for "foo", then "n"
> (vi-repeat-search) doesn't continue the search for "foo".

The easiest solution would probably be to change the two functions to
use the same last-search variable instead of two different ones.  The
only downside to this is if someone out there uses both search functions
and enjoys having a different search default in each one.  I personally
see no problem with combining them.

Bart Schaefer wrote:
> Even in emacs mode you can't exit from incremental search and then
> resume the same search again later.

I'm not sure what you mean here.  Type Ctrl-R twice and it will start a
new search with the previous search string.

..wayne..


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: vi-history-incremental-search?
  2002-08-30 18:44 ` vi-history-incremental-search? Wayne Davison
@ 2002-08-30 20:16   ` Bart Schaefer
  0 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2002-08-30 20:16 UTC (permalink / raw)
  To: Steve Talley, Zsh Users

On Aug 30, 11:44am, Wayne Davison wrote:
> 
> Bart Schaefer wrote:
> > Even in emacs mode you can't exit from incremental search and then
> > resume the same search again later.
> 
> I'm not sure what you mean here.  Type Ctrl-R twice and it will start a
> new search with the previous search string.

Hrm, I swear I tried it in 4.0.6 and it didn't work.  But I just tried
again (with 4.0.3, I haven't upgraded the machines at work yet) and it
worked, so I must have flubbed something last night.

In that case, Steve can do:

function vi-repeat-incremental-search-backward {
 bindkey -e
 zle -U $'\C-r'
 zle history-incremental-search-backward
 bindkey -v
}
zle -N vi-repeat-incremental-search-backward
bindkey -a N vi-repeat-incremental-search-backward

(The "bindkey" commands shouldn't be necessary, but the keymap for h-i-s-b
is messed up when you enter it from vicmd.)


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-08-30 20:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-29 20:49 vi-history-incremental-search? Steve Talley
2002-08-30  3:26 ` vi-history-incremental-search? Bart Schaefer
2002-08-30 18:44 ` vi-history-incremental-search? Wayne Davison
2002-08-30 20:16   ` vi-history-incremental-search? Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).