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

Re: Behaviour of {beginning,end}-of-buffer-or-history



On 02/06/11 16:25, Bart Schaefer wrote:
> On Jun 2,  5:04am, Bernhard Tittelbach wrote:
> }
[...]
> A quick test of [[ $LBUFFER[-1] = $'\n' ]] should fix that.
[...]

indeed, works perfectly now:

beginning-or-end-of-somewhere() {
  local hno=$HISTNO
  if [[ ( "${LBUFFER[-1]}" == $'\n' && "${WIDGET}" == beginning-of* )\
     || ( "${RBUFFER[1]}" == $'\n' && "${WIDGET}" == end-of* ) ]]; then
    zle .${WIDGET:s/somewhere/buffer-or-history/} "$@"
  else
    zle .${WIDGET:s/somewhere/line-hist/} "$@"
    if (( HISTNO != hno )); then
      zle .${WIDGET:s/somewhere/buffer-or-history/} "$@"
    fi
  fi
}
zle -N beginning-of-somewhere beginning-or-end-of-somewhere
zle -N end-of-somewhere beginning-or-end-of-somewhere


Cheers & Thanks,
Bernhard



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