Skip to content

Commit

Permalink
Merge pull request #106 from Freed-Wu/master
Browse files Browse the repository at this point in the history
Improve zsh completion
  • Loading branch information
wtsnjp authored Jul 7, 2023
2 parents cdf5ca8 + 8d83da2 commit bc8c0b9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
8 changes: 1 addition & 7 deletions doc/texdoc.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
14 changes: 11 additions & 3 deletions script/texdoclib-const.tlu
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ Website: <https://tug.org/texdoc/>
Repository: <https://github.com/TeX-Live/texdoc>
Please email bugs to <[email protected]>.]]

zsh_completion = [[
compdef __texdoc texdoc
zsh_completion = [=[
#compdef texdoc
__texdoc() {
local options=(
Expand All @@ -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
Expand Down

0 comments on commit bc8c0b9

Please sign in to comment.