about summary refs log tree commit diff
path: root/Completion/User
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-04-15 18:18:42 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-04-15 18:18:42 +0000
commit7a0415cfd70a02b2280d27556c6c54cef1c86e1a (patch)
tree37a88a1c4611ee37f2a3209873fc9a34a2624587 /Completion/User
parent904b939cbd81a542303da2c58288b95b153106f5 (diff)
downloadzsh-7a0415cfd70a02b2280d27556c6c54cef1c86e1a.tar.gz
zsh-7a0415cfd70a02b2280d27556c6c54cef1c86e1a.tar.xz
zsh-7a0415cfd70a02b2280d27556c6c54cef1c86e1a.zip
zsh-3.1.5-pws-11 zsh-3.1.5-pws-11
Diffstat (limited to 'Completion/User')
-rw-r--r--Completion/User/_a2ps8
-rw-r--r--Completion/User/_configure29
-rw-r--r--Completion/User/_dd4
-rw-r--r--Completion/User/_find24
-rw-r--r--Completion/User/_hosts2
-rw-r--r--Completion/User/_make2
-rw-r--r--Completion/User/_man6
-rw-r--r--Completion/User/_mh36
-rw-r--r--Completion/User/_rcs8
-rw-r--r--Completion/User/_rlogin10
-rw-r--r--Completion/User/_stty6
-rw-r--r--Completion/User/_tar68
-rw-r--r--Completion/User/_x_options2
13 files changed, 146 insertions, 59 deletions
diff --git a/Completion/User/_a2ps b/Completion/User/_a2ps
index 9aa9d3d99..600b58872 100644
--- a/Completion/User/_a2ps
+++ b/Completion/User/_a2ps
@@ -1,22 +1,22 @@
 #defcomp a2ps
 
-if [[ -prefix -- ]]; then
+if [[ "$PREFIX[1,2]" = -- ]]; then
   _comp_parts '(--borders --compact --truncate-lines --interpret
                 --print-anyway --delegate)' '=' '(yes no)'
   _comp_parts '(--major)' '=' '(rows columns)'
   _comp_parts '(--end-of-line)' '=' '(r n nr rn any)'
 
-  complist -S= -k '(--medium --columns --rows --line-numbers
+  compgen -S= -k '(--medium --columns --rows --line-numbers
                     --font-size --lines-per-page --chars-per-line
  		    --tabsize --non-printable-format --encoding
 		    --title --stdin --prologue --highlight-level
 		    --strip-level --output --version-control --suffix
 		    --printer --copies --sides --page-prefeed
 		    --no-page-prefeed)'
-  complist -qS= -k '(--margin --header --underlay --left-title
+  compgen -qS= -k '(--margin --header --underlay --left-title
                      --right-title --left-footer --footer --right-footer
 		     --pages --pretty-print)'
-  complist -k '(--landscape --portrait --catman --no-header)'
+  compgen -k '(--landscape --portrait --catman --no-header)'
 else
   _files -F fignore -g "*~*.ps"
 fi
diff --git a/Completion/User/_configure b/Completion/User/_configure
index de8d5fba5..050701fac 100644
--- a/Completion/User/_configure
+++ b/Completion/User/_configure
@@ -1,12 +1,35 @@
 #defcomp configure
 
+setopt localoptions extendedglob
+
 if [[ $PREFIX = *=* ]]; then
   # Complete filenames after e.g. --prefix=
   IPREFIX=${PREFIX%%=*}=
   PREFIX=${PREFIX#*=}
-  complist -f
+  compgen -f
 else
   # Generate a list of options from configure --help
-  complist -s '$($COMMAND --help |
-  sed -n -e '\''s/^ *\(--[-a-z0-9]*\)[    =,].*$/\1/p'\'')'
+  local -a pars
+  local i
+  pars=($($words[1] --help | awk '$1 ~ /--[a-z]*.*/ {print $1}'))
+  for i in $pars
+  do
+    case $i in
+      (--(((en|dis)able-FEATURE)|(with(out|)-PACKAGE))*)
+        : Skip standard help output
+      ;;
+      --enable)
+        : Skip standard help output
+      ;;
+      --*\[=* )
+        compadd -M 'r:|-=* r:|=*' -q -S = -- ${i%%\[=*}
+      ;;
+      --*=* )
+        compadd -M 'r:|-=* r:|=*' -S = -- ${i%%=*}
+      ;;
+      * )
+        compadd -M 'r:|-=* r:|=*' -- $i
+      ;;
+    esac
+  done
 fi
diff --git a/Completion/User/_dd b/Completion/User/_dd
index 2458541ea..86a47b1ab 100644
--- a/Completion/User/_dd
+++ b/Completion/User/_dd
@@ -4,10 +4,10 @@ if [[ -iprefix conv= ]]; then
   # If there's a comma present, ignore up to the last one.  The
   # test alone will have that effect.
   [[ -string , ]]
-  complist -S, -q \
+  compgen -S, -q \
   -k '(ascii ebcdic ibm block unblock lcase ucase swab noerror sync)'
 elif [[ -iprefix 'if=' || -iprefix 'of=' ]]; then
   _files
 else
-  complist -S '=' -k '(if of ibs obs bs cbs skip files seek count conv)'
+  compgen -S '=' -k '(if of ibs obs bs cbs skip files seek count conv)'
 fi
diff --git a/Completion/User/_find b/Completion/User/_find
index ca4f79908..8fcdafb83 100644
--- a/Completion/User/_find
+++ b/Completion/User/_find
@@ -1,21 +1,23 @@
 #defcomp find
 
+local prev="$words[CURRENT-1]"
+
 if [[ -mbetween -(ok|exec) \\\; ]]; then
-  _normal "$@"
+  _normal
 elif [[ -iprefix - ]]; then
-  complist -s 'daystart {max,min,}depth follow noleaf version xdev \
+  compgen -s 'daystart {max,min,}depth follow noleaf version xdev \
     {a,c,}newer {a,c,m}{min,time} empty false {fs,x,}type gid inum links \
     {i,}{l,}name {no,}{user,group} path perm regex size true uid used \
     exec {f,}print{f,0,} ok prune ls'
-elif [[ -position 1 ]]; then
-  complist -g '. ..'
+elif [[ -position 2 ]]; then
+  compgen -g '. ..'
   _files -g '(-/)'
-elif [[ -mcurrent -1 -((a|c|)newer|fprint(|0|f)) ]]; then
+elif [[ "$prev" = -((a|c|)newer|fprint(|0|f)) ]]; then
   _files
-elif [[ -current -1 -fstype ]]; then
-  complist -k '(ufs 4.2 4.3 nfs tmp mfs S51K S52K)'
-elif [[ -current -1 -group ]]; then
-  complist -k groups
-elif [[ -current -1 -user ]]; then
-  complist -u
+elif [[ "$prev" = -fstype ]]; then
+  compgen -k '(ufs 4.2 4.3 nfs tmp mfs S51K S52K)'
+elif [[ "$prev" = -group ]]; then
+  compgen -k groups
+elif [[ "$prev" = -user ]]; then
+  compgen -u
 fi
diff --git a/Completion/User/_hosts b/Completion/User/_hosts
index 3acc327ac..eb418c5b3 100644
--- a/Completion/User/_hosts
+++ b/Completion/User/_hosts
@@ -1,3 +1,3 @@
 #defcomp ftp ncftp ping rwho rup xping traceroute nslookup
 
-complist -k hosts
+compgen -k hosts
diff --git a/Completion/User/_make b/Completion/User/_make
index d576b0308..24d2cf3f5 100644
--- a/Completion/User/_make
+++ b/Completion/User/_make
@@ -1,3 +1,3 @@
 #defcomp make gmake pmake
 
-complist -s "\$(awk '/^[a-zA-Z0-9][^/ 	]+:/ {print \$1}' FS=: [mM]akefile)"
+compgen -s "\$(awk '/^[a-zA-Z0-9][^/ 	]+:/ {print \$1}' FS=: [mM]akefile)"
diff --git a/Completion/User/_man b/Completion/User/_man
index 8204fba0b..67d59f24a 100644
--- a/Completion/User/_man
+++ b/Completion/User/_man
@@ -2,10 +2,10 @@
 setopt localoptions rcexpandparam
 
 local rep
-if [[ $2 = (<->*|ln) ]]; then
-  rep=( $manpath/(man|cat)$2/$PREFIX*$SUFFIX.<->*(N:t:r) )
+if [[ $words[2] = (<->*|ln) ]]; then
+  rep=( $manpath/(man|cat)${words[2]}/$PREFIX*$SUFFIX.<->*(N:t:r) )
 else
   rep=( $manpath/(man|cat)*/$PREFIX*$SUFFIX.<->*(N:t:r) )
 fi
 
-(( $#rep )) && compadd -m $rep
+(( $#rep )) && compadd - $rep
diff --git a/Completion/User/_mh b/Completion/User/_mh
index 67ce49fd2..7e8575123 100644
--- a/Completion/User/_mh
+++ b/Completion/User/_mh
@@ -1,4 +1,4 @@
-#defcomp folder comp inc mark refile repl scan show next prev rmm pick whom mhn mhpath mhpatch
+#defcomp folder folders comp inc mark refile repl scan show next prev rmm pick whom mhn mhpath
 
 # Completion for all possible MH commands.
 # Alter the following two to your own mh directory and the directory
@@ -7,6 +7,8 @@
 local mymhdir=~/Mail
 local mhlib=/usr/lib/mh
 
+local prev="$words[CURRENT-1]"
+
 # To be on the safe side, check this exists and if not, get it anyway.
 [[ -d $mymhdir ]] || mymhdir=$(mhpath +)
 
@@ -14,13 +16,13 @@ if [[ -iprefix - ]]; then
   # get list of options, which MH commands can generate themselves
   # awk is just too icky to use for this, sorry.  send me one if
   # you come up with it.
-  compadd -m $($COMMAND -help | perl -ne 'if (/^\s*-\(?(\S+)/) {
+  compadd - $($words[1] -help | perl -ne 'if (/^\s*-\(?(\S+)/) {
     $n = $1;
     $n =~ s/\)//g;
     print $n =~ s/^\[([a-z]+)\]// ? "$n\n$1$n\n" : "$n\n";
   }')
   return
-elif [[ -iprefix '+' || -iprefix '@' || -current -1 -draftfolder ]]; then
+elif [[ -iprefix '+' || -iprefix '@' || "$prev" = -draftfolder ]]; then
   # Complete folder names.
   local mhpath
   if [[ $IPREFIX != '@' ]]; then
@@ -31,12 +33,12 @@ elif [[ -iprefix '+' || -iprefix '@' || -current -1 -draftfolder ]]; then
   fi
 
   # painless, or what?
-  complist -W mhpath -/
-elif [[ -mcurrent -1 -(editor|(whatnow|rmm|show|more)proc) ]]; then
-  complist -c
-elif [[ -current -1 -file ]]; then
-  complist -f
-elif [[ -mcurrent -1 -(form|audit|filter) ]]; then
+  _path_files -W mhpath -/
+elif [[ "$prev" = -(editor|(whatnow|rmm|show|more)proc) ]]; then
+  compgen -c
+elif [[ "$prev" = -file ]]; then
+  compgen -f
+elif [[ "$prev" = -(form|audit|filter) ]]; then
   # Need some MH template file, which may be in our own MH directory
   # or with the standard library.
   local mhfpath
@@ -44,11 +46,11 @@ elif [[ -mcurrent -1 -(form|audit|filter) ]]; then
   [[ -d $mhlib ]] || { mhlib=$(mhparam mhlproc); mhlib=$mhlib:h; }
   mhfpath=($mymhdir $mhlib)
 
-  complist -W mhfpath -g '*(.)'
-elif [[ -mcurrent -1 -(no|)cc ]]; then
-  compadd -m all to cc me
-elif [[ -mcurrent -1 -[rw]cache ]]; then
-  compadd -m public private never ask
+  compgen -W mhfpath -g '*(.)'
+elif [[ "$prev" = -(no|)cc ]]; then
+  compadd all to cc me
+elif [[ "$prev" = -[rw]cache ]]; then
+  compadd public private never ask
 else
   # Generate sequences.
   local foldnam folddir f
@@ -64,7 +66,7 @@ else
     # leaving foldnam empty works here
   fi
 
-  complist -s '$(mark $foldnam | awk -F: '\''{ print $1 }'\'')'
-  compadd -m reply next cur prev first last all unseen
-  complist -W folddir -g '<->'
+  compgen -s '$(mark $foldnam 2>/dev/null | awk -F: '\''{ print $1 }'\'')'
+  compadd reply next cur prev first last all unseen
+  compgen -W folddir -g '<->'
 fi
diff --git a/Completion/User/_rcs b/Completion/User/_rcs
index 537db6278..5a751605c 100644
--- a/Completion/User/_rcs
+++ b/Completion/User/_rcs
@@ -1,9 +1,11 @@
 #defcomp co ci rcs
 
-[[ $COMMAND = ci || $COMMAND = rcs ]] && _files
+local nm=$compstate[nmatches]
 
-if [[ $NMATCHES -eq 0 && -d RCS && $COMMAND != ci ]]; then
+[[ $words[1] = ci || $words[1] = rcs ]] && _files
+
+if [[ $compstate[nmatches] -eq nm && -d RCS && $words[1] != ci ]]; then
   local rep
   rep=(RCS/$PREFIX*$SUFFIX,v(:t:s/\,v//))
-  (( $#rep )) && compadd -m $rep
+  (( $#rep )) && compadd - $rep
 fi
diff --git a/Completion/User/_rlogin b/Completion/User/_rlogin
index e36554f23..5d6daef9b 100644
--- a/Completion/User/_rlogin
+++ b/Completion/User/_rlogin
@@ -1,9 +1,9 @@
 #defcomp rlogin rsh ssh
 
-if [[ -position 1 ]]; then
-  complist -k hosts
-elif [[ -position 2 ]]; then
-  complist -k '(-l)'
+if [[ CURRENT -eq 2 ]]; then
+  compgen -k hosts
+elif [[ CURRENT -eq 3 ]]; then
+  compgen -k '(-l)'
 else
-  complist -u
+  compgen -u
 fi
diff --git a/Completion/User/_stty b/Completion/User/_stty
index 6b54b5007..d32d6bdff 100644
--- a/Completion/User/_stty
+++ b/Completion/User/_stty
@@ -1,12 +1,12 @@
 #defcomp stty
 
-if [[ -mcurrent -1 \
+if [[ "$words[CURRENT-1]" = \
   (*erase|discard|status|dsusp|intr|kill|lnext|quit|reprint|start|s*p) ]]
 then
-     compadd -m -Q '^-' '^h' '^?' '^c' '^u'
+     compadd -Q '^-' '^h' '^?' '^c' '^u'
 else
   [[ -string '-' || -string '+' ]]
-  compadd -m rows columns intr quit erase kill eof eol \
+  compadd rows columns intr quit erase kill eof eol \
     eol2 start stop susp dsusp reprint discard werase lnext \
     parenb parodd cs8 cstopb hupcl cread clocal parext \
     ignbrk brkint ignpar parmrk inpck istrip inlcr igncr icrnl iuclc \
diff --git a/Completion/User/_tar b/Completion/User/_tar
index 91767e44d..84c490f1e 100644
--- a/Completion/User/_tar
+++ b/Completion/User/_tar
@@ -1,11 +1,69 @@
 #defcomp tar
 
-local nm=$NMATCHES tf="$2"
+# Tar completion.  Features:
+#  - Assumes tar commands are in second position, tar archive is in third
+#    e.g. tar xvzf zsh-3.0.5.tar.gz ...
+#    Could search better.  Send me the patch.
+#  - `tar' can be called anything, will use the correct name
+#  - Preferentially completes *.tar and *.TAR files in third position
+#  - unless z or Z appears in the commands, in which case prefer *.tar.gz
+#    and similar (GNU tar).
+#  - From fourth position on, if command is x or t, completes files inside
+#    archive.  This is supposed to look pretty much as if the files are
+#    in an ordinary directory hierarchy.  Handles extraction from compressed
+#    archives (GNU tar).
+#  - Anywhere -- appears, gets a list of long options to complete from
+#    tar itself (GNU tar); this needs perl.  If you have GNU tar but not
+#    perl:  your system manager is weird.
+#  - Things like --directory=... are also completed correctly.
 
-if [[ ( -mword 1 *t*f* || -mword 1 *x*f* ) && -position 3 100000 ]]; then
-  complist -k "( $(tar tf $tf) )"
-elif [[ -mword 1 *c*f* && -position 3 100000 ]]; then
+emulate -LR zsh
+setopt extendedglob
+
+local nm=$NMATCHES tcmd="$words[2]" tf="$words[3]"
+
+if [[ $PREFIX = *=* ]]; then
+  # For GNU tar arguments like --directory=
+  IPREFIX=${PREFIX%%\=*}=
+  PREFIX=${PREFIX#*=}
+  if [[ $IPREFIX = --directory* ]]; then
+    _path_files -/
+  else
+    _files
+  fi
+elif [[ $PREFIX = --* ]]; then
+  # gnu tar, generate completions from --help
+  # ones followed by = get that as a suffix
+  local -a ownlist eqlist
+  local comp
+  $words[1] --help |
+  perl -ne 'while (/--[^[\s,='\'']+=?/g) { print "$&\n"; }' |
+  while read comp; do
+    if [[ $comp = *= ]]; then
+      eqlist[$#eqlist+1]=${comp%=}
+    else
+      ownlist[$#ownlist+1]=$comp
+    fi
+  done
+  compgen -S '=' -k eqlist
+  compgen -k ownlist
+elif [[ "$tcmd" = *[tx]*f* && $CURRENT -ge 4 ]] then
+  # Listing or extracting a particular file.  We run `tar t...'
+  # on the file, keeping the list of filenames cached, plus the
+  # name of the tarfile so we know if it changes.
+  local largs=-tf
+
+  [[ $words[2] = *z* ]] && largs=-tzf
+  [[ $words[2] = *Z* ]] && largs=-tZf
+  if [[ $tf != $tar_cache_name ]]; then
+    tar_cache_list=("${(@f)$($words[1] $largs $tf)}")
+    tar_cache_name=$tf
+  fi
+  _multi_parts / tar_cache_list
+elif [[ "$tcmd" = *c*f* && $CURRENT -ge 4 ]] then
   _files
-elif [[ -mcurrent -1 *f* && -position 2 ]]; then
+elif [[ "$tcmd" = *[zZ]*f* && $CURRENT -eq 3 ]] then
+  _files -g '*.((tar|TAR).(gz|Z)|.tgz)'
+elif [[ "$tcmd" = *f* && $CURRENT -eq 3 ]] then
   _files -g '*.(tar|TAR)'
 fi
diff --git a/Completion/User/_x_options b/Completion/User/_x_options
index cc469286d..3190ee377 100644
--- a/Completion/User/_x_options
+++ b/Completion/User/_x_options
@@ -2,4 +2,4 @@
 
 # A simple pattern completion, just as an example.
 
-complist -J options -k '(-display -name -xrm)'
+compgen -J options -k '(-display -name -xrm)'