Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: compadd completion
- X-seq: zsh-workers 35729
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxx>
- Subject: PATCH: compadd completion
- Date: Wed, 08 Jul 2015 12:07:53 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1436350074; bh=8Yh26ExpZCXe0OoXmWaHuxEpS7QA6LD7eiw2tAnLM/c=; h=From:To:Subject:Date:From:Subject; b=tPQEwiIAuBvS7Hf+rqvzGOG1XmxReRSbcqxZObGoyweYK2KavugpvbkYcwEoELMpyi2v+enJ3t6XW1gMaFMZ64vvRKAjzvuBMXQIajtQHcZXJqw9Yic6TKDTMBDoQ1p1TOwCvSpU5t6Ecwg2NTJ+BCOlyyH98WfqMpan0JFXQLWVGyK+QnIWuA5TG2KAE4fYR5Mefby98efGFP0TicwRcVyN8ZspFT+6ZwcXkQuPhIziioHduGqjV/C9udBWjWN3WYNCJKvESIfsYeWeLYpWAfox5r2fmAM+Lq43Z3Svb0n7oEWC3AeDrrLx62V9fu1yBv9pAutEz6CuQWDksSV/Hg==
- 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
This will perhaps seem rather pointless because compadd is not exactly an
interactive command but I quite often write and edit small functions on the
command-line, especially now that vi-mode is working better. Also, this is
quicker than looking at the documentation for simple cases.
Oliver
diff --git a/Completion/Zsh/Command/_compadd b/Completion/Zsh/Command/_compadd
new file mode 100644
index 0000000..eee999f
--- /dev/null
+++ b/Completion/Zsh/Command/_compadd
@@ -0,0 +1,52 @@
+#compdef compadd -P _*
+
+local curcontext="$curcontext" state line ret=1
+typeset -A opt_args
+
+_arguments -C -s -S -A "-*" \
+ '-P+[specify prefix]:prefix' \
+ '-S+[specify suffix]:suffix' \
+ '-p+[specify hidden prefix]:hidden prefix' \
+ '-s+[specify hidden suffix]:hidden suffix' \
+ '-i+[specify ignored prefix]:ignored prefix' \
+ '-I+[specify ignored suffix]:ignored suffix' \
+ '(-k)-a[matches are elements of specified arrays]' \
+ '(-a)-k[matches are keys of specified associative arrays]' \
+ '-d+[specify display strings]:array:_parameters -g "*array*"' \
+ '-l[list display strings one per line, not in columns]' \
+ '-o[order matches by display string not by match string]' \
+ '(-1 -E)-J+[specify match group]:group' \
+ '-V+[specify unsorted match group]:group' \
+ '(-J -E)-1[remove only consecutive duplicates from group]' \
+ '-2[preserve all duplicates]' \
+ '(-x)-X[specify explanation]:explanation' \
+ '(-X)-x[specify unconditional explanation]:explanation' \
+ '-q[make suffix autoremovable]' \
+ '-r+[specify character class for suffix autoremoval]:character class' \
+ '-R+[specify function for suffix autoremoval]:function:_functions' \
+ '-f[mark matches as being files]' \
+ '-e[mark matches as being parameters]' \
+ '-W[specify location for matches marked as files]' \
+ '-F+[specify array of ignore patterns]:array:_parameters -g "*array*"' \
+ '-Q[disable quoting of matchines]' \
+ '*-M[specify matching specifications]' \
+ '-n[hide matches in completion listing]' \
+ '-U[disable internal matching of completion candidates]' \
+ '-O+[populate array with matches instead of adding them]:array:_parameters -g "*array*"' \
+ '-A+[populate array with expanded matches instead of adding them]:array:_parameters -g "*array*"' \
+ '-D+[delete elements from array corresponding to non-matching candidates]:array:_parameters -g "*array*"' \
+ '-C[add special match that expands to all other matches]' \
+ '(-1 -J)-E+[add specified number of display only matches]:number' \
+ '*:candidate:->candidates' && ret=0
+
+if [[ -n $state ]]; then
+ if (( $+opt_args[-a] )); then
+ _parameters -g "*array*" && ret=0
+ elif (( $+opt_args[-k] )); then
+ _parameters -g "*assoc*" && ret=0
+ else
+ _message -e candidate candidates
+ fi
+fi
+
+return ret
Messages sorted by:
Reverse Date,
Date,
Thread,
Author