Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: up-line-or-search question
- X-seq: zsh-workers 16910
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- Subject: Re: up-line-or-search question
- Date: Tue, 26 Mar 2002 11:51:01 -0800 (PST)
- Cc: Zsh hackers list <zsh-workers@xxxxxxxxxx>
- In-reply-to: <20020326192340.GA12802@xxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- Sender: schaefer@xxxxxxxxxxxxxxxx
On Tue, 26 Mar 2002, Oliver Kiddle wrote:
> I didn't realise that the numeric argument would propagate so thought
> the second history-beginning-search-backward was harmless. Your
> replacement breaks the addition that it goes down a line if at the end
> of the history.
I'd rather have it feep at the end of the history. Moving down a line
when the search fails means I lose my context and have to re-establish
it before I can e.g. reverse the direction of the search.
> Changing the zle h-b-s-? commands to:
>
> [[ $LASTWIDGET = $__searching ]] && CURSOR=$__savecursor
> zle .history-beginning-search-backward
> __savecursor=$CURSOR
> zle .end-of-line
> (and moving the return statement in the down-line function)
>
> It works for going up but breaks when changing to going down.
> Basically, it searches down using the whole line instead of up to where
> the cursor was. Any ideas?
Don't test [[ $LASTWIDGET = $__searching ]], test [[ -n $__searching ]].
And name the cursor-saving variable something less generic, there may be
other functions that want to save and restore the cursor ...
> > zle .vi-fetch-history -n $NUMERIC
>
> Ok. Thanks. It isn't possible to include args (numeric or otherwise)
> with a bindkey though is it?
I'm not sure what you mean. If you mean supply args at the time that you
invoke the key binding, then you only get the numeric argument (digits
typed as a prefix, in vi mode). If you mean supply args at the time you
create the key binding, then you just create a new widget that has the
arguments and call it:
function vi-fetch-history-twentyseven {
zle .vi-fetch-history -n 27 # Always retrieve event 27
}
zle -N vi-fetch-history-twentyseven
bindkey -v g vi-fetch-history-twentyseven
Messages sorted by:
Reverse Date,
Date,
Thread,
Author