>From a67963b2be0ad72b462996da93e89b734b68efa0 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 30 Sep 2015 17:53:42 +0000 Subject: [PATCH 2/2] Add 'compexists'. --- Completion/compinit | 5 +++++ Doc/Zsh/compsys.yo | 12 +++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Completion/compinit b/Completion/compinit index 4b9a778..ac7e672 100644 --- a/Completion/compinit +++ b/Completion/compinit @@ -430,6 +430,11 @@ compdef() { fi } +compexists() { + (( $# )) || return 2 + (( $+_comps[$1] )) +} + # Now we automatically make the definition files autoloaded. typeset _i_wdirs _i_wfiles diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo index 955b300..444b966 100644 --- a/Doc/Zsh/compsys.yo +++ b/Doc/Zsh/compsys.yo @@ -445,9 +445,9 @@ subsect(Functions) The following function is defined by tt(compinit) and may be called directly. +startitem() findex(compdef) cindex(completion system, adding definitions) -startitem() redef(SPACES)(0)(tt(ifztexi(NOTRANS(@ @ @ @ @ @ ))ifnztexi( ))) xitem(tt(compdef) [ tt(-ane) ] var(function name) ... [ tt(-){tt(p)|tt(P)} var(pattern) ... [ tt(-N) var(name) ...]]) xitem(tt(compdef -d) var(name) ...) @@ -516,6 +516,16 @@ underscore. Wherever applicable, the tt(-a) option makes the var(function) autoloadable, equivalent to tt(autoload -U )var(function). ) +findex(compexists) +cindex(completion system, checking existence of definitions) +item(tt(compexists) var(name))( +This function checks whether the command var(name) has completion. +The return value is tt(0) if var(name) has a completion and tt(1) if it +doesn't. If no var(name) was passed, return tt(2). + +Completions for var(name) can be defined with tt(compdef), e.g., +with tt(compdef name=)var(foo) or tt(compdef )var(_foo)tt( name). +) enditem() Note also the tt(_gnu_generic) function described below, which can be -- 2.1.4