emulate -L zsh setopt extendedglob local opt keys integer stat while getopts "k:" opt; do case $opt in # Read the given number of keys. This is a bit # ropey for more than a single key. (k) keys=$OPTARG ;; (*) return 1 ;; esac done (( OPTIND > 1 )) && shift $(( OPTIND - 1 )) local pretext="$PREDISPLAY$LBUFFER$RBUFFER$POSTDISPLAY " local LBUFFER="$2" local RBUFFER="$3" local PREDISPLAY="$pretext${1:-? }" local POSTDISPLAY= local -a region_highlight region_highlight=("P${#pretext} ${#PREDISPLAY} bold") if [[ -n $keys ]]; then zle -R read -k $keys stat=$? else zle recursive-edit -K main stat=$? (( stat )) || REPLY=$BUFFER fi return $stat