From a409dbf74c5b0b11fb0d642dd0f5a48ee1f531ba Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Thu, 21 Feb 2013 10:49:22 +0000 Subject: 31058: add completion of options from newer versions of some commands --- Completion/Zsh/Command/_fc | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'Completion/Zsh/Command') diff --git a/Completion/Zsh/Command/_fc b/Completion/Zsh/Command/_fc index bcbb4928e..2af5980c2 100644 --- a/Completion/Zsh/Command/_fc +++ b/Completion/Zsh/Command/_fc @@ -3,17 +3,21 @@ local fc_common fc_hist fc_r fc_common=( - '(-A -R -W -I)-r[reverse order of the commands]' - '(-A -R -W -I -e)-n[suppress line numbers]' - '(-A -R -W -I)*::commands:_command_names -e' ) + '(-A -R -W -I -p -P)-r[reverse order of the commands]' + '(-A -R -W -I -e -p -P)-n[suppress line numbers]' + '(-A -R -W -I -p -P)*::commands:_command_names -e' ) fc_hist=( - '(-A -R -W -I)-m[treat first argument as a pattern]' - '(-A -R -W -I -e -f -E -i)-d[print time-stamps]' - '(-A -R -W -I -e -d -E -i)-f[mm/dd/yyyy format time-stamps]' - '(-A -R -W -I -e -d -f -i)-E[dd.mm.yyyy format time-stamps]' - '(-A -R -W -I -e -d -f -E)-i[yyyy-mm-dd format time-stamps]' - '(-A -R -W -I -e)-D[print elapsed times]' ) + '(-A -R -W -I -p -p)-m[treat first argument as a pattern]' + '(-A -R -W -I -e -f -E -i -t -p -P)-d[print time-stamps]' + '(-A -R -W -I -e -d -E -i -t -p -P)-f[mm/dd/yyyy format time-stamps]' + '(-A -R -W -I -e -d -f -i -t -p -P)-E[dd.mm.yyyy format time-stamps]' + '(-A -R -W -I -e -d -f -E -t -p -P)-i[yyyy-mm-dd format time-stamps]' + '(-A -R -W -I -e -d -f -E -i -p -P)-t[print time-stamps in specified format]:date format' + '(-A -R -W -I -e -p -P)-D[print elapsed times]' + '(- *)-p[push current history to stack]:history file:_files:history size: :saved history size' + '(- *)-P[pop history from stack]' +) fc_r='(-A -R -W -I -e)-l[list resulting commands on stdout]' @@ -26,11 +30,11 @@ case $service in ;; *) _arguments -s -S \ - '(-A -R -W -I -l -n -d -f -E -i -D)-e[specify editor to invoke]:editor to invoke:_command_names -e' \ - '(-l -m -e -r -n -d -f -E -i -D -A -W *)-R[read history from file]:history file:_files' \ - '(-l -m -e -r -n -d -f -E -i -D -R -W *)-A[append history to file]:history file:_files' \ - '(-l -m -e -r -n -d -f -E -i -D -R -A *)-W[write history to file]:history file:_files' \ - '(-l -m -e -r -n -d -f -E -i -D -A -W *)-I[read/write new events only]:history file:_files' \ + '(-A -R -W -I -l -n -d -f -E -i -D -p -P)-e[specify editor to invoke]:editor to invoke:_command_names -e' \ + '(-l -m -e -r -n -d -f -E -i -D -A -W -p -P *)-R[read history from file]:history file:_files' \ + '(-l -m -e -r -n -d -f -E -i -D -R -W -p -P *)-A[append history to file]:history file:_files' \ + '(-l -m -e -r -n -d -f -E -i -D -R -A -p -P *)-W[write history to file]:history file:_files' \ + '(-l -m -e -r -n -d -f -E -i -D -A -W -p -P *)-I[read/write new events only]:history file:_files' \ "$fc_common[@]" "$fc_hist[@]" "$fc_r" && return 0 ;; esac -- cgit v1.2.3 From a45b45eeabe6325ba1c00deaccafd1ec64cdc981 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Fri, 22 Feb 2013 21:58:16 +0000 Subject: 31061: "functions" completion takes account of options already on the command line --- ChangeLog | 4 ++-- Completion/Zsh/Command/_typeset | 28 ++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) (limited to 'Completion/Zsh/Command') diff --git a/ChangeLog b/ChangeLog index f9b7c9081..7a634d4fd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,7 @@ 2013-02-22 Peter Stephenson * 31061: Completion/Zsh/Command/_typeset: "functions" completion - takes accout of options already on the command line. + takes account of options already on the command line. * 31060: Src/builtin.c: "+" before a flag for "functions" or "autoload" should suppress display of function body. @@ -540,5 +540,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5806 $ +* $Revision: 1.5807 $ ***************************************************** diff --git a/Completion/Zsh/Command/_typeset b/Completion/Zsh/Command/_typeset index d44783d64..0920e3fb5 100644 --- a/Completion/Zsh/Command/_typeset +++ b/Completion/Zsh/Command/_typeset @@ -12,7 +12,9 @@ allargs=( F "($fopts -A -E -L -R -T -U -Z -a -i -m)-F[floating point, use fixed point decimal on output]" L "($fopts -A -E -F -i)-L+[left justify and remove leading blanks from value]:width" R "($fopts -A -E -F -i)-R+[right justify and fill with leading blanks]:width" - T "($fopts -A -E -F -a -g -h -i -l -m -t)-T[tie scalar to array]" + T "($fopts -A -E -F -a -g -h -i -l -m -t)-T[tie scalar to array or trace function]" + Tf "($popts -t)-T[trace execution of this function only]" + Tp "($fopts -A -E -F -a -g -h -i -l -m -t)-T[tie scalar to array]" U '(-A -E -F -i)-U[keep array values unique and suppress alias expansion for functions]' Uf '-U[suppress alias expansion for functions]' Up '(-E -F -i)-+U[keep array values unique]' @@ -49,7 +51,7 @@ case ${service} in ;; float) use="EFHghlprtux";; functions) - use="Ukmtuz" + use="UkmTtuz" func=f ;; integer) @@ -64,6 +66,12 @@ esac [[ -z "${words[(r)-*[aA]*]}" ]] || func=p [[ -z "${words[(r)-*f*]}" ]] || func=f +# This function uses whacky features of _arguments which means we +# need to look for options to the command beforehand. +local onopts offopts +onopts=${(j..)${${words[1,CURRENT-1]:#^-*}##-}} +offopts=${(j..)${${words[1,CURRENT-1]:#^+*}##+}} + for ((i=1;i<=$#use;++i)); do args+=( ${allargs[${use[$i]}${${(s::)use[$i]}[(r)[Uut]]:+$func}]} ) done @@ -81,6 +89,22 @@ if [[ "$state" = vars_eq ]]; then funckeys=(${(k)functions}) args=(${args:|funckeys}) _wanted functions expl 'shell function' compadd -a args + elif [[ -n $onopts$offopts ]]; then + if [[ -n $offopts ]]; then + args=(${(f)"$(functions +$offopts)"}) + else + args=(${(k)functions}) + fi + if [[ -n $onopts ]]; then + local -a funckeys + funckeys=(${(f)"$(functions +$onopts)"}) + args=(${args:|funckeys}) + fi + if zstyle -t ":completion:${curcontext}:functions" prefix-needed && + [[ $PREFIX != [_.]* ]]; then + args=(${args:#_*}) + fi + _wanted functions expl 'shell functions' compadd -a args else _functions fi -- cgit v1.2.3 From 012668e14ec7305c404975da8c5ba648c1586a82 Mon Sep 17 00:00:00 2001 From: "Barton E. Schaefer" Date: Tue, 10 Sep 2013 08:14:37 -0700 Subject: 31714: handle ".." properly when $PWD or the path prefix traverses a symbolic link. --- ChangeLog | 5 +++++ Completion/Zsh/Command/_cd | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'Completion/Zsh/Command') diff --git a/ChangeLog b/ChangeLog index 829973181..196b78dd6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-09-10 Barton E. Schaefer + + * 31714: Completion/Zsh/Command/_cd: handle ".." properly when + $PWD or the path prefix traverses a symbolic link. + 2013-09-08 Peter Stephenson * 31711: Doc/Zsh/contrib.yo, Functions/MIME/zsh-mime-handler: diff --git a/Completion/Zsh/Command/_cd b/Completion/Zsh/Command/_cd index 476947f60..a5d328fc5 100644 --- a/Completion/Zsh/Command/_cd +++ b/Completion/Zsh/Command/_cd @@ -51,6 +51,18 @@ else _directory_stack && ret=0 fi + local -a tmpWpath + if [[ $PREFIX = (|*/)../* ]]; then + local tmpprefix + # Use cd in a subshell to properly [not] resolve symlinks + tmpprefix=$(cd ${PREFIX%/*} >&/dev/null && print $PWD) + if [[ -n $tmpprefix ]]; then + tmpWpath=(-W $tmpprefix) + IPREFIX=${IPREFIX}${PREFIX%/*}/ + PREFIX=${PREFIX##*/} + fi + fi + if [[ $PREFIX != (\~|/|./|../)* ]]; then local tmpcdpath alt @@ -88,7 +100,7 @@ else # already handled by _command_names (see _autocd) [[ CURRENT -ne 1 || ( -z "$path[(r).]" && $PREFIX != */* ) ]] && - alt=( "${cdpath+local-}directories:${cdpath+local }directory:_path_files -/" "$alt[@]" ) + alt=( "${cdpath+local-}directories:${cdpath+local }directory:_path_files $tmpWpath -/" "$alt[@]" ) if [[ CURRENT -eq argstart && noopts -eq 0 && $PREFIX = -* ]] && zstyle -t ":completion:${curcontext}:options" complete-options; then @@ -100,7 +112,7 @@ else return ret fi [[ CURRENT -ne 1 ]] && _wanted directories expl directory \ - _path_files -/ && ret=0 + _path_files $tmpWpath -/ && ret=0 return ret fi -- cgit v1.2.3 From 6f921b91f475f77c1447fed4cada24235958b13d Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Wed, 9 Oct 2013 17:28:53 +0200 Subject: 31805: Update _enable and _disable for -p, fix related typo in docs --- Completion/Zsh/Command/_disable | 9 +++++---- Completion/Zsh/Command/_enable | 8 +++++--- Doc/Zsh/builtins.yo | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) (limited to 'Completion/Zsh/Command') diff --git a/Completion/Zsh/Command/_disable b/Completion/Zsh/Command/_disable index 3b627fb5f..68be75fd4 100644 --- a/Completion/Zsh/Command/_disable +++ b/Completion/Zsh/Command/_disable @@ -1,9 +1,10 @@ #compdef disable _arguments -C -s -A "-*" -S \ - "(-f -r -s)-a[act on regular or global aliases]:*:regular or global aliases:(${(k)aliases} ${(k)galiases})" \ - "(-a -r -s)-f[act on functions]:*:functions:(${(k)functions})" \ - "(-a -f -s)-r[act on reserved words]:*:reserved-words:compadd -k reswords" \ - "(-a -f -r)-s[act on suffix aliases]:*:suffix aliases:(${(k)saliases})" \ + "(-f -r -s -p)-a[act on regular or global aliases]:*:regular or global aliases:(${(k)aliases} ${(k)galiases})" \ + "(-a -r -s -p)-f[act on functions]:*:functions:(${(k)functions})" \ + "(-a -f -s -p)-r[act on reserved words]:*:reserved-words:compadd -k reswords" \ + "(-a -f -r -p)-s[act on suffix aliases]:*:suffix aliases:(${(k)saliases})" \ + "(-a -f -r -s)-p[act on pattern characters]:*:pattern characters:compadd -k patchars" \ '-m[treat arguments as patterns]' \ "*:builtin command:(${(k)builtins})" diff --git a/Completion/Zsh/Command/_enable b/Completion/Zsh/Command/_enable index c5f8b2c43..f7737823f 100644 --- a/Completion/Zsh/Command/_enable +++ b/Completion/Zsh/Command/_enable @@ -1,8 +1,10 @@ #compdef enable _arguments -C -s -A "-*" -S \ - "(-f -r)-a[act on aliases]:*:aliases:(${(k)dis_aliases})" \ - "(-a -r)-f[act on functions]:*:functions:(${(k)dis_functions})" \ - "(-a -f)-r[act on reserved words]:*:reserved-words:compadd -k dis_reswords" \ + "(-f -r -s -p)-a[act on regular or global aliases]:*:aliases:(${(k)dis_aliases} ${(k)dis_galiases})" \ + "(-a -r -s -p)-f[act on functions]:*:functions:(${(k)dis_functions})" \ + "(-a -f -s -p)-r[act on reserved words]:*:reserved-words:compadd -k dis_reswords" \ + "(-a -f -r -p)-s[act on suffix aliases]:*:suffix aliases:(${(k)dis_saliases})" \ + "(-a -f -r -s)-p[act on pattern characters]:*:pattern characters:compadd -k dis_patchars" \ '-m[treat arguments as patterns]' \ "*:builtin command:(${(k)dis_builtins})" diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo index 8e46a88ee..2cc33d241 100644 --- a/Doc/Zsh/builtins.yo +++ b/Doc/Zsh/builtins.yo @@ -471,7 +471,7 @@ problems in scripts and functions are altered. If the tt(-L) switch is given, the options tt(LOCAL_OPTIONS), tt(LOCAL_PATTERNS) and tt(LOCAL_TRAPS) will be set as well, causing the effects of the tt(emulate) command and any tt(setopt), -tt(disable -p) or tt(enable -b), and tt(trap) commands to be local to +tt(disable -p) or tt(enable -p), and tt(trap) commands to be local to the immediately surrounding shell function, if any; normally these options are turned off in all emulation modes except tt(ksh). The tt(-L) switch is mutually exclusive with the -- cgit v1.2.3 From 38adc173369ae5b4cf4c3175494edd9743724640 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Wed, 9 Oct 2013 19:02:13 +0200 Subject: 31806: _enable _disable: Workaround special characters in alias and function names breaking _arguments syntax --- Completion/Zsh/Command/_disable | 12 +++++++++--- Completion/Zsh/Command/_enable | 12 +++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) (limited to 'Completion/Zsh/Command') diff --git a/Completion/Zsh/Command/_disable b/Completion/Zsh/Command/_disable index 68be75fd4..52b82a6e9 100644 --- a/Completion/Zsh/Command/_disable +++ b/Completion/Zsh/Command/_disable @@ -1,10 +1,16 @@ #compdef disable +local -a ali_arr sali_arr func_arr + +ali_arr=(${(k)aliases} ${(k)galiases}) +sali_arr=(${(k)saliases}) +func_arr=(${(k)functions}) + _arguments -C -s -A "-*" -S \ - "(-f -r -s -p)-a[act on regular or global aliases]:*:regular or global aliases:(${(k)aliases} ${(k)galiases})" \ - "(-a -r -s -p)-f[act on functions]:*:functions:(${(k)functions})" \ + "(-f -r -s -p)-a[act on regular or global aliases]:*:regular or global aliases:compadd -k ali_arr" \ + "(-a -r -s -p)-f[act on functions]:*:functions:compadd -k func_arr" \ "(-a -f -s -p)-r[act on reserved words]:*:reserved-words:compadd -k reswords" \ - "(-a -f -r -p)-s[act on suffix aliases]:*:suffix aliases:(${(k)saliases})" \ + "(-a -f -r -p)-s[act on suffix aliases]:*:suffix aliases:compadd -k sali_arr" \ "(-a -f -r -s)-p[act on pattern characters]:*:pattern characters:compadd -k patchars" \ '-m[treat arguments as patterns]' \ "*:builtin command:(${(k)builtins})" diff --git a/Completion/Zsh/Command/_enable b/Completion/Zsh/Command/_enable index f7737823f..9410651b7 100644 --- a/Completion/Zsh/Command/_enable +++ b/Completion/Zsh/Command/_enable @@ -1,10 +1,16 @@ #compdef enable +local -a ali_arr sali_arr func_arr + +ali_arr=(${(k)dis_aliases} ${(k)dis_galiases}) +sali_arr=(${(k)dis_saliases}) +func_arr=(${(k)dis_functions}) + _arguments -C -s -A "-*" -S \ - "(-f -r -s -p)-a[act on regular or global aliases]:*:aliases:(${(k)dis_aliases} ${(k)dis_galiases})" \ - "(-a -r -s -p)-f[act on functions]:*:functions:(${(k)dis_functions})" \ + "(-f -r -s -p)-a[act on regular or global aliases]:*:aliases:compadd -k ali_arr" \ + "(-a -r -s -p)-f[act on functions]:*:functions:compadd -k func_arr" \ "(-a -f -s -p)-r[act on reserved words]:*:reserved-words:compadd -k dis_reswords" \ - "(-a -f -r -p)-s[act on suffix aliases]:*:suffix aliases:(${(k)dis_saliases})" \ + "(-a -f -r -p)-s[act on suffix aliases]:*:suffix aliases:compadd -k sali_arr" \ "(-a -f -r -s)-p[act on pattern characters]:*:pattern characters:compadd -k dis_patchars" \ '-m[treat arguments as patterns]' \ "*:builtin command:(${(k)dis_builtins})" -- cgit v1.2.3