On Jul 3, 12:30am, Felix Rosencrantz wrote:
} Subject: Using buffer for history-incremental-search-backward
}
} I'm trying to figure out how to use history-incremental-search-backward.
}
} host% sleep 5
} ^Recho
} host% echo
}
} So why doesn't the control-R register?
While `sleep' is running, zle is inactive and the regular tty driver is
in control of the interpretation of input characters. Chances are you
have `stty ^R redisplay' or the like (probably as a default, rather than
explicitly in any of your init files), so the tty driver consumes the ^R
before zle gets started again.
} I tried to write a widget that can be dropped in the
} place of the builtin h-i-s-b. The problem I've been having is how to
} determine if this is the initial call of h-i-s-b, or if it is in the
} middle of a search in progress.
Ordinarily that's what the LASTWIDGET parameter is for, but the behavior
after you already have started an incremental search is not what you'd
expect: your widget has not been assigned to LASTWIDGET yet because the
(internal C) function for `zle history-incremental-search-backward' has
not yet returned! So you have to fudge that yourself.
Then there's the additional problem that there is a limited set of key
bindings during the incremental search, and the binding for the h-i-s-b
widget is not one of them -- so you have to actually *name* your widget
`history-increment-search-backward', and refer to the real widget by its
"safe" name (with a leading dot) in the `zle' calls.
history-increment-search-backward () {
setopt localoptions unset
if [[ -n "$doing_hisb" ]]; then
zle .history-incremental-search-backward
else
local doing_hisb=yes
zle .history-incremental-search-backward "$BUFFER"
fi
}
Both of these things could be considered bugs.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/bartshttp://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net