From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Subject: [PATCH] Add API wrapper to ${+_comps[...]}
Date: Wed, 30 Sep 2015 18:29:48 +0000 [thread overview]
Message-ID: <20150930182948.GD2003@tarsus.local2> (raw)
[-- Attachment #1: Type: text/plain, Size: 47 bytes --]
I wonder if this is useful enough to be added?
[-- Attachment #2: 0001-compdef-documentation-Move-an-example.patch --]
[-- Type: text/x-patch, Size: 1515 bytes --]
>From ed7cddd08d7e3bcf7d60349917ecc50461f50dd1 Mon Sep 17 00:00:00 2001
From: Daniel Shahaf <d.s@daniel.shahaf.name>
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
[-- Attachment #3: 0002-Add-compexists.patch --]
[-- Type: text/x-patch, Size: 1933 bytes --]
>From a67963b2be0ad72b462996da93e89b734b68efa0 Mon Sep 17 00:00:00 2001
From: Daniel Shahaf <d.s@daniel.shahaf.name>
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
next reply other threads:[~2015-09-30 18:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-30 18:29 Daniel Shahaf [this message]
2015-10-04 0:49 ` Bart Schaefer
2015-10-05 21:51 ` Daniel Shahaf
2015-10-05 22:11 ` Bart Schaefer
2015-10-05 22:33 ` Daniel Shahaf
2015-10-05 22:49 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150930182948.GD2003@tarsus.local2 \
--to=d.s@daniel.shahaf.name \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).