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

Re: Zle history feature like that of many IRC clients?



An additional twist occurred to me overnight:

On Dec 19,  7:17pm, Bart Schaefer wrote:
:
:     down-or-fake-accept-line() {
:       (( HISTNO == HISTCMD )) && zle fake-accept-line
:       zle .down-line-or-history "$@"                     
:     }

That's going to call fake-accept-line a bit too soon if you are in a
multi-line buffer.  The fix is pretty simple:

    down-or-fake-accept-line() {
      if (( HISTNO == HISTCMD )) && [[ "$RBUFFER" != *$'\n'* ]];
      then
        zle fake-accept-line
      fi
      zle .down-line-or-history "$@"                     
    }

(Rewritten as an "if" to avoid line wrap.)  This assumes that if there
are newlines to the right of the cursor, then we're somewhere in the
middle of a multi-line buffer and should keep moving down.

If you wanted down-history instead of down-line-or-history, then the
original test would be correct (but you should change which widget is
called at the end).



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