about summary refs log tree commit diff
path: root/Completion/Unix/Type
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Unix/Type')
-rw-r--r--Completion/Unix/Type/_absolute_command_paths12
-rw-r--r--Completion/Unix/Type/_baudrates (renamed from Completion/Unix/Type/_baudrate)58
-rw-r--r--Completion/Unix/Type/_canonical_paths93
-rw-r--r--Completion/Unix/Type/_date_formats21
-rw-r--r--Completion/Unix/Type/_dates7
-rw-r--r--Completion/Unix/Type/_diff_options27
-rw-r--r--Completion/Unix/Type/_email_addresses2
-rw-r--r--Completion/Unix/Type/_files3
-rw-r--r--Completion/Unix/Type/_hosts24
-rw-r--r--Completion/Unix/Type/_path_files12
-rw-r--r--Completion/Unix/Type/_pspdf2
-rw-r--r--Completion/Unix/Type/_remote_files19
-rw-r--r--Completion/Unix/Type/_signals13
-rw-r--r--Completion/Unix/Type/_sys_calls20
-rw-r--r--Completion/Unix/Type/_tilde_files3
-rw-r--r--Completion/Unix/Type/_zfs_dataset8
16 files changed, 182 insertions, 142 deletions
diff --git a/Completion/Unix/Type/_absolute_command_paths b/Completion/Unix/Type/_absolute_command_paths
index e9ab17023..0d52ff851 100644
--- a/Completion/Unix/Type/_absolute_command_paths
+++ b/Completion/Unix/Type/_absolute_command_paths
@@ -7,7 +7,9 @@ _hashed_absolute_command_paths() {
   integer ret=1
   for i in $set_of_dirs_of_hashed_commands
   do
-    compadd -M "l:|=$i" "$expl[@]" -a 'commands[(R)${~i}[^/]#]'
+    local -a matches=( "${(@)commands[(R)${~i}[^/]#]}" )
+    local -a descs=( $matches:t )
+    compadd -M "l:|=$i" -d descs "$@" -a matches
     ret=0
   done
   return ret
@@ -16,7 +18,13 @@ _hashed_absolute_command_paths() {
 # This function completes absolute pathnames of executables, e.g., /etc/rc.local
 _typed-in_absolute_command_paths() {
   # TODO: the description "full path to an executable" and tag in the caller are ignored by _path_files
-  _path_files -/ -g '*(-*)' -P / -W /
+  if [[ -z $PREFIX ]]; then
+    _path_files -/ -g '*(-*)' -P / -W /
+  elif [[ $PREFIX[1] == / ]]; then
+    _path_files -/ -g '*(-*)' -W /
+  else
+    return 1
+  fi
 }
 
 _absolute_command_paths() {
diff --git a/Completion/Unix/Type/_baudrate b/Completion/Unix/Type/_baudrates
index c16928444..add359d13 100644
--- a/Completion/Unix/Type/_baudrate
+++ b/Completion/Unix/Type/_baudrates
@@ -2,7 +2,7 @@
 
 # Offer a list of baud-rates. Usage:
 #
-#   _baudrate [OPTION(s)...]
+#   _baudrates [OPTION(s)...]
 #
 # Available options:
 #
@@ -15,10 +15,6 @@
 #                  value in the complete list to generate an arbitrary
 #                  sub-set.
 #
-#     -t TAG       Use TAG as the tag value in _wanted call.
-#
-#     -d DESC      Use DESC as the description value in _wanted call.
-#
 # The default complete list of available baud rates is also configurable via
 # the 'baud-rates' style:
 #
@@ -27,15 +23,15 @@
 # It is also possible to override the arguments to -f, -u and -l via styles in
 # a similar fashion:
 #
-#   zstyle ':completion:*:*:screen:*' max-baud-rate 9600
-#   zstyle ':completion:*:*:screen:*' min-baud-rate 1200
-#   zstyle ':completion:*:*:screen:*' baud-rate-filter some_function_name
+#   zstyle ':completion:*:*:screen:*:baud-rates' max-value 9600
+#   zstyle ':completion:*:*:screen:*:baud-rates' min-value 1200
+#   zstyle ':completion:*:*:screen:*:baud-rates' filter some_function_name
 
+local tmp
+local -a expl rates
 local -A opts
-local expl tag desc tmp
-local -a rates
 
-zparseopts -E -A opts u: l: f: d: t:
+zparseopts -E -A opts u: l: f:
 
 # The following uses a generated list; first find out where the B* macros are
 # defined:
@@ -51,34 +47,32 @@ zparseopts -E -A opts u: l: f: d: t:
 # which is synonymous to "hang-up".
 
 zstyle -a ":completion:${curcontext}:" baud-rates rates ||
-    rates=( 50 75 110 134 150 200 300 600
-            1200 1800 2400 4800 9600
-            19200 38400 57600
-            115200 230400 460800 500000 576000 921600
-            1000000 1152000 1500000 2000000 2500000 3000000 3500000 4000000 )
+  rates=( 50 75 110 134 150 200 300 600
+          1200 1800 2400 4800 9600
+          19200 38400 57600
+          115200 230400 460800 500000 576000 921600
+          1000000 1152000 1500000 2000000 2500000 3000000 3500000 4000000 )
 
-zstyle -s ":completion:${curcontext}:" max-baud-rate tmp && opts[-u]=$tmp
-zstyle -s ":completion:${curcontext}:" min-baud-rate tmp && opts[-l]=$tmp
-zstyle -s ":completion:${curcontext}:" baud-rate-filter tmp && opts[-f]=$tmp
+zstyle -s ":completion:${curcontext}:baud-rates" max-value tmp && opts[-u]=$tmp
+zstyle -s ":completion:${curcontext}:baud-rates" min-value tmp && opts[-l]=$tmp
+zstyle -s ":completion:${curcontext}:baud-rates" filter tmp && opts[-f]=$tmp
 
 if (( ${+opts[-u]} )) || (( ${+opts[-l]} )); then
-    local -i min max
-    min=${opts[-l]:-0}
-    max=${opts[-u]:-${${(On)rates}[1]}}
-    rates=( ${(M)rates:#${~:-<$min-$max>}} )
+  local -i min max
+  min=${opts[-l]:-0}
+  max=${opts[-u]:-${${(On)rates}[1]}}
+  rates=( ${(M)rates:#${~:-<$min-$max>}} )
 fi
 
 if (( ${+opts[-f]} )); then
-    set -- $rates
-    rates=( )
-    for item; do
-        ${opts[-f]} $item && rates+=( $item )
-    done
+  set -- $rates
+  rates=( )
+  for item; do
+    ${opts[-f]} $item && rates+=( $item )
+  done
 fi
 
-tag=${opts[-t]:-baud-rate}
-desc=${opts[-d]:-baud rate}
-
 # -1V removes dupes (which there shouldn't be) and otherwise leaves the
 # order in the $rates array intact.
-_wanted -1V $tag expl $desc compadd -a $expl -- rates
+_description -1V baud-rates expl 'baud rate'
+compadd "${(@)argv/#-J/-V}" "$expl[@]" -- "${rates[@]}"
diff --git a/Completion/Unix/Type/_canonical_paths b/Completion/Unix/Type/_canonical_paths
index e4a725b2b..6eab7b677 100644
--- a/Completion/Unix/Type/_canonical_paths
+++ b/Completion/Unix/Type/_canonical_paths
@@ -3,83 +3,59 @@
 # This completion function completes all paths given to it, and also tries to
 # offer completions which point to the same file as one of the paths given
 # (relative path when an absolute path is given, and vice versa; when ..'s are
-# present in the word to be completed, and some paths got from symlinks.
+# present in the word to be completed, and some paths got from symlinks).
 
-# Usage: _canonical_paths [-A var] [-N] [-MJV12nfX] tag desc paths...
+# Usage: _canonical_paths [-A var] [-N] [-MJV12nfX] tag desc [paths...]
 
-# -A, if specified, takes the paths from the array variable specified. Paths can
-# also be specified on the command line as shown above. -N, if specified,
+# -A, if specified, takes the paths from the array variable specified. Paths
+# can also be specified on the command line as shown above. -N, if specified,
 # prevents canonicalizing the paths given before using them for completion, in
 # case they are already so. `tag' and `desc' arguments are well, obvious :) In
 # addition, the options -M, -J, -V, -1, -2, -n, -F, -X are passed to compadd.
 
-_canonical_paths_pwd() {
-  # Get the canonical directory name by changing to it.
-  integer chaselinks
-  [[ -o chaselinks ]] && (( chaselinks = 1 ))
-  setopt localoptions nopushdignoredups chaselinks
-  if builtin pushd -q -- $1 2>/dev/null; then
-    REPLY=$PWD
-    (( chaselinks )) || unsetopt chaselinks
-    builtin popd -q
-  else
-    REPLY=$1
-  fi
-}
-
-_canonical_paths_get_canonical_path() {
-  typeset newfile nondir
-  typeset -A seen
-
-  REPLY=$1
-  # Canonicalise the directory path.  We may not be able to
-  # do this if we can't read all components.
-  if [[ -d $REPLY ]]; then
-    _canonical_paths_pwd $REPLY
-  else
-    # Resolve any trailing symbolic links, guarding against loops.
-    while [[ -z ${seen[$REPLY]} ]]; do
-      seen[$REPLY]=1
-      newfile=()
-      zstat -A newfile +link $REPLY 2>/dev/null
-      if [[ -n $newfile[1] ]]; then
-	REPLY=$newfile[1]
-      else
-	break
-      fi
-    done
-    if [[ $REPLY = */*[^/] && $REPLY != /[^/]# ]]; then
-      # Don't try this if there's a trailing slash or we're in
-      # the root directory.
-      nondir=${REPLY##*/#}
-      _canonical_paths_pwd ${REPLY%/#*}
-      REPLY+="/$nondir"
-    fi
-  fi
-}
-
 _canonical_paths_add_paths () {
+  # origpref = original prefix
+  # expref = expanded prefix
+  # curpref = current prefix
+  # canpref = canonical prefix
+  # rltrim = suffix to trim and readd
   local origpref=$1 expref rltrim curpref canpref subdir
   [[ $2 != add ]] && matches=()
   expref=${~origpref} 2>/dev/null
   [[ $origpref == (|*/). ]] && rltrim=.
   curpref=${${expref%$rltrim}:-./}
-  if zstat $curpref >&/dev/null; then
-    _canonical_paths_get_canonical_path $curpref
-    canpref=$REPLY
-  else
-    canpref=$curpref
-  fi
+  canpref=$curpref:P
   [[ $curpref == */ && $canpref == *[^/] ]] && canpref+=/
   canpref+=$rltrim
   [[ $expref == *[^/] && $canpref == */ ]] && origpref+=/
-  matches+=(${${(M)files:#$canpref*}/$canpref/$origpref})
+
+  # Append to $matches the subset of $files that matches $canpref.
+  if [[ $canpref == $origpref ]]; then
+    # This codepath honours any -M matchspec parameters.
+    () {
+      local -a tmp_buffer
+      compadd -A tmp_buffer "$__gopts[@]" -a files
+      matches+=( "${(@)tmp_buffer/$canpref/$origpref}" )
+    }
+  else
+    # ### Ideally, this codepath would do what the 'if' above does,
+    # ### but telling compadd to pretend the "word on the command line"
+    # ### is ${"the word on the command line"/$origpref/$canpref}.
+    matches+=(${${(M)files:#$canpref*}/$canpref/$origpref})
+  fi
+
   for subdir in $expref?*(@); do
     _canonical_paths_add_paths ${subdir/$expref/$origpref} add
   done
 }
 
 _canonical_paths() {
+  # The following parameters are used by callee functions:
+  #    __gopts
+  #    matches
+  #    files
+  #    (possibly others)
+
   local __index
   typeset -a __gopts __opts
 
@@ -105,10 +81,7 @@ _canonical_paths() {
   if (( $__opts[(I)-N] )); then
     files=($@)
   else
-    for __index in $@; do
-      _canonical_paths_get_canonical_path $__index
-      files+=($REPLY)
-    done
+    files+=($@:P)
   fi
 
   local base=$PREFIX
diff --git a/Completion/Unix/Type/_date_formats b/Completion/Unix/Type/_date_formats
index 09f8cab52..6bd5c6d6b 100644
--- a/Completion/Unix/Type/_date_formats
+++ b/Completion/Unix/Type/_date_formats
@@ -19,27 +19,24 @@ compset -S '%*'
 specs=(
   'a:abbreviated day name'
   'A:full day name'
-  'b:abbreviated month name'
+  {b,h}':abbreviated month name'
   'B:full month name'
   'c:preferred locale date and time'
   'C:2-digit century'
   'd:day of month (01-31)'
   'D:american format month/day/year (%m/%d/%y)'
   'e:day of month ( 1-31)'
-  'E:alternate representation'
   'F:ISO 8601 year-month-date (%Y-%m-%d)'
   'G:4-digit ISO 8601 week-based year'
   'g:2-digit ISO 8601 week-based year'
-  'h:abbreviated month name'
   'H:hour (00-23)'
   'I:hour (01-12)'
   'j:day of year (001-366)'
-  'k:hour ( 1-23)'
+  'k:hour ( 0-23)'
   'l:hour ( 1-12)'
   'm:month (01-12)'
   'M:minute (00-59)'
   'n:newline'
-  'O:alternative format modifier'
   'p:locale dependent AM/PM'
   'r:locale dependent a.m. or p.m. time (%I:%M:%S %p)'
   'R:24-hour notation time (%H:%M)'
@@ -62,24 +59,26 @@ specs=(
 )
 
 case $OSTYPE in
-  freebsd*|linux-gnu|solaris2.<11->)
+  freebsd*|dragonfly*|darwin*|linux-gnu|solaris2.<11->)
     specs+=(
+      'E:alternate representation'
+      'O:alternative format modifier'
       "-:don't pad numeric values"
-      '#:swap case of alphabetic characters'
       '0:left pad numeric values with zeroes'
-      '^:convert lowercase characters to uppercase'
       '_:left pad numeric values with spaces'
     )
   ;|
   linux-gnu|solaris2.<11->)
     specs+=(
+      '#:swap case of alphabetic characters'
+      '^:convert lowercase characters to uppercase'
       'P:lower case locale dependent am/pm'
     )
   ;|
-  freebsd*)
+  freebsd*|dragonfly*|darwin*|openbsd*|netbsd*)
     specs+=( 'v:date in short form (%e-%b-%Y)' )
   ;|
-  solaris2.<11->|freebsd*)
+  solaris2.<11->|freebsd*|dragonfly*|darwin*|openbsd*)
     specs+=( '+:localized representation of date and time' )
   ;;
   solaris2.<-10>)
@@ -103,4 +102,4 @@ done
 
 _describe -t date-format-specifier 'date format specifier' specs \
     -p "${(Q)PREFIX:-%}" -S ''
-_message -e date-format-precision 'precision for %%. (1-6)'
+[[ $1 == zsh ]] && _message -e date-format-precision 'precision for %%. (1-6)'
diff --git a/Completion/Unix/Type/_dates b/Completion/Unix/Type/_dates
index 83397b45a..0af10eb24 100644
--- a/Completion/Unix/Type/_dates
+++ b/Completion/Unix/Type/_dates
@@ -9,7 +9,7 @@
 #   max-matches-length : maximum number or percentage of lines to use for
 #                        completion listing, if both are specified, the
 #                        lowest takes precedence.
-#   format             : override date format
+#   date-format        : override date format
 
 local -a disp cand expl
 local userformat format spacer=1 spacing month monstart skip match
@@ -22,10 +22,10 @@ local future mlabel mfmt mlabels
 
 zparseopts -D -K -E f:=format F=future
 (( future = $#future ? 1 : -1 ))
-zstyle -s ':completion:$curcontext:dates' date-format userformat
+zstyle -s ":completion:${curcontext}:dates" date-format userformat
 format=${userformat:-${format[2]:-%F}}
 
-zstyle -a ':completion:$curcontext:dates' max-matches-length r
+zstyle -a ":completion:${curcontext}:dates" max-matches-length r
 for ri in $r; do
   [[ $ri = [0-9]##% ]] && (( ri = LINES * .${ri%%%} ))
   (( ri < rows )) && (( rows=ri ))
@@ -37,6 +37,7 @@ _tags dates || return 0
 _comp_mesg=yes
 _description -2V -x dates expl date
 compadd "${@:/-X/-x}" "$expl[@]" -
+[[ -z $MENUSELECT && $WIDGET != menu-select ]] && return
 [[ -n $PREFIX$SUFFIX ]] && return 0
 (( rows )) || return 0
 compstate[list]='packed rows'
diff --git a/Completion/Unix/Type/_diff_options b/Completion/Unix/Type/_diff_options
index 6af392a13..55ddecd2a 100644
--- a/Completion/Unix/Type/_diff_options
+++ b/Completion/Unix/Type/_diff_options
@@ -6,6 +6,25 @@ local -a args
 cmd="$1"
 shift
 
+_diff_palette() {
+  local context state line ret=1
+  local -a suf
+  _values -s : attribute \
+    "ad[added text]:attribute [32]:->attrs" \
+    "de[deleted text]:attribute [31]:->attrs" \
+    "hd[header]:attribute [1]:->attrs" \
+    "ln[line numbers]:attribute [36]:->attrs" \
+    "rs[rest - other text]:attribute [0]:->attrs" && ret=0
+  if [[ -n $state ]]; then
+    compset -P '*;'
+    compset -S '[;=]*' || suf=( -S: -r ": ;\\\t\n\=" )
+    _alternative -C context -O suf \
+      'attributes:attributes:((0:reset 1:bold 3:italics 4:underline 5:blink))' \
+      'colors:color:((30:default 31:red 32:green 33:yellow 34:blue 35:magenta 36:cyan 37:white))' && ret=0
+  fi
+  return ret
+}
+
 if _pick_variant -c $cmd gnu=GNU unix -v; then
   # output formats
   of="-y --side-by-side -n --rcs -e -f --ed -q --brief -c -C --context -u -U \
@@ -46,6 +65,7 @@ if _pick_variant -c $cmd gnu=GNU unix -v; then
     '(--no-ignore-file-name-case)--ignore-file-name-case[ignore case when comparing file names]' \
     '(--ignore-file-name-case)--no-ignore-file-name-case[consider case when comparing file names]' \
     '(-E --ignore-tab-expansion)'{-E,--ignore-tab-expansion}'[ignore changes due to tab expansion]' \
+    '(-Z --ignore-trailing-space)'{-Z,--ignore-trailing-space}'[ignore white space at line end]' \
     '(-b --ignore-space-change)'{-b,--ignore-space-change}'[ignore changes in the amount of white space]' \
     '(--ignore-all-space -w)'{--ignore-all-space,-w}'[ignore all white space]' \
     '(-B --ignore-blank-lines)'{-B,--ignore-blank-lines}'[ignore lines that are all blank]' \
@@ -56,7 +76,7 @@ if _pick_variant -c $cmd gnu=GNU unix -v; then
     "($of $oss)-c[output a context diff]" \
     "($of $oss)"{-U+,--unified=-}'[output a unified diff]:number of lines of unified context' \
     "($of $oss)-u[output a unified diff]" \
-    "($ofwuc $oss)*"{-L+,--label=}'[set label to use instead of file name]:label' \
+    "($ofwuc $oss)*"{-L+,--label=}'[set label to use instead of file name and timestamp]:label' \
     "($ofwuc $oss -p --show-c-function)"{-p,--show-c-function}'[show C function of each change]' \
     "($ofwuc $oss -F --show-function-line)"{-F+,--show-function-line=}'[show the most recent line matching regex]:regex' \
     "($of $ouc $oss)--brief[output only whether files differ]" \
@@ -84,8 +104,9 @@ if _pick_variant -c $cmd gnu=GNU unix -v; then
     '(-l --paginate)'{-l,--paginate}'[output through pr]' \
     '(-t --expand-tabs)'{-t,--expand-tabs}'[expand tabs to spaces]' \
     '(-T --initial-tab)'{-T,--initial-tab}'[prepend a tab]' \
-    '--tabsize=[specify width of tab]:width' \
+    '--tabsize=[specify width of tab]:width [8]' \
     '(-r --recursive)'{-r,--recursive}'[recursively compare subdirectories]' \
+    "--no-dereference[don't follow symbolic links]" \
     '(-N --new-file)'{-N,--new-file}'[treat absent files as empty]' \
     '(-P --unidirectional-new-file)'{-P,--unidirectional-new-file}'[treat absent first files as empty]' \
     '(-s --report-identical-files)'{-s,--report-identical-files}'[report when two files are the same]' \
@@ -97,6 +118,8 @@ if _pick_variant -c $cmd gnu=GNU unix -v; then
     '--horizon-lines=[set number of lines to keep in prefix and suffix]:number of horizon lines' \
     '(-d --minimal)'{-d,--minimal}'[try to find a smaller set of changes]' \
     '(-H --speed-large-files)'{-H,--speed-large-files}'[assume large files and many small changes]' \
+    '--color=-[use colors in output]::when [auto]:(never always auto)' \
+    '--palette=[specify colors to use]:color:_diff_palette' \
     '(-v --version)'{-v,--version}'[display version info]' \
     '--help[display help info]' \
     "$@"
diff --git a/Completion/Unix/Type/_email_addresses b/Completion/Unix/Type/_email_addresses
index 7d5c942de..8a5877a9c 100644
--- a/Completion/Unix/Type/_email_addresses
+++ b/Completion/Unix/Type/_email_addresses
@@ -5,6 +5,8 @@
 # -s sep    - complete a list of addresses separated by specified character
 # -c        - e-mail address must be of form user@host (no comments or aliases)
 #
+# TODO: with -n, have the named plugin complete not only aliases but also addresses?
+# 
 # Plugins are written as separate functions with names starting `_email-'.
 # They should either do their own completion or return the addresses in the
 # reply array in the form 'alias:address' and return 300. The -c option is
diff --git a/Completion/Unix/Type/_files b/Completion/Unix/Type/_files
index fe0780a57..2b0c5580a 100644
--- a/Completion/Unix/Type/_files
+++ b/Completion/Unix/Type/_files
@@ -7,6 +7,7 @@ local ret=1
 # we don't want to complete them multiple times (for each file pattern).
 if _have_glob_qual $PREFIX; then
   compset -p ${#match[1]}
+  compset -S '[^\)\|\~]#(|\))'
   if [[ $_comp_caller_options[extendedglob] == on ]] && compset -P '\#'; then
     _globflags && ret=0
   else
@@ -34,7 +35,7 @@ if (( $tmp[(I)-g*] )); then
   [[ "$glob" = (#b)(*\()([^\|\~]##\)) && $match[2] != \#q* ]] &&
       glob="${match[1]}#q${match[2]}"
 elif [[ $type = */* ]]; then
-  glob="*(-/)"
+  glob="*(#q-/)"
 fi
 tmp=$opts[(I)-F]
 if (( tmp )); then
diff --git a/Completion/Unix/Type/_hosts b/Completion/Unix/Type/_hosts
index c3133dc68..d9e1090a4 100644
--- a/Completion/Unix/Type/_hosts
+++ b/Completion/Unix/Type/_hosts
@@ -45,13 +45,23 @@ if ! zstyle -a ":completion:${curcontext}:hosts" hosts _hosts; then
 
         # known_hosts syntax supports the host being in the form [hostname]:port
         # The filter below extracts the hostname from lines using this format.
-        khosts=($(for host ($khosts); do
-          if [[ $host =~ "\[(.*)\]:\d*" ]]; then
-            echo $match
-          else
-            echo $host
-          fi
-        done))
+        #
+        # known_hosts syntax supports wildcards.  The filter below removes wildcard
+        # entries.
+        () {
+          local host
+          local -a match mbegin mend
+          khosts=()
+          for host; do
+            if [[ $host == *[*?]* ]]; then
+              continue
+            elif [[ $host = (#b)*\[(*)\]:[[:digit:]]#* ]]; then
+              khosts+=${match[1]}
+            else
+              khosts+=$host
+            fi
+          done
+        } "$khosts[@]"
 
         if [[ -z $useip ]]; then
           khosts=(${${khosts:#(#s)[0-9]##.[0-9]##.[0-9]##.[0-9]##(#e)}:#(#s)[0-9a-f:]##(#e)})
diff --git a/Completion/Unix/Type/_path_files b/Completion/Unix/Type/_path_files
index c64ebf58c..9fa6ae9fc 100644
--- a/Completion/Unix/Type/_path_files
+++ b/Completion/Unix/Type/_path_files
@@ -17,6 +17,7 @@ local -a match mbegin mend
 if _have_glob_qual $PREFIX; then
   local ret=1
   compset -p ${#match[1]}
+  compset -S '[^\)\|\~]#(|\))'
   if [[ $_comp_caller_options[extendedglob] == on ]] && compset -P '\#'; then
     _globflags && ret=0
   else
@@ -68,7 +69,7 @@ fi
 pats=( "${(@)pats:# #}" )
 
 if (( $#pfx )); then
-  compset -P "$pfx[2]" || pfxsfx=( "$pfx[@]" "$pfxsfx[@]" )
+  compset -P "${(b)pfx[2]}" || pfxsfx=( "$pfx[@]" "$pfxsfx[@]" )
 fi
 
 if (( $#prepaths )); then
@@ -273,7 +274,7 @@ if [[ "$pre" = [^][*?#^\|\<\>\\]#(\`[^\`]#\`|\$)*/* && "$compstate[quote]" != \'
   orig="${orig[1,(in:i:)/][1,-2]}"
   donepath=
   prepaths=( '' )
-elif [[ "$pre[1]" = \~ && -z "$compstate[quote]" ]]; then
+elif [[ "$pre[1]" = \~ && "$compstate[quote]" = (|\`) ]]; then
 
   # It begins with `~', so remember anything before the first slash to be able
   # to report it to the completion code. Also get an expanded version of it
@@ -376,11 +377,10 @@ for prepath in "$prepaths[@]"; do
     # on, we need to remove quotes from everything that's not a pattern
     # character, because the code that does the file generation only
     # strips quotes from pattern characters (you know better than
-    # to ask why).  Because we need to test for a real directory,
-    # however, for tmp2 we unquote everything.
+    # to ask why).
     tmp1=${match[1]}
     tpre=${match[2]}
-    tmp2=${(Q)tmp1}
+    tmp2=$tmp1
     tmp1=${tmp1//(#b)\\(?)/$match[1]}
     tpre=${tpre//(#b)\\([^\\\]\[\^\~\(\)\#\*\?])/$match[1]}
     # Theory: donepath needs the quoting of special characters
@@ -593,7 +593,7 @@ for prepath in "$prepaths[@]"; do
     # There are more components, so skip over the next components and make a
     # slash be added.
 
-    tmp1=( ${tmp1//(#b)([][()|*?^#~<>\\=])/\\${match[1]}} )
+    #tmp1=( ${tmp1//(#b)([][()|*?^#~<>\\=])/\\${match[1]}} )
     tmp2="${(M)tpre##${~skips}}"
     if [[ -n "$tmp2" ]]; then
       skipped="/$tmp2"
diff --git a/Completion/Unix/Type/_pspdf b/Completion/Unix/Type/_pspdf
index d0ca31a7c..5bb8650b1 100644
--- a/Completion/Unix/Type/_pspdf
+++ b/Completion/Unix/Type/_pspdf
@@ -1,4 +1,4 @@
-#compdef evince gsbj gsdj gsdj500 gslj gslp gsnd ps2ascii ghostview mgv pstoedit pstotgif zathura
+#compdef gsbj gsdj gsdj500 gslj gslp gsnd ps2ascii ghostview mgv pstoedit pstotgif zathura
 
 local expl ext
 
diff --git a/Completion/Unix/Type/_remote_files b/Completion/Unix/Type/_remote_files
index db3316422..a5fce9afd 100644
--- a/Completion/Unix/Type/_remote_files
+++ b/Completion/Unix/Type/_remote_files
@@ -28,16 +28,19 @@
 
 
 # There should be coloring based on all the different ls -F classifiers.
-local expl rempat remfiles remdispf remdispd args cmd cmd_args suf ret=1
+local expl rempat remfiles remdispf remdispd args cmd suf ret=1
+local -a args cmd_args
 local glob host
 
 if zstyle -T ":completion:${curcontext}:files" remote-access; then
 
   # Parse options to _remote_files. Stops at the first "--".
   zparseopts -D -E -a args / g:=glob h:=host
-  shift
   (( $#host)) && shift host || host="${IPREFIX%:}"
 
+  args=( ${argv[1,(i)--]} )
+  shift ${#args}
+  [[ $args[-1] = -- ]] && args[-1]=()
   # Command to run on the remote system.
   cmd="$1"
   shift
@@ -45,9 +48,9 @@ if zstyle -T ":completion:${curcontext}:files" remote-access; then
   # Handle arguments to ssh.
   if [[ $cmd == ssh ]]; then
     zparseopts -D -E -a cmd_args p: 1 2 4 6 F:
-    cmd_args="-o BatchMode=yes $cmd_args -a -x"
+    cmd_args=( -o BatchMode=yes "$cmd_args[@]" -a -x )
   else
-    cmd_args="$@"
+    cmd_args=( "$@" )
   fi
 
   if [[ -z $QIPREFIX ]]
@@ -55,11 +58,13 @@ if zstyle -T ":completion:${curcontext}:files" remote-access; then
     else rempat="${(q)PREFIX%%[^./][^/]#}\*"
   fi
 
+  # remote filenames
   remfiles=(${(M)${(f)"$(_call_program files $cmd $cmd_args $host ls -d1FL -- "$rempat" 2>/dev/null)"}%%[^/]#(|/)})
 
   compset -P '*/'
   compset -S '/*' || (( ${args[(I)-/]} )) || suf='remote file'
 
+  # display strings for remote files and directories
   remdispf=(${remfiles:#*/})
   remdispd=(${(M)remfiles:#*/})
 
@@ -74,9 +79,9 @@ if zstyle -T ":completion:${curcontext}:files" remote-access; then
   while _tags; do
     while _next_label files expl ${suf:-remote directory}; do
       [[ -n $suf ]] &&
-          compadd "$@" "$expl[@]" -d remdispf ${(q)remdispf%[*=|]} && ret=0
-      compadd ${suf:+-S/} -r "/ \t\n\-" "$@" "$expl[@]" -d remdispd \
-	${(q)remdispd%/} && ret=0
+          compadd "$args[@]" "$expl[@]" -d remdispf -- ${(q)remdispf%[*=|]} && ret=0
+      compadd ${suf:+-S/} -r "/ \t\n\-" "$args[@]" "$expl[@]" -d remdispd \
+	-- ${(q)remdispd%/} && ret=0
     done
     (( ret )) || return 0
   done
diff --git a/Completion/Unix/Type/_signals b/Completion/Unix/Type/_signals
index 104efd4f4..df9a2f339 100644
--- a/Completion/Unix/Type/_signals
+++ b/Completion/Unix/Type/_signals
@@ -8,12 +8,15 @@
 #
 # A `-' or `--' as the first argument is ignored.
 
-local expl last minus pre sigs
+local expl minus pre sigs
+local first last # keep these as strings for -z/-n tests
 
 zparseopts -D -K -E 'p=minus' 'a=last' 's=pre'
 if [[ -z "$last" ]]; then
+  first=2
   last=-3
 else
+  first=1
   last=-1
 fi
 [[ -n "$minus" ]] && minus='-'
@@ -26,20 +29,20 @@ if [[ -z "$minus" ]] ||
   local disp tmp
 
   if zstyle -t ":completion:${curcontext}:signals" prefix-hidden; then
-    tmp=( "${(@)signals[1,last]}" )
+    tmp=( "${(@)signals[first,last]}" )
     disp=(-d tmp)
   else
     disp=()
   fi
 
   if [[ -n "$pre" && $PREFIX = ${minus}S* ]]; then
-    sigs=( "${minus}SIG${(@)^signals[1,last]}" )
-    (( $#disp )) && tmp=( "$tmp[@]" "${(@)signals[1,last]}" )
+    sigs=( "${minus}SIG${(@)^signals[first,last]}" )
+    (( $#disp )) && tmp=( "$tmp[@]" "${(@)signals[first,last]}" )
   else
     sigs=()
   fi
 
   _wanted signals expl signal \
       compadd "$@" "$disp[@]" -M 'm:{a-z}={A-Z}' - \
-              "${minus}${(@)^signals[1,last]}" "$sigs[@]"
+              "${minus}${(@)^signals[first,last]}" "$sigs[@]"
 fi
diff --git a/Completion/Unix/Type/_sys_calls b/Completion/Unix/Type/_sys_calls
new file mode 100644
index 000000000..bd9b34f70
--- /dev/null
+++ b/Completion/Unix/Type/_sys_calls
@@ -0,0 +1,20 @@
+#autoload
+
+# Options:
+#
+# -a    add "all" as an additional match
+# -n    add "none" as an additional match
+
+local expl all none
+local ifile=/usr/include/sys/syscall.h
+local -au syscalls
+
+zparseopts -D -K -E a=all n=none
+
+[[ $OSTYPE = linux* ]] && ifile=/usr/include/bits/syscall.h
+syscalls=( ${${${(M)${(f)"$(<$ifile)"}:#?define[[:blank:]]##SYS_*}#*[[:blank:]]SYS_}%%[[:blank:]]*} ) 2>/dev/null
+[[ -n $all ]] && syscalls+=( all )
+[[ -n $none ]] && syscalls+=( none )
+
+_description syscalls expl 'system call'
+compadd "$@" "$expl[@]" -a syscalls
diff --git a/Completion/Unix/Type/_tilde_files b/Completion/Unix/Type/_tilde_files
index ee6b18088..b1b3b37f0 100644
--- a/Completion/Unix/Type/_tilde_files
+++ b/Completion/Unix/Type/_tilde_files
@@ -30,7 +30,8 @@ case "$PREFIX" in
   ;;
 \~*)
   compset -P '?'
-  _users "$@"
+  local -a expl=( "$@" )
+  _alternative -O expl users:user:_users named-directories:'named directory':'compadd -k nameddirs'
   ;;
 *)
   _files "$@"
diff --git a/Completion/Unix/Type/_zfs_dataset b/Completion/Unix/Type/_zfs_dataset
index 5fa3e9e50..6bef04e45 100644
--- a/Completion/Unix/Type/_zfs_dataset
+++ b/Completion/Unix/Type/_zfs_dataset
@@ -4,7 +4,7 @@ local -a type expl_type_arr rsrc rdst paths_allowed
 local -a typearg datasetlist expl mlist
 local expl_type
 
-# -e takes an argument which is passed as as the "descr" argument to _wanted
+# -e takes an argument which is passed as the "descr" argument to _wanted
 # -p indicates that filesystem paths, not just dataset names, are allowed
 # -r1 indicates that we're completing the source of a rename
 # -r2 indicates that we're completing the destination of a rename
@@ -58,14 +58,14 @@ if [[ ${#rdst} -gt 0 ]]; then
 fi
 
 if [[ -n $type[(r)clone] ]]; then
-	datasetlist=( ${="$(zfs list -H -o name,origin -t filesystem | awk "\$2 != \"-\" {print \$1}")":#no cloned filesystems available} )
+	datasetlist=( ${="$(zfs list -H -o name,origin -t filesystem 2>/dev/null | awk "\$2 != \"-\" {print \$1}")":#no cloned filesystems available} )
 else
-	datasetlist=( ${="$(zfs list -H -o name $typearg)":#no datasets available} )
+	datasetlist=( ${="$(zfs list -H -o name $typearg 2>/dev/null)":#no datasets available} )
 fi
 
 expl_type=${typearg[2,-1]//,/\/}
 if [[ -n $type[(r)mtpt] ]]; then
-	mlist=( ${="$(zfs list -H -o mountpoint $typearg)":#no mountpoints available} )
+	mlist=( ${="$(zfs list -H -o mountpoint $typearg 2>/dev/null)":#no mountpoints available} )
 	datasetlist=( $datasetlist $mlist )
 	expl_type="$expl_type/mountpoint"
 fi