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

Re: accept-line-and-down-history and push-input



On Oct 26, 10:06am, Mikael Magnusson wrote:
}
} I sometimes use accept-line-and-down-history to rerun a series of
} commands, but occasionally need to run another command at some point
} in the middle, but when returning from push-input, I'm left at the end
} of history, not where I was. Is there some clever way I can wrap
} push-input, or something, to make this work?

You can read/assign to HISTNO.  Something like this:

    with-saved-history-position() {
      typeset -g RESTORE_HISTNO=$HISTNO
      zle .$WIDGET "$@"
    }
    zle -N push-input with-saved-history-position

    zle-line-init() {
      [[ -n $RESTORE_HISTNO ]] && { 
	HISTNO=$RESTORE_HISTNO
	typeset -g RESTORE_HISTNO=''
      }
    }
    zle -N zle-line-init

(I'm beginning to think that zle-line-init should be a builtin widget
that calls an array of hook functions, ala precmd.)

-- 



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