about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-06-08 09:25:39 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-06-08 09:25:39 +0000
commit805381040dd69dd02b78423d2d71913b33f3cc33 (patch)
tree1fa89ee643e8e577a2f79e76e3d6cafc93256ca2 /Completion
parentf42e3fa8e6152e145251e8f16f4c61c23dec1f59 (diff)
downloadzsh-805381040dd69dd02b78423d2d71913b33f3cc33.tar.gz
zsh-805381040dd69dd02b78423d2d71913b33f3cc33.tar.xz
zsh-805381040dd69dd02b78423d2d71913b33f3cc33.zip
zsh-3.1.5-pws-21 zsh-3.1.5-pws-21
Diffstat (limited to 'Completion')
-rw-r--r--Completion/.distfiles2
-rw-r--r--Completion/Base/.distfiles2
-rw-r--r--Completion/Base/_brace_parameter14
-rw-r--r--Completion/Base/_first63
-rw-r--r--Completion/Base/_long_options10
-rw-r--r--Completion/Core/.distfiles7
-rw-r--r--Completion/Core/_approximate12
-rw-r--r--Completion/Core/_complete10
-rw-r--r--Completion/Core/_correct4
-rw-r--r--Completion/Core/_expand2
-rw-r--r--Completion/Core/_files8
-rw-r--r--Completion/Core/_list4
-rw-r--r--Completion/Core/_normal2
-rw-r--r--Completion/Core/_parameters7
-rw-r--r--Completion/Core/_sep_parts2
-rw-r--r--Completion/Core/compinit34
-rw-r--r--Completion/Makefile.in86
-rw-r--r--Completion/User/_make3
-rw-r--r--Completion/User/_mh2
19 files changed, 231 insertions, 43 deletions
diff --git a/Completion/.distfiles b/Completion/.distfiles
index c50107c61..e85e122ef 100644
--- a/Completion/.distfiles
+++ b/Completion/.distfiles
@@ -1,3 +1,3 @@
 DISTFILES_SRC='
-    .distfiles README
+    .distfiles README Makefile.in
 '
diff --git a/Completion/Base/.distfiles b/Completion/Base/.distfiles
index 6c537c26b..ef1e9df73 100644
--- a/Completion/Base/.distfiles
+++ b/Completion/Base/.distfiles
@@ -1,6 +1,6 @@
 DISTFILES_SRC='
     .distfiles 
-    _brace_parameter _command_names _condition _default _equal
+    _brace_parameter _command_names _condition _default _equal _first
     _long_options _math _parameter _precommand _redirect _subscript
     _tilde _vars 
 '
diff --git a/Completion/Base/_brace_parameter b/Completion/Base/_brace_parameter
index d45e317be..f688e175a 100644
--- a/Completion/Base/_brace_parameter
+++ b/Completion/Base/_brace_parameter
@@ -1,9 +1,19 @@
 #compdef -brace-parameter-
 
+setopt localoptions extendedglob
+
+local lp ls n q suf=''
+
 if [[ "$SUFFIX" = *\}* ]]; then
   ISUFFIX="${SUFFIX#*\}}$ISUFFIX"
   SUFFIX="${SUFFIX%%\}*}"
-  _parameters -S '} ' -r '-:?#%+=[/'
 else
-  _parameters -S '} ' -r '-:?#%+=[/'
+  suf='} '
 fi
+
+lp="$LBUFFER[1,-${#PREFIX}-1]"
+ls="$RBUFFER[${#SUFFIX}+1,-1]"
+n=${(M)#ls##\"#}
+q=${(M)lp%%\"#}
+
+_parameters -s "${q[1,-n-1]}" -S "$suf" -r '-:?#%+=[/'
diff --git a/Completion/Base/_first b/Completion/Base/_first
new file mode 100644
index 000000000..d9e7ee82c
--- /dev/null
+++ b/Completion/Base/_first
@@ -0,0 +1,63 @@
+#compdef -first-
+
+# This function is called at the very beginning before any other
+# function for a specific context.
+#
+# This just gives some examples of things you might want to do here.
+#
+#
+# If you use the vared builtin and want completion in there to act the 
+# way completion on the right hand side of assignments is done, add
+# (or un-comment) this code:
+#
+#     if [[ -n $compstate[vared] ]]; then
+#       if [[ $compstate[vared] = *\[* ]]; then
+#         # vared on an array-element
+#         compstate[parameter]=${compstate[vared]%%\[*}
+#         compstate[context]=value
+#       else
+#         # vared on a parameter, let's see if it is an array
+#         compstate[parameter]=$compstate[vared]
+#         if [[ ${(tP)compstate[vared]} = *(array|assoc)* ]]; then
+#           compstate[context]=array_value
+#         else
+#           compstate[context]=value
+#         fi
+#       fi
+#       return
+#     fi
+#
+#
+#
+# Other things you can do here is to complete different things if the
+# word on the line matches a certain pattern. This example allows
+# completion of words from the history by adding two commas at the end 
+# and hitting TAB.
+#
+#     if [[ "$PREFIX" = *,, ]]; then
+#       local max i=1
+#     
+#       PREFIX="$PREFIX[1,-2]"
+#       # If a numeric prefix is given, we use it as the number of
+#       # lines (multiplied by ten below) in the history to search.
+#       if [[ NUMERIC -gt 1 ]]; then
+#         max=$NUMERIC
+#         NUMERIC=1
+#       else
+#         # The default is to search the last 100 lines.
+#         max=10
+#       fi
+#       # We first search in the last ten lines, then in the last
+#       # twenty lines, and so on...
+#       while [[ i -le max ]]; do
+#         if compgen -X "%Bhistory ($n):%b" -Q -H $(( i*10 )) ''; then
+#           # We have found at least one matching word, so we switch
+#           # on menu-completion and make sure that no other
+#           # completion function is called by setting _comp_skip.
+#           compstate[insert]=menu
+#           _comp_skip=1
+#           return
+#         fi
+#         (( i++ ))
+#       done
+#     fi
diff --git a/Completion/Base/_long_options b/Completion/Base/_long_options
index 6288fc3a0..a50edee1c 100644
--- a/Completion/Base/_long_options
+++ b/Completion/Base/_long_options
@@ -7,11 +7,11 @@
 # a command that does not support this option.
 #
 # For options that get an argument after a `=', the function also tries
-# to automatically find out what should be complete as the argument.
+# to automatically find out what should be completed as the argument.
 # The possible completions for option-arguments can be described with
 # the arguments to this function. This is done by giving pairs of
 # patterns and actions as consecutive arguments. The actions specify
-# what should be done to complete arguemts of those options that match 
+# what should be done to complete arguments of those options that match 
 # the pattern. The action may be a list of words in brackets or in
 # parentheses, separated by spaces. A list in brackets denotes
 # possible values for an optional argument, a list in parentheses
@@ -27,18 +27,18 @@
 # This makes `yes' and `no' be completed as the argument of options
 # whose description ends in a star, file names for options that
 # contain the substring `=FILE' in the description, and paths for
-# options whose description contains `=DIR'. Note the last two
+# options whose description contains `=DIR'. Note that the last two
 # patterns are not needed since this function always completes files
 # for option descriptions containing `=FILE' and paths for option
 # descriptions that contain `=DIR' or `=PATH'. These builtin patterns
 # can be overridden by patterns given as arguments, though.
 # 
-# This function accepts following options:
+# This function accepts the following options:
 #
 # -t   do completion only on words starting with two hyphens
 #
 # -i   list of patterns. Options, matching these patterns, are ignored.
-#      The list may be given as array name or as literal list in braces.
+#      The list may be given as a array name or as a literal list in braces.
 #      E.g. _long_options -i '(--(enable|disable)-FEATURE*)' will ignore
 #      --enable-FEATURE, that is listed in configure help output
 #
diff --git a/Completion/Core/.distfiles b/Completion/Core/.distfiles
index 9a9e87d7c..c9362dccb 100644
--- a/Completion/Core/.distfiles
+++ b/Completion/Core/.distfiles
@@ -1,7 +1,8 @@
 DISTFILES_SRC='
     .distfiles
-    _approximate _closequotes _compalso _complete _correct _expand _files
-    _list _main_complete _match _menu _multi_parts _normal _oldlist _options
-    _parameters _path_files _sep_parts _set_options _unset_options
+    _approximate _compalso _complete _correct _expand
+    _files _list _main_complete _match _menu _multi_parts
+    _normal _oldlist _options _parameters _path_files
+    _sep_parts _set_options _unset_options
     compdump compinit compinstall
 '
diff --git a/Completion/Core/_approximate b/Completion/Core/_approximate
index 1b40f7cbf..c63416901 100644
--- a/Completion/Core/_approximate
+++ b/Completion/Core/_approximate
@@ -1,9 +1,9 @@
 #autoload
 
 # This code will try to correct the string on the line based on the
-# strings generated for the context if `compconfig[correct]' is set.
-# These corrected strings will be shown in a list and one can
-# cycle through them as in a menucompletion or get the corrected prefix.
+# strings generated for the context. These corrected strings will be
+# shown in a list and one can cycle through them as in a menucompletion
+# or get the corrected prefix.
 #
 # Supported configuration keys:
 #
@@ -64,7 +64,7 @@
 local _comp_correct _correct_prompt comax
 local cfgacc cfgorig cfgps cfgins
 
-# Only if all global matchers hav been tried.
+# Only if all global matchers have been tried.
 
 [[ compstate[matcher] -ne compstate[total_matchers] ]] && return 1
 
@@ -153,7 +153,7 @@ compgen() {
 _comp_correct=1
 compstate[matcher]=-1
 
-_correct_prompt="${cfgps//\%e/1}"
+_correct_prompt="${cfgps//\\%e/1}"
 
 # We also need to set `extendedglob' and make the completion
 # code behave as if globcomplete were set.
@@ -188,7 +188,7 @@ while [[ _comp_correct -le comax ]]; do
   [[ "${#:-$PREFIX$SUFFIX}" -le _comp_correct+1 ]] && break
   (( _comp_correct++ ))
 
-  _correct_prompt="${cfgps//\%e/$_comp_correct}"
+  _correct_prompt="${cfgps//\\%e/$_comp_correct}"
 done
 
 compstate[matcher]="$compstate[total_matchers]"
diff --git a/Completion/Core/_complete b/Completion/Core/_complete
index 0f4d5ff4b..86ccc8c67 100644
--- a/Completion/Core/_complete
+++ b/Completion/Core/_complete
@@ -6,6 +6,15 @@
 
 local comp name
 
+# If we have a user-supplied context name, use only that.
+
+if [[ -n "$compcontext" ]]; then
+  comp="$_comps[$compcontext]"
+  [[ -z "$comp" ]] || "$comp"
+
+  return
+fi
+
 # An entry for `-first-' is the replacement for `compctl -T'
 # Completion functions may set `_compskip' to any value to make the 
 # main loops stop calling other completion functions.
@@ -20,6 +29,7 @@ if [[ ! -z "$comp" ]]; then
   fi
 fi
 
+
 # For arguments and command names we use the `_normal' function.
 
 if [[ "$compstate[context]" = command ]]; then
diff --git a/Completion/Core/_correct b/Completion/Core/_correct
index 35ab01cf1..c9c3d999c 100644
--- a/Completion/Core/_correct
+++ b/Completion/Core/_correct
@@ -1,8 +1,8 @@
 #autoload
 
-# This is mainly a wrapper around the more general `_approximate.
+# This is mainly a wrapper around the more general `_approximate'.
 # By setting `compstate[pattern_match]' to something unequal to `*' and
-# then calling `_approximate, we get only corrections, not all strings
+# then calling `_approximate', we get only corrections, not all strings
 # with the corrected prefix and something after it.
 #
 # Supported configuration keys are the same as for `_approximate', only
diff --git a/Completion/Core/_expand b/Completion/Core/_expand
index 9172b6cbf..aca3839d4 100644
--- a/Completion/Core/_expand
+++ b/Completion/Core/_expand
@@ -132,7 +132,7 @@ else
   if [[ -z "$compconfig[expand_prompt]" ]]; then
     compadd -UQ $group _expand - "$exp[@]"
   else
-    compadd -UQ -X "${compconfig[expand_prompt]//\%o/$word}" \
+    compadd -UQ -X "${compconfig[expand_prompt]//\\%o/$word}" \
             $group _expand - "$exp[@]"
   fi
   [[ "$compconfig[expand_menu]" != *last* &&
diff --git a/Completion/Core/_files b/Completion/Core/_files
index 506ddbc8e..b6349a8c5 100644
--- a/Completion/Core/_files
+++ b/Completion/Core/_files
@@ -1,7 +1,7 @@
 #autoload
 
 # Utility function for completing files of a given type or any file.
-# In many cases you will want to call this one instead of _path_files().
+# In many cases you will want to call this one instead of `_path_files'.
 
 local nm=$compstate[nmatches] ret=1
 
@@ -12,9 +12,9 @@ if [[ $# -ne 0 && compstate[nmatches] -eq nm ]]; then
 
   # We didn't get any matches for those types of files described by
   # the `-g' or `-/' option. Now we try it again accepting all files.
-  # First we get those options that we have to use even if then. If
-  # we find out that the `-f' option was given, we already accepted
-  # all files and give up immediatly.
+  # First we get those options that we have to use even then. If we
+  # find out that the `-f' option was given, we already accepted all
+  # files and give up immediatly.
 
   opts=()
   while getopts "P:S:W:F:J:V:X:f/g:" opt; do
diff --git a/Completion/Core/_list b/Completion/Core/_list
index 099c6bc7b..0d5651c23 100644
--- a/Completion/Core/_list
+++ b/Completion/Core/_list
@@ -1,8 +1,8 @@
 #autoload
 
 # This completer function makes the other completer functions used
-# insert possible completions only after once the list has been
-# shown.
+# insert possible completions only after the list has been shown at
+# least once.
 #
 # Configuration keys:
 #
diff --git a/Completion/Core/_normal b/Completion/Core/_normal
index 98337eae5..ed7243bb1 100644
--- a/Completion/Core/_normal
+++ b/Completion/Core/_normal
@@ -3,7 +3,7 @@
 local comp command cmd1 cmd2 pat val name i ret=1
 
 # Completing in command position? If not we set up `cmd1' and `cmd2' as
-# two strings we have search in the completion definition arrays (e.g.
+# two strings we have to search in the completion definition arrays (e.g.
 # a path and the last path name component).
 
 command="$words[1]"
diff --git a/Completion/Core/_parameters b/Completion/Core/_parameters
index 0e8c548f7..d9d8a38b2 100644
--- a/Completion/Core/_parameters
+++ b/Completion/Core/_parameters
@@ -1,8 +1,7 @@
 #autoload
 
 # This should be used to complete parameter names if you need some of the
-# extra options of compadd. It first tries to complete only non-local
-# parameters. All arguments are given to compadd.
+# extra options of compadd. It completes only non-local parameters. All
+# arguments are given to compadd.
 
-compadd "$@" - "${(@)${(@)${(@)${(@f)$(typeset)}:#*local *\=*}%%\=*}##* }" ||
-    compadd "$@" - "${(@)${(@)${(@f)$(typeset)}%%\=*}##* }"
+compadd "$@" - "${(@)${(@)${(@)${(@f)$(typeset)}:#*local *\=*}%%\=*}##* }"
diff --git a/Completion/Core/_sep_parts b/Completion/Core/_sep_parts
index b906a3042..6f2595120 100644
--- a/Completion/Core/_sep_parts
+++ b/Completion/Core/_sep_parts
@@ -9,7 +9,7 @@
 #
 #  _sep_parts '(foo bar)' @ hosts
 #
-# This will make this function complete the strings `foo' and `bar'
+# This will make this function complete the strings `foo' and `bar'.
 # If the string on the line contains a `@', the substring after it
 # will be completed from the array `hosts'. Of course more arrays
 # may be given, each preceded by another separator string.
diff --git a/Completion/Core/compinit b/Completion/Core/compinit
index 77f918502..af2467bec 100644
--- a/Completion/Core/compinit
+++ b/Completion/Core/compinit
@@ -2,7 +2,7 @@
 # functions and aliases. Everything else is split into different files that
 # will automatically be made autoloaded (see the end of this file).
 # The names of the files that will be considered for autoloading have to
-# start with an underscores (like `_setopt).
+# start with an underscores (like `_setopt').
 # The first line of these files will be read and has to say what should be
 # done with its contents:
 #
@@ -50,11 +50,11 @@
 _i_fdir=''
 _i_dumpfile=''
 _i_autodump=0
-while [[ $1 = -[df] ]]; do
+while [[ $# -gt 0 && $1 = -[df] ]]; do
   if [[ "$1" = -d ]]; then
     _i_autodump=1
     shift
-    if [[ -n "$1" && "$1" != -[df] ]]; then
+    if [[ $# -gt 0 && "$1" != -[df] ]]; then
       _i_dumpfile="$1"
       shift
     fi
@@ -91,13 +91,31 @@ elif [[ -n $_i_fdir ]]; then
   # We were told what directory to use.
   compconfig[dumpfile]="$_i_fdir/compinit.dump"
 else
-  # Now we're stuck, but we'd better do something.
-  compconfig[dumpfile]="$HOME/.compinit.dump"
+  compconfig[dumpfile]=''
 fi
 
-compconfig[correct_accept]=2n
-compconfig[correct_prompt]='correct to:'
-compconfig[completer]=_complete
+if [[ -n $compconfig[dumpfile] ]]; then
+  # Check the file is writeable.  If it doesn't exist, the
+  # only safe way is to try and create it.
+  if [[ -f $compconfig[dumpfile] ]]; then
+    [[ -w $compconfig[dumpfile] ]] || compconfig[dumpfile]=''
+  elif touch $compconfig[dumpfile] >& /dev/null; then
+    rm -f $compconfig[dumpfile]
+  else
+    compconfig[dumpfile]=''
+  fi
+fi
+
+if [[ -z $compconfig[dumpfile] ]]; then
+  # If no dumpfile given, or it was not writeable, then use
+  # user's ZDOTDIR.
+  compconfig[dumpfile]="${ZDOTDIR:-$HOME}/.zcompdump"
+fi
+
+(( ${+compconfig[correct_accept]} )) || compconfig[correct_accept]=2n
+(( ${+compconfig[correct_prompt]} )) ||
+  compconfig[correct_prompt]='correct to:'
+(( ${+compconfig[completer]} )) || compconfig[completer]=_complete
 
 # This function is used to register or delete completion functions. For
 # registering completion functions, it is invoked with the name of the
diff --git a/Completion/Makefile.in b/Completion/Makefile.in
new file mode 100644
index 000000000..8b7776a7f
--- /dev/null
+++ b/Completion/Makefile.in
@@ -0,0 +1,86 @@
+#
+# Makefile for Completion subdirectory
+#
+# Copyright (c) 1999 Peter Stephensons
+# All rights reserved.
+#
+# Permission is hereby granted, without written agreement and without
+# license or royalty fees, to use, copy, modify, and distribute this
+# software and to distribute modified versions of this software for any
+# purpose, provided that the above copyright notice and the following
+# two paragraphs appear in all copies of this software.
+#
+# In no event shall Peter Stephenson or the Zsh Development Group be liable
+# to any party for direct, indirect, special, incidental, or consequential
+# damages arising out of the use of this software and its documentation,
+# even if Peter Stephenson and the Zsh Development Group have been advised of
+# the possibility of such damage.
+#
+# Peter Stephenson and the Zsh Development Group specifically disclaim any
+# warranties, including, but not limited to, the implied warranties of
+# merchantability and fitness for a particular purpose.  The software
+# provided hereunder is on an "as is" basis, and Peter Stephenson and the
+# Zsh Development Group have no obligation to provide maintenance,
+# support, updates, enhancements, or modifications.
+#
+
+subdir = Completion
+dir_top = ..
+SUBDIRS =
+
+@VERSION_MK@
+
+# source/build directories
+VPATH           = @srcdir@
+sdir            = @srcdir@
+sdir_top        = @top_srcdir@
+INSTALL         = @INSTALL@
+
+@DEFS_MK@
+
+# ========== DEPENDENCIES FOR BUILDING ==========
+
+all:
+
+# ========== DEPENDENCIES FOR INSTALLING ==========
+
+install: install.fns
+
+uninstall: uninstall.fns
+
+# install functions, including those in subdirectories, creating
+# install directory if necessary
+install.fns:
+	if test x$(fndir) != x && test x$(fndir) != xno; then \
+	  $(sdir_top)/mkinstalldirs $(fndir) || exit 1; \
+	  for file in $(FUNCTIONS_INSTALL); do \
+	    if test -f $$file; then \
+	      $(INSTALL_DATA) $$file $(fndir) || exit 1; \
+	    fi; \
+	  done; \
+	fi; \
+	exit 0
+
+uninstall.fns:
+	if test x$(fndir) != x && test x$(fndir) != xno; then \
+	  for file in $(FUNCTIONS_INSTALL); do \
+	    if test -f $$file; then \
+	      rm -f "$(fndir)/`echo $$file | sed -e 's%^.*/%%'`"; \
+	    fi; \
+	  done; \
+	fi; \
+	exit 0
+
+# ========== DEPENDENCIES FOR CLEANUP ==========
+
+@CLEAN_MK@
+
+mostlyclean-here:
+
+distclean-here:
+
+realclean-here:
+
+# ========== DEPENDENCIES FOR MAINTENANCE ==========
+
+@CONFIG_MK@
diff --git a/Completion/User/_make b/Completion/User/_make
index a30ca4b7a..4770c0d7a 100644
--- a/Completion/User/_make
+++ b/Completion/User/_make
@@ -1,3 +1,4 @@
 #compdef make gmake pmake
 
-compgen -s "\$(awk '/^[a-zA-Z0-9][^\/ 	]+:/ {print \$1}' FS=: [mM]akefile /dev/null)"
+compgen -s "\$(awk '/^[a-zA-Z0-9][^\/ 	]+:/ {print \$1}' FS=: [mM]akefile /dev/null)" ||
+_files
diff --git a/Completion/User/_mh b/Completion/User/_mh
index c2801b896..e228d31b0 100644
--- a/Completion/User/_mh
+++ b/Completion/User/_mh
@@ -57,7 +57,7 @@ else
   # Generate sequences.
   local foldnam folddir f ret
 
-  for f in $argv; do
+  for f in $words; do
     [[ $f = [@+]* ]] && foldnam=$f
   done
   if [[ $foldnam = '+'* ]]; then