Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

User-defined zle widgets and built-in widget failure



I'd like to write a widget that modifies BUFFER, calls a built-in widget,
and then if that built-in widget fails, restores the previous BUFFER and
CURSOR.

Unfortunately, failure of "zle whatever" isn't detectable; "zle" always
sets $? to zero.  What I'd prefer is something like, whenever a feep() is
emitted, then "zle" has a nonzero value, so you can write stuff like

savebuffer=$BUFFER
BUFFER=$searchstring
CURSOR=$#searchstring
zle history-beginning-search-backward || BUFFER=$savebuffer

While I'm on the topic, it seems to me that the current/first/last history
numbers would be useful bits of information for zle widgets.  Then you
could do things like

histno=$HISTORYNUMBER
zle history-beginning-search-backward
[[ $histno != $HISTNUMBER ]] || BUFFER=$savebuffer

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



Messages sorted by: Reverse Date, Date, Thread, Author