Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] Add API wrapper to ${+_comps[...]}
- X-seq: zsh-workers 36724
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] Add API wrapper to ${+_comps[...]}
- Date: Wed, 30 Sep 2015 18:29:48 +0000
- 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=
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
I wonder if this is useful enough to be added?
From ed7cddd08d7e3bcf7d60349917ecc50461f50dd1 Mon Sep 17 00:00:00 2001
From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
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
From a67963b2be0ad72b462996da93e89b734b68efa0 Mon Sep 17 00:00:00 2001
From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author