about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Linux/Command/_dkms165
-rw-r--r--Completion/Unix/Command/_chmod4
-rw-r--r--Completion/Unix/Command/_chown6
-rw-r--r--Completion/Unix/Command/_git2
-rw-r--r--Completion/Unix/Command/_rsync10
-rw-r--r--Completion/Unix/Command/_zstd118
-rw-r--r--Completion/Unix/Type/_remote_files20
-rw-r--r--Completion/X/Command/_setxkbmap210
-rw-r--r--Completion/Zsh/Context/_equal10
-rw-r--r--Completion/Zsh/Type/_module_math_func2
-rw-r--r--Completion/compdump6
-rw-r--r--Completion/compinit4
12 files changed, 277 insertions, 280 deletions
diff --git a/Completion/Linux/Command/_dkms b/Completion/Linux/Command/_dkms
deleted file mode 100644
index 2a3c016c5..000000000
--- a/Completion/Linux/Command/_dkms
+++ /dev/null
@@ -1,165 +0,0 @@
-#compdef dkms
-
-local curcontext="$curcontext" ign cmds opts ret=1
-local -a state line expl args subcmds dirs
-local -A opt_args
-
-subcmds=(
-  'add:add a module/version combination to the tree for builds and installs'
-  'remove:remove a module from the tree'
-  'build:compile a module for a kernel'
-  'unbuild:undoes the build of a module'
-  "install:install a build module for it's corresponding kernel"
-  'uninstall:uninstall a module for a kernel'
-  'match:install every module that is installed for a template kernel for another kernel'
-  'mkdriverdisk:create a floppy driver disk image for use when updated drivers are needed to install an OS'
-  'mktarball:tar up files in the DKMS tree for a specific module'
-  'ldtarball:extract a tarball created with mktarball into the DKMS tree'
-  'mkrpm:create an RPM package for a module'
-  'mkdeb:create a debian binary package for a module'
-  'mkdsc:create a debian source package for a module'
-  'mkbmdeb:create a debian package containing just binary modules'
-  'mkkmp:create a Kernel Module Package source RPM for a module'
-  'status:display the current status of modules, versions and kernels within the tree'
-  'autoinstall:try to install the latest revision of all modules that have been installed for other kernel revisions'
-)
-
-args=(
-  '(1)-m[specify module]:module:->modules'
-  '(1)-v[specify module version]:version'
-  '(-q --quiet)'{-q,--quiet}'[suppress output]'
-  '(--all)*'{-a,--arch}'[specify system architecture]:architecture:->architectures'
-  '*--directive=:directive'
-  '--dkmstree=:path:_directories'
-  '--installtree=:path:_directories'
-  '--sourcetree=:path:_directories'
-  '--dkmsframework=:path:_directories'
-  '--force-version-override'
-  '1: : _describe -t commands command subcmds'
-)
-
-cmd=${${${subcmds%%:*}:*words}[1]}
-if [[ -n $cmd ]]; then
-  curcontext="${curcontext%:*}-$cmd:"
-else
-  # exclude sub-commands based on any options specified so far
-  for cmds opts in \
-    '(remove|build|install|uninstall|match|status|mk(^kmp))' 'k' \
-    '(add|remove)' '-rpm_safe_upgrade' \
-    'mk(driverdisk|kmp)' '-spec' \
-    'mk(deb|dsc|bmdeb|rpm)' '-legacy-postinst' \
-    'mk(tarball|rpm|deb|dsc)' '-(source|binary)-only' \
-    '(match|build|mkkmp)' '(k|-no-(prepare|clean)-kernel|-kernelsourcedir)' \
-    '(|un)install' '-no-(depmod|initrd)' \
-    'mkdriverdisk' '([dr]|-distro|-release|-size|-media)' \
-    '(add|build|install|ldtarball)' '-force' \
-    'match' '-templatekernel' \
-    '*tarball' '-archive' \
-    '(match|build|mkkmp)' '(j*|-no-(prepare|clean)-kernel|-kernelsourcedir)' \
-    '(remove|build|install|status|mk(^kmp))' '-all' \
-    'build' '-config'
-  do
-    [[ -n ${(M)words:#-${~opts}*} ]] &&
-      subcmds=( ${(M)subcmds:#${~cmds}:*} )
-  done
-  args+=( '(1 -)'{-V,--version}'[display version information]' )
-  ign='!' # hide some uncommon options but handle their arguments
-fi
-
-case $cmd in
-  remove|build|install|uninstall|mk*|status)
-    args+=( ': :->modules' )
-  ;|
-  |remove|(un|)build|install|uninstall|match|status|mk(^kmp))
-    args+=( '(--all)*-k[specify kernel version]:kernel:->kernels' )
-  ;|
-  |add|remove) args+=( "${ign}--rpm_safe_upgrade" ) ;|
-  |mk(driverdisk|kmp))
-    args+=( "${ign}--spec=:spec file:_files -g '*.spec(-.)'" )
-  ;|
-  |(mk|ld)tarball)
-    args+=( "${ign}--archive=:tarball:_files -g '*.tar(-.)'" )
-  ;|
-  |mk(deb|dsc|bmdeb|rpm))
-    args+=( "${ign}--legacy-postinst=:value [1]:(0 1)" )
-  ;|
-  |mk(tarball|rpm|deb|dsc)) args+=( "${ign}(--source-only --binaries-only)--"{source,binaries}-only ) ;|
-  |match|build|mkkmp)
-    args+=( #TODO: check ignore needed in absence of parameters
-      "${ign}--no-prepare-kernel"
-      "${ign}--no-clean-kernel"
-      '--kernelsourcedir=:directory:_directories'
-      "${ign}-j+[specify maximum number of jobs to use when building]:jobs"
-    )
-  ;|
-  |(|un)install)
-    args+=(
-      "${ign}--no-depmod"
-      "${ign}--no-initrd"
-    )
-  ;|
-  |add)
-    args+=(
-      '-c[specify location of dkms.conf file]:location:_files'
-    )
-  ;|
-  |remove|(un|)build|install|status|mk(^kmp))
-    args+=( '(-a --arch -k)--all[specify all relevant kernels/arches]' )
-  ;|
-  |build)
-    args+=( "${ign}--config=:kernel config file:_files" )
-  ;|
-  |add|build|install|ldtarball)
-    args+=( '--force[force overwriting of extant files]' )
-  ;|
-  |match)
-    args+=( "${ign}--templatekernel=:kernel:->kernels" )
-  ;|
-  |mkdriverdisk)
-    args+=(
-      "${ign}(-d --distro)"{-d,--distro=}':distribution:(redhat'{,1,2,3}' suse unitedlinux)'
-      "${ign}(-r --release)"{-r,--release=}':release'
-      "${ign}--size=:size (kb) [1440]"
-      "${ign}--media=:media type [floppy]:(floppy iso tar)"
-    )
-  ;|
-  add)
-    args+=(
-      '3:path:_directories'
-      '4:tarball:_files -g "*.tar(-.)"'
-    )
-  ;;
-  install)
-    args+=(
-      '3:rpm file:_files -g "*.rpm(-.)"'
-    )
-  ;;
-esac
-
-_arguments -C $args && ret=0
-
-case $state in
-  modules)
-    dirs=( ${(e)opt_args[--dkmstree]:-/var/lib/dkms}/*/*(/) )
-    dirs=( ${${(M)dirs%/*/*}#/} )
-    _description modules expl module
-    _multi_parts -i "$expl[@]" / dirs && ret=0
-  ;;
-  kernels)
-    if compset -P 1 '*/'; then
-      _description architectures expl architecture
-      compadd "$expl[@]" /lib/modules/$IPREFIX/build/arch/*(/:t) && ret=0
-    else
-      compset -S '/*'
-      dirs=( /lib/modules/*(/:t) )
-      _description -V kernels expl kernel
-      compadd "$expl[@]" -r "/ \t\n\-" ${(on)dirs} && ret=0
-    fi
-  ;;
-  architectures)
-    _description architectures expl architecture
-    compadd "$expl[@]" /lib/modules/$(uname -r)/build/arch/*(/:t) && ret=0
-  ;;
-esac
-
-return ret
diff --git a/Completion/Unix/Command/_chmod b/Completion/Unix/Command/_chmod
index 42e3fa63b..693f348dc 100644
--- a/Completion/Unix/Command/_chmod
+++ b/Completion/Unix/Command/_chmod
@@ -67,13 +67,13 @@ case "$variant" in
     ;;
 esac
 
-_arguments -C -s -S $aopts "$args[@]" && ret=0
+_arguments -C -s -S -0 $aopts "$args[@]" && ret=0
 
 case "$state" in
   files)
     if [[ -n $opt_args[--reference] ]]; then
       zmodload -F zsh/stat b:zstat 2>/dev/null
-      typeset -i8 ref=$(zstat +mode $opt_args[--reference])
+      typeset -i8 ref=$(zstat +mode $opt_args[--reference]:Q)
       _wanted files expl file _files -g "*(-.^f${ref#??})" && ret=0
     elif [[ $line[1] = [0-7]## ]]; then
       _wanted files expl file _files -g "*(-.^f$line[1])" && ret=0
diff --git a/Completion/Unix/Command/_chown b/Completion/Unix/Command/_chown
index 4362d6e75..bcc6aec2f 100644
--- a/Completion/Unix/Command/_chown
+++ b/Completion/Unix/Command/_chown
@@ -71,7 +71,7 @@ case "$variant" in
 esac
 
 (( $+words[(r)--reference*] )) || args+=( '(--reference)1: :->owner' )
-_arguments -C -s -S $aopts "$args[@]" '*: :->files' && ret=0
+_arguments -C -s -S -0 $aopts "$args[@]" '*: :->files' && ret=0
 
 case $state in
   owner)
@@ -95,8 +95,8 @@ case $state in
     (( $+opt_args[-h] || $+opt_args[--no-dereference] )) || deref="-"
     if (( $+opt_args[--reference] )); then
       zmodload -F zsh/stat b:zstat 2>/dev/null
-      usr=$(zstat +uid $opt_args[--reference])
-      grp=$(zstat +gid $opt_args[--reference])
+      usr=$(zstat +uid $opt_args[--reference]:Q)
+      grp=$(zstat +gid $opt_args[--reference]:Q)
       _wanted files expl file _files -g "*($deref^u$usr,$deref^g$grp)" && ret=0
       return ret
     fi
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 22b945e38..86b8a7455 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -278,6 +278,7 @@ _git-bisect () {
           _arguments -C -s \
             $log_options \
             $revision_options && ret=0
+          ;;
         (*)
           _nothing
           ;;
@@ -664,7 +665,6 @@ _git-clone () {
     '(--single-branch)--no-single-branch[clone history leading up to each branch]' \
     "--no-tags[don't clone any tags and make later fetches not follow them]" \
     '--shallow-submodules[any cloned submodules will be shallow]' \
-    '--recursive[initialize all contained submodules]' \
     '(--recursive --recurse-submodules)'{--recursive,--recurse-submodules}'=-[initialize submodules in the clone]::file:__git_files' \
     '--separate-git-dir[place .git dir outside worktree]:path to .git dir:_path_files -/' \
     \*--server-option='[send specified string to the server when using protocol version 2]:option' \
diff --git a/Completion/Unix/Command/_rsync b/Completion/Unix/Command/_rsync
index c65266dbd..81d25a3f4 100644
--- a/Completion/Unix/Command/_rsync
+++ b/Completion/Unix/Command/_rsync
@@ -60,7 +60,14 @@ elif compset -P 1 '*::' || compset -P 1 'rsync://*/'; then
 elif compset -P 'rsync://'; then
   _rsync_user_or_host / "$@"
 elif compset -P 1 '*:'; then
-  _remote_files -- ssh
+  if [[ -v opt_args[(i)client---old-args] || $RSYNC_OLD_ARGS = 1 ]]; then
+    _remote_files -- ssh
+  else
+    # the 3.2.4+ way that rsync handles filenames does not protect *, ? and []
+    # so those characters still need to be escaped to prevent being treated as
+    # a pattern in the remote shell.
+    _remote_files -Q '[][*?]' -- ssh
+  fi
 else
   _rsync_user_or_host : "$@"
 fi
@@ -236,6 +243,7 @@ _rsync() {
     '*--include=[do not exclude files matching pattern]:pattern' \
     '--files-from=[read list of source-file names from specified file]:file:_files' \
     '(-0 --from0)'{-0,--from0}'[all *-from file lists are delimited by nulls]' \
+    '--old-args[disable the modern arg-protection idiom]' \
     '(-s --secluded-args)'{-s,--secluded-args}'[use the protocol to safely send arguments]' \
     "--trust-sender[trust the remote sender's file list]" \
     '--copy-as=[specify user & optional group for the copy]:user:_rsync_users_groups' \
diff --git a/Completion/Unix/Command/_zstd b/Completion/Unix/Command/_zstd
new file mode 100644
index 000000000..92c4a8e41
--- /dev/null
+++ b/Completion/Unix/Command/_zstd
@@ -0,0 +1,118 @@
+#compdef zstd zstdmt unzstd zstdcat -redirect-,<,unzstd=unzstd -redirect-,>,zstd=unzstd -redirect-,<,zstd=zstd
+
+local ign
+local -a levels implied noopt args blksize
+
+(( $#words > 2 )) && ign='!'
+
+[[ $compstate[context] = redirect ]] && noopt=( -- )
+case "$service" in
+  zstdmt) implied=( -T0 ) ;;
+  unzstd) (( $words[(I)(-z|--compress)] )) || implied=( -d ) ;;
+  zstdcat)
+    implied=( -dcf )
+    (( $words[(I)(-z|--compress)] )) && implied=( -cf )
+  ;;
+esac
+words[1]+=( $implied $noopt )
+(( CURRENT += $#implied + $#noopt ))
+
+if (( $words[(r)--ultra] )); then
+  levels=( -{20..22} )
+else
+  levels=( -{1..19} )
+fi
+
+blksize=(
+  '(M -B --block-size)'{-B+,--block-size=-}'[cut file into independent blocks of specified size]: :_numbers -d "no block" -u bytes size KiB MiB'
+)
+if (( $words[(r)--train] )); then
+  args=( $blksize
+    '(M)--train-cover=-[use the cover algorithm with optional arguments]::parameter'
+    '(M)--train-fastcover=-[use the fast cover algorithm with optional arguments]::parameter'
+    '(M)--train-legacy=-[use the legacy algorithm with selectivity]::selectivity [9]'
+    '-o[specify dictionary name]:dictionary name [dictionary]'
+    '(M)--maxdict=[limit dictionary to specified size]: :_numbers -u bytes -d 112640 size KiB MiB'
+    '(M)--dictID=[force dictionary ID to specified value]:value [random]'
+    '*:files:_files'
+  )
+elif (( $words[(I)-b[0-9]#] )); then
+  args=( $blksize
+    '(M)-e-[test all compression levels successively from -b level]: :_numbers -d 3 -l 1 -m 19 level'
+    '(M)-i-[specify minimum evaluation time]: :time (seconds) [3]'
+    '(M -B --block-size)'{-B+,--block-size=-}'[cut file into independent blocks of specified size]: :_numbers -d "no block" -u bytes size KiB MiB' \
+    '(M)-S[output one benchmark result per input file]'
+    '(M)--priority=-[set process priority]:priority:(rt)'
+    '*:files:_files -g "^*.(|t)zst(-.)"'
+  )
+elif (( $words[(I)(-d|--decompress|--uncompress|-l|--list|-t|--test)] )); then
+  args=(
+    '(M --sparse -c --stdout)--no-sparse[sparse mode]'
+    '(M --no-sparse -o)--sparse[sparse mode]'
+    '(--sparse)-o[specify output file]:file:_files -g "^*.(|t)zst(-.)"'
+    "(M)--no-check[ignore checksums in compressed frame]"
+    '!(M --no-check)'{-C,--check}
+    '*:files:_files -g "*.(|t)zst(-.)"'
+  )
+else
+  args=(
+    "(M)--no-check[don't add/verify XXH64 integrity checksums]"
+    '!(M --no-check)'{-C,--check}
+    "(M)--no-content-size[don't include original file size in header]"
+    '!(M --no-content-size)--content-size'
+    "(M)--no-progress[don't show the progress bar but keep other messages]"
+    '!(M --no-progress)--progress'
+    "(M --adapt --fast --ultra ${levels[*]})"$^levels
+    '(M --fast)--ultra[enable levels beyond 19, up to 22]'
+    '--long=-[enable long distance matching with given window log]:window log [27]'
+    "(M --adapt --ultra ${levels[*]})--fast=-[switch to very fast compression levels]:level [1]"
+    "(M --fast ${levels[*]})--adapt=-[dynamically adapt compression level to I/O conditions]: :_values -s , 'range'
+      'min\:level' '(min)max\:level'"
+    '(M)'--{no-,}row-match-finder'[force usage of fast row-based matchfinder for greedy, lazy, and lazy2 strategies]'
+    "(-D)--patch-from=[specify the file to be used as a reference point for zstd's diff engine]: :_files"
+    '(--single-thread -T --threads)'{-T-,--threads=}'[spawn specified number of threads]:threads [1]'
+    '(M -B --block-size)'{-B-,--block-size=-}'[select block size of each job]: :_numbers -u bytes -d 0\:automatic "block size" KiB MiB'
+    '(M -T --threads --rsyncable)--single-thread[use a single thread for both I/O and compression (result different than -T1)]'
+    '(M)--auto-threads=[use either physical cores or logical cores as default when specifying -T0]:cores [physical]:(physical logcial)'
+    '(M --single-thread)--rsyncable[compress using a rsync-friendly method]'
+    '(M)--exclude-compressed[only compress files that are not already compressed]'
+    '(M --size-hint)--stream-size=-[specify exact size of streaming input from stdin]:  :_numbers -u bytes size KiB MiB'
+    '(M --stream-size)--size-hint=[indicate size of streamed input to optimize compression parameters]: :_numbers -u bytes size KiB MiB'
+    '(M)--target-compressed-block-size=[generate compressed block of approximately targeted size]: :_numbers -u bytes limit KiB MiB'
+    "(M)--no-dictID[don't write dictID into header (dictionary compression only)]"
+    '(M --no-compress-literals --compress-literals)'--{no-,}compress-literals'[force (un)compressed literals]'
+    '(M)--show-default-cparams[show compression parameters for each file]'
+    '(--test)-o[specify output file]:file:_files -g "*.(|t)zst(-.)"'
+    '--format=-[compress files to specified format]:format [zstd]:(zstd gzip xz lzma lz4)'
+    '--zstd=[specify advanced compression options]: :_values -s , "option"
+      strategy\:strategy "windowLog\:bits (10-31)" "hashLog\:bits (6-30)"
+      "chainLog\:bits (6-31)" "searchLog\:searches" "minMatch\:length"
+      "targetLength\:length" "overlapLog\:size" "ldmHashLog\:size"
+      "ldmMinMatch\:length" "ldmBucketSizeLog\:size" "ldmHashRateLog\:frequency"'
+    '*:files:_files -g "^*.(|t)zst(-.)"'
+  )
+fi
+
+_arguments -s -S : $args \
+  "$ign(- *)"{-h,--help}'[display help message]' \
+  "$ign(- *)"{-V,--version}'[display version number]' \
+  '(--patch-from)-D[use specified dictionary for compression or decompression]:dictionary' \
+  '(-f --force)'{-f,--force}'[force overwrite]' \
+  '--rm[remove source file(s) after successful compression or decompression]' \
+  '!(-k --keep --rm)'{-k,--keep} \
+  '(-c --stdout --no-sparse --test)'{-c,--stdout}'[write on standard output]' \
+  '(-M --memory)'{-M-,--memory=}'[set a memory usage limit]: :_numbers -u bytes limit KiB MiB' \
+  \*{-v,--verbose}'[display more information]' \
+  \*{-q,--quiet}'[suppress messages]' \
+  '-r[operate recursively on directories]' \
+  '--filelist=[read list of files to operate upon from file]: :_files' \
+  '--output-dir-flat=[store processed files in directory]: :_directories' \
+  '--output-dir-mirror=[store processed files in directory respecting original structure]: :_directories' \
+  '--trace=[log tracing information to file]: :_files' \
+  + '(M)' \
+  \!{-z,--compress,--uncompress} \
+  '(-B --block-size)'{-d,--decompress}'[decompress]' \
+  '(-B --block-size)'{-l,--list}'[print information about zstd compressed files]' \
+  '(-c --stdout -o --rm -B --block-size)'{-t,--test}'[test compressed file integrity]' \
+  '(-c --stdout -D -k --keep --rm)--train=[create a dictionary from a training set of files]' \
+  '(-c --stdout -k --keep --rm)-b-[benchmark file(s), using specified compression level]:: :_numbers -d 3 -l 1 -m 19 level'
diff --git a/Completion/Unix/Type/_remote_files b/Completion/Unix/Type/_remote_files
index 93e1b7f43..15c20e5c1 100644
--- a/Completion/Unix/Type/_remote_files
+++ b/Completion/Unix/Type/_remote_files
@@ -11,6 +11,8 @@
 # - -g: specify a pattern to match against files
 #       p, = and * glob qualifiers supported
 # - -h: specify the remote host, default is ${IPREFIX%:}
+# - -Q: specify a pattern of characters to escape in the returned filenames,
+#       instead of shell metacharacters that ${(q)name} does
 # - -W: specify the parent directory to list files from,
 #       default is the home directory
 #
@@ -31,14 +33,14 @@
 
 
 # There should be coloring based on all the different ls -F classifiers.
-local expl rempat remfiles remdispf remdispd args cmd suf ret=1
+local expl rempat remfiles remdispf{,q} remdispd{,q} args cmd suf ret=1
 local -a args cmd_args
-local glob host dir dirprefix
+local glob host dir esc dirprefix
 
 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 W:=dir
+  zparseopts -D -E -a args / g:=glob h:=host W:=dir Q:=esc
   (( $#host)) && shift host || host="${IPREFIX%:}"
 
   args=( ${argv[1,(i)--]} )
@@ -85,6 +87,14 @@ if zstyle -T ":completion:${curcontext}:files" remote-access; then
     remdispf=( ${(M)remdispf:#${~glob[2]}} )
   fi
 
+  if (( $#esc )); then
+    remdispfq=(${${remdispf%[*=|]}//(#b)(${~esc[2]})/\\$match[1]})
+    remdispdq=(${${remdispd%/}//(#b)(${~esc[2]})/\\$match[1]})
+  else
+    remdispfq=(${(q)remdispf%[*=|]})
+    remdispdq=(${(q)remdispd%/})
+  fi
+
   local -a autoremove
   [[ -o autoremoveslash ]] && autoremove=(-r "/ \t\n\-")
 
@@ -92,9 +102,9 @@ if zstyle -T ":completion:${curcontext}:files" remote-access; then
   while _tags; do
     while _next_label remote-files expl ${suf:-remote directory}; do
       [[ -n $suf ]] &&
-          compadd "$args[@]" "$expl[@]" -d remdispf -- ${(q)remdispf%[*=|]} && ret=0
+        compadd "$args[@]" "$expl[@]" -d remdispf -- $remdispfq && ret=0
       compadd ${suf:+-S/} $autoremove "$args[@]" "$expl[@]" -d remdispd \
-	-- ${(q)remdispd%/} && ret=0
+        -- $remdispdq && ret=0
     done
     (( ret )) || return 0
   done
diff --git a/Completion/X/Command/_setxkbmap b/Completion/X/Command/_setxkbmap
index 882a6f939..0850d5419 100644
--- a/Completion/X/Command/_setxkbmap
+++ b/Completion/X/Command/_setxkbmap
@@ -1,101 +1,119 @@
 #compdef setxkbmap
 
-# TODO:
-# model, option, symbols and types suggestions
-# take -layout and -variant into account
-
-_setxkbmap() {
-    emulate -L zsh
-    setopt extendedglob
-
-    # xkb files may be in different places depending on system
-    local dir sourcedir fullname
-    local -a searchdirs=(${XDG_DATA_HOME:-~/.local/share} ${(s.:.)XDG_DATA_DIRS:-/usr/lib:/usr/share:/usr/local/lib:/usr/local/share})
-    for dir in $searchdirs; do
-        fullname="$dir/X11/xkb"
-        if [ -d $fullname ] ; then
-           sourcedir=$fullname
-           break
-        fi
-    done
-    [ -d $sourcedir ] || return 1
-
-    local -a arguments
-
-    arguments=(
-        '-compat[compatibility map]:compatibility:_setxkbmap_compat'
-        '-config[configuration file]:configuration:_files'
-        '-display[display]:display:_x_display'
-        '-geometry[geometry component]:geometry:_setxkbmap_geometry'
-        '-model[model name]:model:'
-        '-option[xkb option]:option:'
-        '(-)'-print'[print component names]'
-        '-rules[rules file]:rules:_files'
-        '-symbols[symbols components]:symbols:'
-        '(-)'{-help,-h}'[display help message]'
-        '-synch[force synchronization]'
-        '-types[types components]:types:'
-        '(-verbose -v)'{-verbose,-v}'[set verbosity level]:verbosity:(0 1 2 3 4 5 6 7 8 9)'
-        '*::keyboard:_setxkbmap_dispatcher'
+local curcontext="$curcontext" sourcedir layout ret=1
+local -a state state_descr line expl matches suf
+local -A opt_args
+
+_arguments -C \
+  '(-)'{-\?,-help}'[display help message]' \
+  '-compat[compatibility map]:compatibility:->compatmaps' \
+  '-config[configuration file]:configuration:_files' \
+  '-device[specify numeric id of the input device]:device:->devices' \
+  '-display[display]:display:_x_display' \
+  '-geometry[geometry component]:geometry:->geometries' \
+  '*-I+[add a directory to be searched for layout or rules files]: :_directories' \
+  '-keycodes[specify keycodes component name]:name' \
+  '-keymap[specify keymap to load]:keymap' \
+  '-layout[specify layout used to choose component names]:layout:->layouts' \
+  '-model[specify model used to choose component names]:model:->models' \
+  '*-option[add an xkb option]:option:->options' \
+  '(-)'-print'[print a complete xkb_keymap description]' \
+  '-query[print the current layout settings]' \
+  '-rules[specify rules file to use]:rules:->rules' \
+  '-symbols[specify symbols component name]:symbol' \
+  '-synch[force synchronization]' \
+  '-types[types components]:type:->types' \
+  '(-verbose -v)'{-verbose,-v}'[set verbosity level]:verbosity:(0 1 2 3 4 5 6 7 8 9)' \
+  '(-)-version[display version information]' \
+  '-variant[specify layout variant used to choose component name]:variant:->variants' \
+  '1:layout:->layouts' \
+  '2:variant:->variants' \
+  '*:option:->options' && ret=0
+
+if [[ -n $state ]]; then
+  local open='(' close=')'
+  compquote open close
+
+  layout=${opt_args[-layout]:-$line[1]}
+  if [[ $state = layouts ]]; then
+    compset -P '*,'
+    if compset -P 1 '*\('; then
+      layout="${${IPREFIX%$open}##*,}"
+      state=variants state_descr=variant
+      suf=( -S"$close$compstate[quote] " )
+    else
+      suf=( -S$open -r ",('\" \t\n\-" )
+    fi
+  fi
+
+  _description $state expl $state_descr
+  if (( $+commands[localectl] )); then
+    case $state in
+      layouts) matches=( $(_call_program layouts localectl list-x11-keymap-layouts) ) ;;
+      models) matches=( $(_call_program layouts localectl list-x11-keymap-models) ) ;;
+      options) matches=( $(_call_program layouts localectl list-x11-keymap-options) ) ;;
+      variants) matches=( $(_call_program layouts localectl list-x11-keymap-variants $layout) ) ;;
+    esac
+  fi
+  if (( ! $#matches )); then
+    sourcedir=$(pkg-config xkeyboard-config --variable=xkb_base 2>/dev/null)
+    [[ -z $sourcedir ]] && sourcedir=(
+      ${XDG_DATA_HOME:-~/.local/share}/X11/xkb(N/)
+      ${(s.:.)XDG_DATA_DIRS:-/usr/lib:/usr/share:/usr/local/lib:/usr/local/share}/X11/xkb(N/)
     )
-    _arguments $arguments
-}
-
-_setxkbmap_dispatcher () {
-
-    case $CURRENT in
-        1)
-            _setxkbmap_layout
-        ;;
-        2)
-            _setxkbmap_variant "$words[1]"
-        ;;
+    (( $#sourcedir )) && case $state in
+      layouts) matches=( $sourcedir/symbols/**/^README(.Ne."REPLY=\${REPLY#*/symbols/}".) ) ;;
+      compatmaps) matches=( $sourcedir/compat/^README(.:t) ) ;;
+      models) matches=( $(sed -n '/modelList/,/\/modelList/ s, *<name>\(.*\)</name>,\1,p' $sourcedir/rules/(evdev|base).xml(.N[1])) ) ;;
+      options) matches=( $(sed -n '/optionList/,/\/optionList/ s, *<name>\(.*\)</name>,\1,p' $sourcedir/rules/(evdev|base).xml(.N[1])) ) ;;
+      rules) matches=( $sourcedir/rules/*.lst(-.:t:r) ) ;;
+      types) matches=( $sourcedir/types/^README(.:t) ) ;;
+      variants)
+        [[ -n $layout && -r $sourcedir/symbols/$layout ]] && matches=(
+            ${${${(M)${(f)"$(<$sourcedir/symbols/$layout)"}:#*xkb_symbols*\"([^\"])##\"*}##*xkb_symbols([^\"])##\"}%%\"*}
+        )
+      ;;
+      geometries)
+        if compset -P 1 '*\('; then
+          layout="${${IPREFIX%$open}##*,}"
+          suf=( -S"$close$compstate[quote] " )
+          matches=( $(sed -n -e '/xkb_geometry/ s/[^"]*"\([^"]*\).*/\1/p' $sourcedir/geometry/${IPREFIX%%[\\(]#}(.N)) )
+        else
+          suf=( -S$open -r "('\" \t\n\-" )
+          matches=( $sourcedir/geometry/^README(.:t) )
+        fi
+      ;;
+      devices)
+        # copied from _xinput
+        if (( $+commands[xinput] )); then
+          local -a ids names disp
+          local out
+          ids=( ${${(f)"$(_call_program input-devices xinput list --id-only)"}#? } )
+          names=( ${${(f)"$(_call_program input-devices xinput list --name-only)"}#? } )
+          disp=( ${(f)"$(_call_program input-devices xinput list --short)"} )
+
+          if [[ $PREFIX$SUFFIX = [^-]*[^0-9]* ]]; then
+            # match based on the names but insert IDs
+            compadd "$expl[@]" -M 'b:=* m:{[:lower:]}={[:upper:]}' -D ids -D disp -a names
+            compadd "$expl[@]" -U -ld disp -a ids && ret=0
+
+            zstyle -s ":completion:${curcontext}:input-devices" insert-ids out || out=menu
+            case "$out" in
+              menu)   compstate[insert]=menu ;;
+              single) [[ $#ids -ne 1 && $compstate[insert] != menu ]] &&
+                          compstate[insert]= ;;
+              *)      [[ ${#:-$PREFIX$SUFFIX} -gt ${#compstate[unambiguous]} ]] &&
+                          compstate[insert]=menu ;;
+            esac
+          else
+            compadd "$expl[@]" -M 'B:0=' -o nosort -ld disp -a ids && ret=0
+          fi
+        fi
+        return ret
+      ;;
     esac
-}
-
-_setxkbmap_files () {
-    local dir="$1"
-    local label="$2"
-
-    local -a fullpath shortpath expl
-
-    fullpath=($sourcedir/$dir/**/*~*README(.))
-    shortpath=(${fullpath#$sourcedir\/$dir\/})
-
-    _wanted layout expl $label compadd -a - shortpath
-
-}
-
-(( $+functions[_setxkbmap_compat] )) ||
-_setxkbmap_compat() {
-    _setxkbmap_files "compat" "compatibility"
-}
-
-(( $+functions[_setxkbmap_layout] )) ||
-_setxkbmap_layout () {
-    _setxkbmap_files "symbols" "layout"
-}
-
-(( $+functions[_setxkbmap_geometry] )) ||
-_setxkbmap_geometry () {
-    _setxkbmap_files "geometry" "geometry"
-}
-
-(( $+functions[_setxkbmap_variant] )) ||
-_setxkbmap_variant () {
-    local file=$sourcedir/symbols/${1}
-    local -a variants lines expl
-
-    if [ ! -f $file ]; then
-        _message "no such layout: ${1}"
-        return 1
-    fi
-
-    lines=("${(f)$(< ${file})}")
-    variants=(${${${(M)lines:#*xkb_symbols*\"([^\"])##\"*}##*xkb_symbols([^\"])##\"}%%\"*})
-    
-    _wanted variant expl 'variant' compadd -a variants
-
-}
+  fi
+  compadd "$expl[@]" $suf -a matches && ret=0
+fi
 
-_setxkbmap "$@"
+return ret
diff --git a/Completion/Zsh/Context/_equal b/Completion/Zsh/Context/_equal
index 58a415d56..5cdeea264 100644
--- a/Completion/Zsh/Context/_equal
+++ b/Completion/Zsh/Context/_equal
@@ -1,3 +1,11 @@
 #compdef -equal-
 
-_path_commands
+local -a match mbegin mend
+
+if _have_glob_qual $PREFIX; then
+  compset -p ${#match[1]}
+  compset -S '[^\)\|\~]#(|\))'
+  _globquals
+else
+  _path_commands
+fi
diff --git a/Completion/Zsh/Type/_module_math_func b/Completion/Zsh/Type/_module_math_func
index 5044bdf4c..e92b78b71 100644
--- a/Completion/Zsh/Type/_module_math_func
+++ b/Completion/Zsh/Type/_module_math_func
@@ -2,7 +2,7 @@
 
 local mod
 local -a funcs alts
-local -a modules=( example mathfunc system )
+local -a modules=( example mathfunc system random )
 
 for mod in $modules; do
   funcs=( ${${${(f)"$(zmodload -Fl zsh/$mod 2>/dev/null)"}:#^+f:*}##+f:} )
diff --git a/Completion/compdump b/Completion/compdump
index 5af5174f1..6daf92f9f 100644
--- a/Completion/compdump
+++ b/Completion/compdump
@@ -113,7 +113,7 @@ integer _i=5
 print -n autoload -Uz >& $_d_fd
 while (( $#_d_als )); do
   if (( ! $+_compautos[$_d_als[1]] )); then
-    print -rn " ${(q-)_d_als[1]}"
+    print -n " $_d_als[1]"
     if (( ! --_i && $#_d_als > 1 )); then
       _i=5
       print -n ' \\\n           '
@@ -126,13 +126,13 @@ print >& $_d_fd
 
 local _c
 for _c in "${(ok@)_compautos}"; do
-  print -r "autoload -Uz ${(q-)_compautos[$_c]} $_c" >& $_d_fd
+  print "autoload -Uz $_compautos[$_c] $_c" >& $_d_fd
 done
 
 print >& $_d_fd
 
 print "typeset -gUa _comp_assocs" >& $_d_fd
-print -r "_comp_assocs=( ${(qq)_comp_assocs} )" >& $_d_fd
+print "_comp_assocs=( ${(qq)_comp_assocs} )" >& $_d_fd
 exec {_d_fd}>&-
 
 mv -f $_d_file ${_d_file%.$HOST.$$}
diff --git a/Completion/compinit b/Completion/compinit
index 51e9d88b8..5cb527fac 100644
--- a/Completion/compinit
+++ b/Completion/compinit
@@ -301,7 +301,7 @@ compdef() {
     if [[ -z "$eval" ]] && [[ "$1" = *\=* ]]; then
       while (( $# )); do
         if [[ "$1" = *\=* ]]; then
-	  cmd="${(q)${1%%\=*}}"
+	  cmd="${1%%\=*}"
 	  svc="${1#*\=}"
           func="$_comps[${_services[(r)$svc]:-$svc}]"
           [[ -n ${_services[$svc]} ]] &&
@@ -412,7 +412,7 @@ compdef() {
 	      svc=
             fi
             if [[ -z "$new" || -z "${_comps[$1]}" ]]; then
-              _comps[$cmd]="${(q)func}"
+              _comps[$cmd]="$func"
 	      [[ -n "$svc" ]] && _services[$cmd]="${1#*\=}"
 	    fi
             ;;