From: Daniel Shahaf <danielsh@apache.org>
To: zsh-workers@zsh.org
Subject: [PATCH] Complete vcs_info_hookadd and vcs_info_hookdel. Expose _vcs_info_hooks as a top-level helper function.
Date: Mon, 17 Feb 2020 09:56:54 +0000 [thread overview]
Message-ID: <20200217095654.29258-1-danielsh@apache.org> (raw)
---
Completion/Zsh/Command/_zstyle | 3 ---
Completion/Zsh/Function/_vcs_info | 31 +++++++++++++++++++++++++++++
Completion/Zsh/Type/_vcs_info_hooks | 2 ++
3 files changed, 33 insertions(+), 3 deletions(-)
create mode 100644 Completion/Zsh/Function/_vcs_info
create mode 100644 Completion/Zsh/Type/_vcs_info_hooks
diff --git a/Completion/Zsh/Command/_zstyle b/Completion/Zsh/Command/_zstyle
index 7db73c0c0..07b60605f 100644
--- a/Completion/Zsh/Command/_zstyle
+++ b/Completion/Zsh/Command/_zstyle
@@ -5,9 +5,6 @@ local nm=$compstate[nmatches] taglist patterns contexts MATCH
integer MBEGIN MEND
typeset -A opt_args styles
-_vcs_info_hooks() {
- compadd - ${functions[(I)+vi-*]#+vi-}
-}
# Assoc array of styles; the values give the possible top-level
# contexts:
# c completion
diff --git a/Completion/Zsh/Function/_vcs_info b/Completion/Zsh/Function/_vcs_info
new file mode 100644
index 000000000..fdb28de6a
--- /dev/null
+++ b/Completion/Zsh/Function/_vcs_info
@@ -0,0 +1,31 @@
+#compdef vcs_info_hookadd vcs_info_hookdel
+
+local -a hook_types=(
+ gen-applied-string
+ gen-hg-bookmark-string
+ gen-mqguards-string
+ gen-unapplied-string
+ no-vcs
+ post-backend
+ post-quilt
+ pre-addon-quilt
+ pre-get-data
+ set-branch-format
+ set-hgrev-format
+ set-message
+ set-patch-format
+ start-up
+)
+
+local -a specs
+case $service in
+ (vcs_info_hookdel)
+ specs=( '-a[remove all occurrences, not just the first]' )
+ ;;
+esac
+
+# TODO: for vcs_info_hookdel complete only functions installed for that hook
+_arguments : \
+ $specs \
+ ":hook type:($hook_types)" \
+ '*:hook function:_vcs_info_hooks'
diff --git a/Completion/Zsh/Type/_vcs_info_hooks b/Completion/Zsh/Type/_vcs_info_hooks
new file mode 100644
index 000000000..bad915000
--- /dev/null
+++ b/Completion/Zsh/Type/_vcs_info_hooks
@@ -0,0 +1,2 @@
+#autoload
+compadd - ${functions[(I)+vi-*]#+vi-}
(I haven't forgotten about the autoloadable parameters thing, but my
todo list isn't fifo.)
Cheers,
Daniel
reply other threads:[~2020-02-17 9:57 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20200217095654.29258-1-danielsh@apache.org \
--to=danielsh@apache.org \
--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).