diff options
author | Axel Beckert <abe@deuxchevaux.org> | 2016-12-04 04:32:03 +0100 |
---|---|---|
committer | Axel Beckert <abe@deuxchevaux.org> | 2016-12-04 04:32:03 +0100 |
commit | 3e439c3863f14c82f70666804c8570a13b3732e6 (patch) | |
tree | 07036c43e0f3f9242bb6dd42cd2a849ec8ea8aca /Completion/Base | |
parent | 2aedc4b88fd0e87b89583983951b04b96f48efd3 (diff) | |
parent | 7b7e84f0815ed22a0ee348a217776529035dccf3 (diff) | |
download | zsh-3e439c3863f14c82f70666804c8570a13b3732e6.tar.gz zsh-3e439c3863f14c82f70666804c8570a13b3732e6.zip |
Merge tag 'zsh-5.2-test-1' into debian
Diffstat (limited to 'Completion/Base')
-rw-r--r-- | Completion/Base/Completer/_expand | 9 | ||||
-rw-r--r-- | Completion/Base/Completer/_external_pwds | 8 | ||||
-rw-r--r-- | Completion/Base/Completer/_user_expand | 11 | ||||
-rw-r--r-- | Completion/Base/Core/_main_complete | 3 | ||||
-rw-r--r-- | Completion/Base/Core/_message | 3 | ||||
-rw-r--r-- | Completion/Base/Core/_normal | 4 | ||||
-rw-r--r-- | Completion/Base/Utility/_arguments | 24 | ||||
-rw-r--r-- | Completion/Base/Utility/_call_program | 16 | ||||
-rw-r--r-- | Completion/Base/Utility/_values | 2 | ||||
-rw-r--r-- | Completion/Base/Widget/_complete_help | 3 | ||||
-rw-r--r-- | Completion/Base/Widget/_correct_filename | 2 | ||||
-rw-r--r-- | Completion/Base/Widget/_most_recent_file | 2 |
12 files changed, 61 insertions, 26 deletions
diff --git a/Completion/Base/Completer/_expand b/Completion/Base/Completer/_expand index e52144cb7..a6e30e891 100644 --- a/Completion/Base/Completer/_expand +++ b/Completion/Base/Completer/_expand @@ -181,7 +181,7 @@ if [[ -z "$compstate[insert]" ]] ;then else _tags all-expansions expansions original - if [[ $#exp -gt 1 ]] && _requested expansions; then + if [[ $#exp -ge 1 ]] && _requested expansions; then local i j normal space dir if [[ "$sort" = menu ]]; then @@ -207,9 +207,14 @@ else (( $#space )) && compadd "$expl[@]" -UQ -qS " " -a space (( $#normal )) && compadd "$expl[@]" -UQ -qS "" -a normal fi - if _requested all-expansions expl 'all expansions'; then + if _requested all-expansions; then local disp dstr + if [[ "$sort" = menu ]]; then + _description all-expansions expl 'all expansions' "o:$word" + else + _description -V all-expansions expl 'all expansions' "o:$word" + fi if [[ "${#${exp}}" -ge COLUMNS ]]; then disp=( -ld dstr ) dstr=( "${(r:COLUMNS-5:)exp} ..." ) diff --git a/Completion/Base/Completer/_external_pwds b/Completion/Base/Completer/_external_pwds index 4ad50f02b..dfc1abe16 100644 --- a/Completion/Base/Completer/_external_pwds +++ b/Completion/Base/Completer/_external_pwds @@ -22,9 +22,13 @@ case $OSTYPE in ) ;; linux*) - dirs=( /proc/${^$(pidof zsh):#$$}/cwd(N:A) ) + dirs=( /proc/${^$(pidof -- -zsh zsh):#$$}/cwd(N:P) ) dirs=( $^dirs(N^@) ) ;; + freebsd*) + dirs=( $(pgrep -U $UID -x zsh) ) + dirs=( $(procstat -h -f $dirs|awk '{if ($3 == "cwd") print $NF}') ) + ;; *) if (( $+commands[lsof] )); then dirs=( ${${${(M)${(f)"$(lsof -a -u $EUID -c zsh -p \^$$ -d cwd -F n -w @@ -32,7 +36,7 @@ case $OSTYPE in fi ;; esac -dirs=( ${(D)dirs} ) +dirs=( ${(D)dirs:#$PWD} ) compstate[pattern_match]='*' _wanted directories expl 'current directory from other shell' \ diff --git a/Completion/Base/Completer/_user_expand b/Completion/Base/Completer/_user_expand index cf3d172f0..ee39bb176 100644 --- a/Completion/Base/Completer/_user_expand +++ b/Completion/Base/Completer/_user_expand @@ -27,7 +27,7 @@ exp=("$word") # Now look for user completions. -zstyle -a ":completion:${curcontext}" user-expand specs || return 1 +zstyle -a ":completion:${curcontext}:" user-expand specs || return 1 for spec in $specs; do REPLY= @@ -95,7 +95,7 @@ if [[ -z "$compstate[insert]" ]] ;then else _tags all-expansions expansions original - if [[ $#exp -gt 1 ]] && _requested expansions; then + if [[ $#exp -ge 1 ]] && _requested expansions; then local i j normal space dir if [[ "$sort" = menu ]]; then @@ -121,9 +121,14 @@ else (( $#space )) && compadd "$expl[@]" -UQ -qS " " -a space (( $#normal )) && compadd "$expl[@]" -UQ -qS "" -a normal fi - if _requested all-expansions expl "all expansions${REPLY:+: $REPLY}"; then + if _requested all-expansions; then local disp dstr + if [[ "$sort" = menu ]]; then + _description all-expansions expl "all expansions${REPLY:+: $REPLY}" "o:$word" + else + _description -V all-expansions expl "all expansions${REPLY:+: $REPLY}" "o:$word" + fi if [[ "${#${exp}}" -ge COLUMNS ]]; then disp=( -ld dstr ) dstr=( "${(r:COLUMNS-5:)exp} ..." ) diff --git a/Completion/Base/Core/_main_complete b/Completion/Base/Core/_main_complete index 9c4cfac85..aa2486236 100644 --- a/Completion/Base/Core/_main_complete +++ b/Completion/Base/Core/_main_complete @@ -38,6 +38,9 @@ local func funcs ret=1 tmp _compskip format nm call match min max i num\ _saved_colors="$ZLS_COLORS" \ _saved_colors_set=${+ZLS_COLORS} \ _ambiguous_color='' +# Hide any '_comp_priv_prefix' variable that happens to be defined in the calling scope. +local _comp_priv_prefix +unset _comp_priv_prefix # _precommand sets this to indicate we are following a precommand modifier local -a precommands diff --git a/Completion/Base/Core/_message b/Completion/Base/Core/_message index 13c83989f..4d5645eaf 100644 --- a/Completion/Base/Core/_message +++ b/Completion/Base/Core/_message @@ -18,7 +18,8 @@ if [[ "$1" = -e ]]; then ret=0 done - (( $compstate[nmatches] )) || compstate[insert]= + (( ! $compstate[nmatches] )) && [[ $compstate[insert] = *unambiguous* ]] && + compstate[insert]= return ret fi diff --git a/Completion/Base/Core/_normal b/Completion/Base/Core/_normal index 539b3781f..dd607d2b2 100644 --- a/Completion/Base/Core/_normal +++ b/Completion/Base/Core/_normal @@ -30,9 +30,9 @@ if [[ CURRENT -eq 1 ]]; then curcontext="${curcontext%:*:*}:-command-:" comp="$_comps[-command-]" - [[ -n "$comp" ]] && eval "$comp" && ret=0 + [[ -n "$comp" ]] && eval "$comp" && return - return ret + return 1 fi _set_command diff --git a/Completion/Base/Utility/_arguments b/Completion/Base/Utility/_arguments index 87fb20e6b..d2c0d33de 100644 --- a/Completion/Base/Utility/_arguments +++ b/Completion/Base/Utility/_arguments @@ -36,7 +36,7 @@ if (( long )); then tmpargv=( "${(@)argv[1,long-1]}" ) # optspec's before --, if any - name=${~words[1]} + name=${~words[1]} 2>/dev/null [[ "$name" = [^/]*/* ]] && name="$PWD/$name" name="_args_cache_${name}" @@ -105,7 +105,10 @@ if (( long )); then continue else # Still no comment, add the previous options anyway. - lopts+=("${tmp[@]}") + # Add a ':' after the option anyways, to make the matching of + # the options lateron work as intended. + # It will be removed again later. + lopts+=("${^tmp[@]}":) tmp=() fi fi @@ -147,7 +150,7 @@ if (( long )); then done # Tidy up any remaining uncommented options. if (( ${#tmp} )); then - lopts+=("${tmp[@]}") + lopts+=("${^tmp[@]}":) fi # Remove options also described by user-defined specs. @@ -220,19 +223,22 @@ if (( long )); then # Ignore :descriptions at the ends of lopts for matching this; # they aren't in the patterns. - tmp=("${(@M)lopts:##$~pattern(|:*)}") - lopts=("${(@)lopts:##$~pattern(|:*)}") + tmp=("${(@M)lopts:##$~pattern:*}") + lopts=("${(@)lopts:##$~pattern:*}") (( $#tmp )) || continue opt='' + # Clean suffix ':' added earlier + tmp=("${(@)tmp%:}") + # If there are option strings with a `[=', we take these to get an # optional argument. - tmpo=("${(@M)tmp:#*\[\=*}") + tmpo=("${(@M)tmp:#[^:]##\[\=*}") if (( $#tmpo )); then - tmp=("${(@)tmp:#*\[\=*}") + tmp=("${(@)tmp:#[^:]##\[\=*}") for opt in "$tmpo[@]"; do # Look for --option:description and turn it into @@ -263,9 +269,9 @@ if (( long )); then # Basically the same as the foregoing. # TODO: could they be combined? - tmpo=("${(@M)tmp:#*\=*}") + tmpo=("${(@M)tmp:#[^:]##\=*}") if (( $#tmpo )); then - tmp=("${(@)tmp:#*\=*}") + tmp=("${(@)tmp:#[^:]##\=*}") for opt in "$tmpo[@]"; do if [[ $opt = (#b)(*):([^:]#) ]]; then diff --git a/Completion/Base/Utility/_call_program b/Completion/Base/Utility/_call_program index 010e09476..9a44f2d8e 100644 --- a/Completion/Base/Utility/_call_program +++ b/Completion/Base/Utility/_call_program @@ -1,6 +1,16 @@ #autoload +X -local tmp err_fd=-1 +local curcontext="${curcontext}" tmp err_fd=-1 +local -a prefix + +if [[ "$1" = -p ]]; then + shift + if (( $#_comp_priv_prefix )); then + curcontext="${curcontext%:*}/${${(@M)_comp_priv_prefix:#^*[^\\]=*}[1]}:" + zstyle -t ":completion:${curcontext}:${1}" gain-privileges && + prefix=( $_comp_priv_prefix ) + fi +fi if (( ${debug_fd:--1} > 2 )) || [[ ! -t 2 ]] then exec {err_fd}>&2 # debug_fd is saved stderr, 2 is trace or redirect @@ -13,10 +23,10 @@ if zstyle -s ":completion:${curcontext}:${1}" command tmp; then if [[ "$tmp" = -* ]]; then eval "$tmp[2,-1]" "$argv[2,-1]" else - eval "$tmp" + eval $prefix "$tmp" fi else - eval "$argv[2,-1]" + eval $prefix "$argv[2,-1]" fi 2>&$err_fd } always { diff --git a/Completion/Base/Utility/_values b/Completion/Base/Utility/_values index ab0e46a9c..c510b4cc0 100644 --- a/Completion/Base/Utility/_values +++ b/Completion/Base/Utility/_values @@ -3,7 +3,7 @@ local subopts opt usecc garbage subopts=() -zparseopts -D -E -a garbage C=usecc O:=subopts M: J: V: 1 2 n F: X: +zparseopts -D -a garbage C=usecc O:=subopts M: J: V: 1 2 n F: X: (( $#subopts )) && subopts=( "${(@P)subopts[2]}" ) diff --git a/Completion/Base/Widget/_complete_help b/Completion/Base/Widget/_complete_help index 09637ecb9..252b0e281 100644 --- a/Completion/Base/Widget/_complete_help +++ b/Completion/Base/Widget/_complete_help @@ -11,6 +11,7 @@ _complete_help() { { compadd() { return 1 } + compcall() { _help_sort_tags use-compctl } zstyle() { local _f="${${(@)${(@)funcstack[2,(i)_($~_help_scan_funcstack)]}:#(_($~_help_filter_funcstack)|\((eval|anon)\))}% *}" @@ -42,7 +43,7 @@ _complete_help() { ${1:-_main_complete} } always { - unfunction compadd zstyle + unfunction compadd compcall zstyle } for i in "${(@ok)help_funcs}"; do diff --git a/Completion/Base/Widget/_correct_filename b/Completion/Base/Widget/_correct_filename index 7431a4831..3150ffcdb 100644 --- a/Completion/Base/Widget/_correct_filename +++ b/Completion/Base/Widget/_correct_filename @@ -28,7 +28,7 @@ fi if [[ $file = \~*/* ]]; then tilde=${file%%/*} - etilde=${~tilde} + etilde=${~tilde} 2>/dev/null file=${file/#$tilde/$etilde} fi diff --git a/Completion/Base/Widget/_most_recent_file b/Completion/Base/Widget/_most_recent_file index 68d1c91a2..e72cf5e8d 100644 --- a/Completion/Base/Widget/_most_recent_file +++ b/Completion/Base/Widget/_most_recent_file @@ -11,7 +11,7 @@ local file tilde etilde if [[ $PREFIX = \~*/* ]]; then tilde=${PREFIX%%/*} - etilde=${~tilde} + etilde=${~tilde} 2>/dev/null # PREFIX and SUFFIX have full command line quoting in, but we want # any globbing characters which are quoted to stay quoted. eval "file=($PREFIX*$SUFFIX(om[${NUMERIC:-1}]N))" |