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

Re: how to execute zle widget during zsh-init?

On Tue, 17 Aug 2004, Andy Spiegl wrote:

> but zle-line-init() is called every time zle starts, i.e. before a prompt
> is shown.  Isn't that overkill? :-)

That's why I put "zle -D zle-line-init" in there.  The widget executes 
once (the first time zle initializes) and then ceases to be a widget, so
it never executes again.

> Besides that doubt I can't get it to work.  I put the function 
> zle-line-init into my .zshrc, but where do I put the definition of the 
> function grow-killring?

I presumed you had that somewhere already, because of the implementation
you had included.  I didn't know what you called it so I made up a name.
I supposed e.g. that you had pasted in the content of an autoload file.

The full solution (with apologies to others that this repeats most of my 
previous post) could all be in .zshrc and would then look something like

    grow-killring() {
        setopt localoptions noksharrays
        : ${killring[${NUMERIC:-30}]:=''}
    zle -N grow-killring
    zle-line-init() {
        zle grow-killring
        zle -D zle-line-init
    zle -N zle-line-init

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