about summary refs log tree commit diff
path: root/Completion/Core
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-07-12 17:02:40 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-07-12 17:02:40 +0000
commit1f6786ef7ae24ff858f52c6d4ac2bc23d529c0c1 (patch)
tree608d6471d477e8d4d9eafa62f521be50c3248f6e /Completion/Core
parent7c670f1e6a0e154f0b1a2d4b6eed0e71c9404b56 (diff)
downloadzsh-1f6786ef7ae24ff858f52c6d4ac2bc23d529c0c1.tar.gz
zsh-1f6786ef7ae24ff858f52c6d4ac2bc23d529c0c1.tar.xz
zsh-1f6786ef7ae24ff858f52c6d4ac2bc23d529c0c1.zip
zsh-3.1.6-test-1 zsh-3.1.6-test-1
Diffstat (limited to 'Completion/Core')
-rw-r--r--Completion/Core/_main_complete30
-rw-r--r--Completion/Core/_match8
-rw-r--r--Completion/Core/_oldlist24
-rw-r--r--Completion/Core/_path_files7
-rw-r--r--Completion/Core/compinit12
-rw-r--r--Completion/Core/compinstall4
6 files changed, 60 insertions, 25 deletions
diff --git a/Completion/Core/_main_complete b/Completion/Core/_main_complete
index 62e60a1cc..af659e1d4 100644
--- a/Completion/Core/_main_complete
+++ b/Completion/Core/_main_complete
@@ -15,9 +15,13 @@
 #    any matches, correction is tried and if that doesn't yield
 #    anything either, correcting completion is attempted.
 #
-# These completer functions are only used when this function is called
-# without arguments. If arguments are given, they should be names of
-# completer functions which will then be called.
+#    These completer functions are only used when this function is called
+#    without arguments. If arguments are given, they should be names of
+#    completer functions which will then be called.
+#
+#  last_prompt
+#    If this is set to `always' the cursor is moved up to the last prompt
+#    after printing a list even if a numeric argument was given.
 
 
 # If you want to complete only set or unset options for the unsetopt
@@ -33,7 +37,7 @@
 # state than the global one for which you are completing.
 
 
-local comp
+local comp ret=1
 
 setopt localoptions nullglob rcexpandparam
 unsetopt markdirs globsubst shwordsplit nounset ksharrays
@@ -54,5 +58,21 @@ fi
 # And now just call the completer functions defined.
 
 for comp; do
-  "$comp" && return
+  if "$comp"; then
+    ret=0
+    break;
+  fi
 done
+
+[[ "$compconfig[last_prompt]" = always ]] && compstate[last_prompt]=yes
+
+_lastcomp=( "${(@kv)compstate}" )
+_lastcomp[completer]="$comp"
+_lastcomp[prefix]="$PREFIX"
+_lastcomp[suffix]="$SUFFIX"
+_lastcomp[iprefix]="$IPREFIX"
+_lastcomp[isuffix]="$ISUFFIX"
+_lastcomp[qiprefix]="$QIPREFIX"
+_lastcomp[qisuffix]="$QISUFFIX"
+
+return ret
diff --git a/Completion/Core/_match b/Completion/Core/_match
index 251c65381..a4499dc08 100644
--- a/Completion/Core/_match
+++ b/Completion/Core/_match
@@ -60,10 +60,8 @@ _complete && ret=1
 compstate[pattern_match]="$opm"
 compstate[matcher]="$compstate[total_matchers]"
 
-if (( ! ret )); then
-  [[ "$compconfig[match_insert]" = unambig* &&
-     $#compstate[unambiguous] -ge ${#:-${PREFIX}${SUFFIX}} ]] && 
-      compstate[pattern_insert]=unambiguous
-fi
+[[ ret -eq 1 && "$compconfig[match_insert]" = unambig* &&
+   $#compstate[unambiguous] -ge ${#:-${PREFIX}${SUFFIX}} ]] && 
+    compstate[pattern_insert]=unambiguous
 
 return 1-ret
diff --git a/Completion/Core/_oldlist b/Completion/Core/_oldlist
index f42197695..bdf12f90c 100644
--- a/Completion/Core/_oldlist
+++ b/Completion/Core/_oldlist
@@ -4,12 +4,24 @@
 # and either the compconfig key oldlist_list is `always', or it is not `never'
 # and the list is not already shown, then use the existing list for listing
 # (even if it was generated by another widget).
-if [[ -n $compstate[old_list] && $compconfig[oldlist_list] != never &&
-  $WIDGET = *list* &&
-  ( $compconfig[oldlist_list] = always || $compstate[old_list] != shown ) ]]
-then
-  compstate[old_list]=keep
-  return 0
+# Do this also if there is an old list and it was generated by the
+# completer named by the oldlist_list key.
+if [[ -n $compstate[old_list] && $compconfig[oldlist_list] != never ]]; then
+  if [[ $WIDGET = *list* &&
+        ( $compconfig[oldlist_list] = always ||
+	  $compstate[old_list] != shown ) ]]; then
+    compstate[old_list]=keep
+    return 0
+  elif [[ $compconfig[oldlist_list] = *${_lastcomp[completer]}* ]]; then
+    [[ "$_lastcomp[insert]" = unambig* ]] && compstate[to_end]=single
+    compstate[old_list]=keep
+    if [[ -o automenu ]]; then
+      compstate[insert]=menu
+    else
+      compadd -Qs "$SUFFIX" - "$PREFIX"
+    fi
+    return 0
+  fi
 fi
 
 # If this is a completion widget, and we have a completion inserted already,
diff --git a/Completion/Core/_path_files b/Completion/Core/_path_files
index 58f343367..e65f814e1 100644
--- a/Completion/Core/_path_files
+++ b/Completion/Core/_path_files
@@ -33,12 +33,11 @@ typeset -U prepaths exppaths
 setopt localoptions nullglob rcexpandparam extendedglob
 unsetopt markdirs globsubst shwordsplit nounset
 
+local sopt='-' gopt='' opt
 exppaths=()
 prepaths=('')
 ignore=()
 group=()
-sopt='-'
-gopt=''
 pats=()
 addpfx=()
 addsfx=()
@@ -377,9 +376,9 @@ done
 exppaths=( "${(@)exppaths:#$orig}" )
 
 if [[ -n "$compconfig[path_expand]" &&
-      $#exppaths -eq 0 && nm -eq compstate[nmatches] ]]; then
+      $#exppaths -eq 1 && nm -eq compstate[nmatches] ]]; then
   compadd -QU -S '' "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \
           -M 'r:|/=* r:|=*' -p "$linepath" - "${(@)exppaths}"
 fi
 
-[[ nm -eq compstate[nmatches] ]]
+[[ nm -ne compstate[nmatches] ]]
diff --git a/Completion/Core/compinit b/Completion/Core/compinit
index 9302d8243..63e4c0860 100644
--- a/Completion/Core/compinit
+++ b/Completion/Core/compinit
@@ -49,7 +49,7 @@ emulate -L zsh
 typeset _i_dumpfile _i_files _i_line _i_done _i_dir _i_autodump=1
 typeset _i_tag _i_file _i_addfiles
 
-while [[ $# -gt 0 && $1 = -[df] ]]; do
+while [[ $# -gt 0 && $1 = -[dDf] ]]; do
   if [[ "$1" = -d ]]; then
     _i_autodump=1
     shift
@@ -59,6 +59,7 @@ while [[ $# -gt 0 && $1 = -[df] ]]; do
     fi
   elif [[ "$1" = -D ]]; then
     _i_autodump=0
+    shift
   elif [[ "$1" = -f ]]; then
     # Not used any more; use _compdir
     shift
@@ -72,6 +73,11 @@ done
 typeset -gA _comps
 _patcomps=()
 
+# The associative array use to report information about the last
+# cmpletion to the outside.
+
+typeset -gA _lastcomp
+
 # This is the associative array used for configuration.
 
 typeset -gA compconfig
@@ -308,10 +314,10 @@ if [[ $#_i_files -lt 20 || $_compdir = */Core || -d $_compdir/Core ]]; then
     fi
     for _i_line in {1..$#i_addfiles}; do
       _i_file=${_i_addfiles[$_i_line]}
-      [[ -d $_i_file && -z ${fpath[(r)$_i_$file]} ]] ||
+      [[ -d $_i_file && -z ${fpath[(r)$_i_file]} ]] ||
         _i_addfiles[$_i_line]=
     done
-    fpath=($_i_addfiles $fpath)
+    fpath=($fpath $_i_addfiles)
     _i_files=( ${^~fpath:/.}/_(|*[^~])(N:t) )
   fi
 fi
diff --git a/Completion/Core/compinstall b/Completion/Core/compinstall
index 52b4bf707..bd58d643b 100644
--- a/Completion/Core/compinstall
+++ b/Completion/Core/compinstall
@@ -136,7 +136,7 @@ fi
 
 # Check if this is in fpath already, else put it there (with ~'s expanded).
 _ci_f=${~_ci_fdir}
-[[ -z ${fpath[(r)$_ci_f]} ]] && fpath=($_ci_f $fpath)
+[[ -z ${fpath[(r)$_ci_f]} ]] && fpath=($fpath $_ci_f)
 
 # Contract $HOME to ~ in the parameter to be used for writing.
 _ci_fdir=${_ci_fdir/#$HOME/\~}
@@ -183,7 +183,7 @@ ${_ci_dumpfile}.  Please edit a replacement."
 fi
 
 _ci_lines="${_ci_lines}_compdir=$_ci_fdir
-[[ -z \$fpath[(r)\$_compdir] ]] && fpath=(\$_compdir \$fpath)
+[[ -z \$fpath[(r)\$_compdir] ]] && fpath=(\$fpath \$_compdir)
 autoload -U compinit
 compinit"
 [[ $_ci_dtype != standard ]] && _ci_lines="${_ci_lines} $_ci_dumpfile"