diff --git a/doc/texdoc.tex b/doc/texdoc.tex index ce01c8e..f4b39b6 100644 --- a/doc/texdoc.tex +++ b/doc/texdoc.tex @@ -787,13 +787,7 @@ \subsection{Zsh} \item adding \code{eval "\$(texdoc \lopt{print-completion} zsh)"} to your zsh configuration file. -\item adding a file somewhere in \code{\$fpath} with the following contents: -% -\begin{htcode} -#compdef texdoc -(( $+functions[__texdoc] )) || eval "$(texdoc \textbackslash - --print-completion zsh)" && __texdoc -\end{htcode} +\item creating a file named \code{\_texdoc} in \code{\$fpath} whose content is the output of \code{texdoc \lopt{print-completion} zsh}. \end{itemize} \section{Licence} diff --git a/script/texdoclib-const.tlu b/script/texdoclib-const.tlu index c551bf4..1340a82 100644 --- a/script/texdoclib-const.tlu +++ b/script/texdoclib-const.tlu @@ -50,8 +50,8 @@ Website: Repository: Please email bugs to .]] -zsh_completion = [[ -compdef __texdoc texdoc +zsh_completion = [=[ +#compdef texdoc __texdoc() { local options=( @@ -72,7 +72,15 @@ __texdoc() { ;; esac } -]] + +if [[ $zsh_eval_context[-1] == loadautofunc ]]; then + # autoload from fpath, call function directly + __texdoc "$@" +else + # eval/source/. command, register function for later + compdef __texdoc texdoc +fi +]=] --[[ structure of the options table