Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Wishlist for zsh: 3 tcsh features
- X-seq: zsh-users 4358
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Wishlist for zsh: 3 tcsh features
- Date: Tue, 09 Oct 2001 15:25:17 +0100
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20011008161313.EC4ACD804@xxxxxxxxxxxxxxxxx> <OF594BCCA9.4364E8B5-ON80256ADF.0059B87C@xxxxxxxxxxxxxxx> <3BC1DDEE.FA306604@xxxxxxxxxxx> <1011008173916.ZM5532@xxxxxxxxxxxxxxxxxxxxxxx>
- Sender: kiddleo@xxxxxxxxxxxxxxxx
Bart Schaefer wrote:
> On Oct 8, 6:10pm, Oliver Kiddle wrote:
> } Those two widgets annoyingly don't allow you to navigate up and down in
> } multiple line commands so you may prefer to try `up-line-or-search' and
Of course this only really matters because I'm binding to the cursor
up/down keys.
> I don't think it's possible to get more primitive than up-line-or-history,
> which goes up one line in a multi-line buffer or up one history entry at
> the beginning of the buffer. Unless you're looking for a primitive that
> won't move out of the multi-line buffer when it reaches the top?
Yes. I had in mind using something like up-line || history-b-s-b
>
> Meanwhile, something like this should work:
>
> function up-line-or-beginning-search {
> if [[ $LASTWIDGET != $WIDGET ]]
> then
> if [[ $BUFFER == *$'\n'* ]]
> then
> __last_up_line=up-line-or-history
> else
> __last_up_line=history-beginning-search-backward
> fi
> fi
> zle .${__last_up_line:-beep}
> }
>
That is great, thanks. I never thought to check for multi-line buffers
by looking in BUFFER for a newline.
I presume that the LASTWIDGET check and __last_up_line saving is there
so that if the history search retrieved a multi-line command, it would
continue to use history-beginning-search-backward. Unfortunately, this
means it won't do a history search from the first line of a multi-line
buffer - not that that matters much - so I changed it to this:
if [[ ${BUFFER[1,CURSOR]} == *$'\n'* ]]; then
zle up-line-or-history
else
zle history-beginning-search-backward
fi
Please let me know if that has problems which I missed. Next I'll have
to get it to do something more useful from a PS2 prompt.
Oliver
_____________________________________________________________________
This message has been checked for all known viruses by the
MessageLabs Virus Scanning Service. For further information visit
http://www.messagelabs.com/stats.asp
Messages sorted by:
Reverse Date,
Date,
Thread,
Author