Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: are there some ways to get things like isearch-{start,end}-position?
On Mar 27, 2:58pm, Madsen Zhang wrote:
>
> if the last isearch direction is available, the following script, based on
> the one from Bart Schaefer, should work in both forward and backward
> isearch:
>
> zle-isearch-exit() {
> if [[ $ISEARCHDIR -eq 1 ]]; then
> local match mbegin mend
> setopt extendedglob
> [[ -n $LASTSEARCH ]] || return 0
> : ${LBUFFER%(#b)(*)$LASTSEARCH}
> CURSOR=$mend[1]
> fi
>
> return 0
> }
> zle -N zle-isearch-exit
You can set ISEARCHDIR for yourself by putting a little wrapper function
around history-incremental-search-*.
hist-inc-search-save-direction() {
if [[ $WIDGET = *-forward ]]; then
typeset -g ISEARCHDIR=1
zle .history-incremental-search-forward "$@"
else
typeset -g ISEARCHDIR=-1
zle .history-incremental-search-backward "$@"
fi
}
zle -N history-incremental-search-forward hist-inc-search-save-direction
zle -N history-incremental-search-backward hist-inc-search-save-direction
I'm not sure I got the semantics of ISEARCHDIR the way you wanted them,
but you get the idea.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author