From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3876 invoked by alias); 30 Sep 2015 18:38:04 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 36724 Received: (qmail 13487 invoked from network); 30 Sep 2015 18:38:01 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-type:date:from:message-id :mime-version:subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=XBN xA5hz0aWWzxAyH8R466/VYAc=; b=UiHMBX3JT/YVVgTjCqR0l2QyKcwyiVWrvhT MEhj5rsbdYUkjdmGN0/pUqExkJ+Ztsq6YIfBa8Hoij+Mh+3jkA98KvWGVXMtPd3L g4F6er9D7xdyTr/iHICkew2JRTkgpAkftPq/LbttXSSbX3OFPdrf3p0djL04qN5I ZIRoF/fY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=XB NxA5hz0aWWzxAyH8R466/VYAc=; b=TjaR+XxIXzAgZsTQmA/WXeWYItJ4jiHFTE QxzRS7G7O08lfZH4w29gTxGGAMQ/mduxtQx5JsOqAJjACaDWX5ZCUQ6xe7PNe/Fk qC5HCfNeCtmu0SuKYkuNl2VQnumy0MaU/hAPl/YR3ViSYRY2729Md6uBPLKE8sv8 5QTs6opws= X-Sasl-enc: K7/VLgw75W40Hknnavgd+pEKBfF8+q5cTDnazrNZRY5Q 1443637791 Date: Wed, 30 Sep 2015 18:29:48 +0000 From: Daniel Shahaf To: zsh-workers@zsh.org Subject: [PATCH] Add API wrapper to ${+_comps[...]} Message-ID: <20150930182948.GD2003@tarsus.local2> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="uQr8t48UFsdbeI+V" Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) --uQr8t48UFsdbeI+V Content-Type: text/plain; charset=us-ascii Content-Disposition: inline I wonder if this is useful enough to be added? --uQr8t48UFsdbeI+V Content-Type: text/x-patch; charset=us-ascii Content-Disposition: attachment; filename="0001-compdef-documentation-Move-an-example.patch" >>From ed7cddd08d7e3bcf7d60349917ecc50461f50dd1 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 30 Sep 2015 17:41:55 +0000 Subject: [PATCH 1/2] compdef documentation: Move an example. --- Doc/Zsh/compsys.yo | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo index d6b1803..955b300 100644 --- a/Doc/Zsh/compsys.yo +++ b/Doc/Zsh/compsys.yo @@ -455,6 +455,11 @@ xitem(tt(compdef -k) [ tt(-an) ] var(function style key-sequence) [ var(key-sequ item(tt(compdef -K) [ tt(-an) ] var(function name style key-seq) [ var(name style seq) ... ])( The first form defines the var(function) to call for completion in the given contexts as described for the tt(#compdef) tag above. +For example, + +example(compdef _pids foo) + +uses the function tt(_pids) to complete process IDs for the command tt(foo). Alternatively, all the arguments may have the form `var(cmd)tt(=)var(service)'. Here var(service) should already have been @@ -513,13 +518,6 @@ autoloadable, equivalent to tt(autoload -U )var(function). ) enditem() -The function tt(compdef) can be used to associate existing completion -functions with new commands. For example, - -example(compdef _pids foo) - -uses the function tt(_pids) to complete process IDs for the command tt(foo). - Note also the tt(_gnu_generic) function described below, which can be used to complete options for commands that understand the `tt(-)tt(-help)' option. -- 2.1.4 --uQr8t48UFsdbeI+V Content-Type: text/x-patch; charset=us-ascii Content-Disposition: attachment; filename="0002-Add-compexists.patch" >>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 --uQr8t48UFsdbeI+V--