From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4524 invoked by alias); 1 Oct 2010 07:59:02 -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: 28307 Received: (qmail 1123 invoked from network); 1 Oct 2010 07:59:00 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at yahoo.co.uk does not designate permitted sender hosts) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.co.uk; h=DKIM-Signature:Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:Received:From:To:Subject:Date:Message-ID; b=wU7OnnfpI3Q/cQ39HkX0LctfeyWpZb2opFnLgAd71W3SnzcHy6FmT1FMBY7HvcGjDsStO5xaFaRE04FbIyGuZytIrNfRf8oCkLkpKlNkn04I31mv6s1a+DS/7Ds+ufcH1rIRSOsLFH2gcKqfnOqzngcp6UU8x7O84qVyWRTtE6M= ; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s1024; t=1285919537; bh=ou2x9cxIEyFP91/whnUF+106m6E24IJgeTVir3qE2G0=; h=Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:Received:From:To:Subject:Date:Message-ID; b=NP0KBeV+TdKKMOex4BG4C1F5apTdVyUWDxym9POlRTAqokjlZc5MJiLum1DWHQ5uCt0GxQ1B/rpFjJA9i5jBkat2LxTu0EDPRvIwvFGSLHa5lkKfAetB9QQMx2/7CRtfhu9vcVZGVhFfQzs6ocRdTa9SMTrRVZCgm28NspZQdOQ= X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI- X-YMail-OSG: xEb_X8EVM1mteDY08MviSCNXTP21x0AgmLuM7vYtJPfSD3a QQIEVY8Q4ayHyD3X5e8r5xmZrk60QjUMvvdb.RJHbNpcLGgiRdmibOUm6eXd gY.1MvyHvBp.WivvsQuRnuSod6y575.7SvV5Fen2MHmLml8Gw6mok_tdej.F DV1.Vo8_8NxfdM6KQM.7c2RFUxG67zRMSlIdm6eRHyUlcJ.wyE18E_6HOQQt hYwc3j77PZvJjCVamiIUamsf6hjo- X-Yahoo-Newman-Property: ymail-3 From: Oliver Kiddle To: Zsh workers Subject: PATCH: update _zstyle Date: Fri, 01 Oct 2010 09:52:16 +0200 Message-ID: <21327.1285919536@thecus> The most interesting thing here is that I've added in (Q) when expanding $line to adapt it for the fix in 27218. There's probably other completions that need adjusting for that change. Does _telnet still need the :q modifiers for example? It's mostly noticeable with _zstyle because it is common to use quotes for the context string. Aside from that, I've added support for the vcs_info stuff to _zstyle and various other new styles. Oliver diff --git a/Completion/Zsh/Command/_zstyle b/Completion/Zsh/Command/_zstyle index dcf30c0..708c0fd 100644 --- a/Completion/Zsh/Command/_zstyle +++ b/Completion/Zsh/Command/_zstyle @@ -1,7 +1,7 @@ #compdef zstyle local state context ostate line expl ctop suf -local nm=$compstate[nmatches] taglist patterns pstyles +local nm=$compstate[nmatches] taglist patterns pstyles contexts typeset -A opt_args styles (( $+functions[_completers] )) || @@ -9,7 +9,7 @@ _completers() { # option: -p - needs a `_' prefix local us local -a disp list expl - + list=( complete approximate correct match expand list menu oldlist ignored prefix history ) zparseopts -D -K -E 'p=us' @@ -25,6 +25,7 @@ _completers() { # c completion # d chpwd # e line editor +# v vcs_info # z zftp # or any combination of the above, # followed by a colon, followed by a state to enter, empty if none. @@ -41,14 +42,21 @@ styles=( cache-policy c:_functions call-command c:bool command c:command + command-path c:_dir_list commands c: complete c:bool + complete-options c:bool completer c:completer condition c:bool cursor c:cursor + delimiters c: disabled c:bool domains c: + environ c:environ expand c: + extra-verbose c:bool + fake c: + fake-always c: fake-files c:fake-files fake-parameters c:fake-params file-list c:bool @@ -94,11 +102,12 @@ styles=( numbers c:bool old-list c:bool old-matches c:oldmatches - old-menu c:bool + old-menu c:bool original c:bool packageset c:packageset path c:_directories pager c:_command_names + path-completion c:bool pine-directory c:_directories ports c:_ports prefix-hidden c:bool @@ -107,17 +116,18 @@ styles=( range c: recent-dirs-insert c:recent-dirs-insert regular c:bool + rehash c:bool remote-access c:bool remove-all-dups c:bool select-prompt c: select-scroll c: separate-sections c:bool + show-completer c:bool single-ignored c:single-ignored sort c:bool special-dirs c:sdirs squeeze-slashes c:bool stop c:stop - stop-keys c: strip-comments c:bool subst-globs-only c:bool substitute c:bool @@ -127,6 +137,8 @@ styles=( urls c:_urls use-cache c:bool use-compctl c:urgh + use-ip c:bool + use-perl c:bool users c:_users users-hosts c:user-host users-hosts-ports c:user-host-port @@ -160,6 +172,24 @@ styles=( word-style e:word-style word-context e: + formats v:vcs-format + actionformats v:vcs-format + branchformat v:branch-format + nvcsformats v: + stgitformat v:stg-format + max-exports v: + enable v:vcs + disable v:vcs + disable-patterns v: + check-for-changes v:bool + stagedstr v: + unstagedstr v: + command v:_command_names + use-server v:bool + use-simple v:bool + get-revision v:bool + use-prompt-escapes v:bool + chpwd z:bool progress z:progress remote-glob z:bool @@ -193,14 +223,19 @@ while (( $#state )); do case "$state[1]" in (contexts) if [[ ! -prefix :*: ]]; then - _wanted contexts expl context compadd -P : -qS : completion zftp + _wanted contexts expl context compadd -P : -qS : completion vcs_info zftp elif compset -P :completion:; then - for ostate in functions _completers cmdorcont argument tag; do + contexts=( functions _completers cmdorcont argument tag ) + elif compset -P :vcs_info:; then + contexts=( vcs-string user-context repo-root-name ) + fi + if (( $#contexts )); then + for ostate in $contexts; do compset -P '[^:]#:' || break done suf=() compset -S ':*' || suf=( -qS: ) - [[ $ostate = tag ]] && suf=() + [[ $ostate = $contexts[-1] ]] && suf=() if compset -P '(|\\)\((*\||)'; then # handle (x|y) patterns suf=() compset -S '(|\\)[)|]*' || @@ -222,7 +257,7 @@ while (( $#state )); do (styles) # Get the top-level context we're completing for, if any. - case $line[1] in + case ${(Q)line[1]} in (:completion:*) ctop=c ;; @@ -235,6 +270,10 @@ while (( $#state )); do ctop=z ;; + (:vcs_info:*) + ctop=v + ;; + (:zle:*) ctop=e ;; @@ -248,7 +287,7 @@ while (( $#state )); do ;; (style-arg) - state+=( "${styles[$line[2]]#*:}" ) + state+=( "${styles[${(Q)line[2]}]#*:}" ) ;; (argument) @@ -278,6 +317,18 @@ while (( $#state )); do _wanted values expl completer _completers -p ;; + (environ) + if [[ "$PREFIX" = *\=* ]]; then + compstate[parameter]="${PREFIX%%\=*}" + compset -P 1 '*=' + _value + else + suf=() + compset -S '=*' || suf=(-S '=') + _parameters -q $suf + fi + ;; + (fsort) _wanted values expl 'how to sort files' \ compadd name size links time date modification access inode change reverse @@ -455,6 +506,64 @@ while (( $#state )); do _wanted word-styles expl 'word style' compadd normal shell space ;; + (vcs-string) + _wanted vcs expl vcs compadd $suf - \ + ${${(f)"$(_call_program vcs vcs_info_printsys 2>/dev/null)"}:#\#*} + ;; + + (vcs) + _wanted vcs expl vcs compadd \ + ${${(f)"$(_call_program vcs vcs_info_printsys 2>/dev/null)"}:#(\#|*-)*} + ;; + + (user-context) + _wanted user-contexts expl 'user context' compadd $suf default command + ;; + + (repo-root-name) + _message -e names 'repository root name' + ;; + + (vcs-format) + if [[ $PREFIX = *% ]]; then + compset -P '*%' + _values -s '' 'format replacement' \ + 's[the vcs in use]' \ + 'b[the current branch]' \ + 'a[an identifier describing the action]' \ + 'i[current revision no/id]' \ + 'c[details of staged changes]' \ + 'u[details of unstaged changes]' \ + 'r[repository name]' \ + 'S[subdirectory within repository]' \ + 'm[misc replacement - backend specific]' + else + _message -e formats 'vcs format' + fi + ;; + + (branch-format) + if [[ $PREFIX = *% ]]; then + compset -P '*%' + _values -s '' 'format replacement' \ + 'b[the current branch]' \ + 'r[current revision number]' \ + else + _message -e formats 'vcs format' + fi + ;; + + (stg-format) + if [[ $PREFIX = *% ]]; then + compset -P '*%' + _values -s '' 'format replacement' \ + 'p[patch currently on top of the stack]' \ + 'c[the number of unapplied patches]' + else + _message -e formats 'vcs format' + fi + ;; + (_*) ${=state[1]} $suf ;;