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

Re: Wierd autoload problems with nested directories



On Jun 14,  2:55am, Ulf Magnusson wrote:
}
} fpath=(/home/ulf/lib/zsh/completions $fpath)
} autoload -U $fpath[1]/*(:t)
} 
} fpath=(/home/ulf/lib/zsh $fpath)
} autoload -U $fpath[1]/*(:t)

You might note that this will result in the "completions" subdirectory
being treated as the name of a function for autoloading.  You probably
should be doing

    autoload -U $fpath[1]/*(.:t)

Also please note that the location from which the function is loaded
depends on the value of $fpath at the time you call the function, NOT
upon the value of $fpath at the time you run "autoload".

} print -l ${fpath[1,3]} yields
} 
} /home/ulf/lib/zsh/completions
} /home/ulf/lib/zsh
} /usr/local/share/zsh/site-functions
} 
} , as expected.

That's certainly not what *I* would have expected.  If the two fpath
assignments really do appear in the order that you show them, I would
expect:

    /home/ulf/lib/zsh
    /home/ulf/lib/zsh/completions
    /usr/local/share/zsh/site-functions

Also, I'd have expected /usr/local/share/zsh/$ZSH_VERSION/functions
(for suitable expansion of $ZSH_VERSION) to appear in the list.

} For some reason, my completions will only work ('work' as in zsh not
} using its default completion behaviour for the context in question) if
} I place them in /home/ulf/lib/zsh.

At what point amidst all of this do you run "compinit"?

Merely autoloading a completion function isn't good enough -- compinit
has to examine the file and read the #compdef line.  That means you must
not run compinit until after you've added to fpath all the directories
where completion functions might be found.



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