about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Commands/.distfiles1
-rw-r--r--Completion/Commands/_next_tags70
-rw-r--r--Completion/Core/_files2
-rw-r--r--Completion/Core/_main_complete5
-rw-r--r--Completion/Core/_requested2
-rw-r--r--Completion/Core/_wanted5
6 files changed, 79 insertions, 6 deletions
diff --git a/Completion/Commands/.distfiles b/Completion/Commands/.distfiles
index 804e65be3..45378a009 100644
--- a/Completion/Commands/.distfiles
+++ b/Completion/Commands/.distfiles
@@ -2,4 +2,5 @@ DISTFILES_SRC='
     .distfiles
     _bash_completions _correct_filename _correct_word _expand_word 
     _history_complete_word _read_comp _most_recent_file _complete_help
+    _next_tags
 '
diff --git a/Completion/Commands/_next_tags b/Completion/Commands/_next_tags
new file mode 100644
index 000000000..8bd3f5921
--- /dev/null
+++ b/Completion/Commands/_next_tags
@@ -0,0 +1,70 @@
+#compdef -k complete-word \C-xn
+
+# Main widget/completer.
+
+_next_tags() {
+
+  if [[ $#funcstack -gt 1 ]]; then
+
+    # Called as completer, probably `remove' our helper function. A better
+    # test would be nice, but I think one should still be able to edit the
+    # current word between attempts to complete it.
+
+    [[ $_next_tags_pre != ${LBUFFER%${PREFIX}} ]] && unset _sort_tags
+
+    return 1
+  else
+    local comp
+
+    if [[ -z $compstate[old_list] ]]; then
+      comp=()
+    else
+      comp=(_next_tags _complete)
+    fi
+
+    (( $+_sort_tags )) || _next_tags_not=
+
+    _sort_tags=_next_tags_sort
+    _next_tags_pre="${LBUFFER%${PREFIX}}"
+    _next_tags_not="$_next_tags_not $_lastcomp[tags]"
+
+    _main_complete "$comp[@]"
+
+    [[ $compstate[insert] = automenu ]] &&
+       compstate[insert]=automenu-unambiguous
+
+    compstate[insert]=''
+    compstate[list]='list force'
+  fi
+}
+
+# Helper function for sorting tags. Most of this is copied from _tags.
+
+_next_tags_sort() {
+  local order tags tag nodef
+
+  zstyle -a ":completion:${curcontext}:" tag-order order ||
+    order=( 'arguments values' options globbed-files directories all-files )
+
+  # But we also remove the tags we've already tried...
+
+  tags=( "${(@)order:#(${(j:|:)~${=_next_tags_not}})}" )
+
+  # ... unless that would remove all offered tags.
+
+  [[ $#tags -ne $#order && "$tags" != *(${(j:|:)~argv})* ]] &&
+    tags=( $order ) _next_tags_not=
+
+  for tag in $tags; do
+    case $tag in
+    -)     nodef=yes;;
+    *\(\)) "${${tag%%[ 	]#\(\)}##[ 	]#}" "$@";;
+    \!*)   comptry "${(@)argv:#(${(j:|:)~${=tag[2,-1]}})}";;
+    ?*)    comptry ${=tag};;
+    esac
+  done
+
+  [[ -z "$nodef" ]] && comptry "$@"
+}
+
+[[ -o kshautoload ]] || _next_tags "$@"
diff --git a/Completion/Core/_files b/Completion/Core/_files
index 1e139bc6b..75cabda81 100644
--- a/Completion/Core/_files
+++ b/Completion/Core/_files
@@ -33,7 +33,7 @@ if zstyle -s ":completion:${curcontext}:directories" file-patterns tmp &&
     type="${type}/"
   fi
 else
-  dopts=()
+  dopts=(-/)
 fi
 if zstyle -s ":completion:${curcontext}:globbed-files" file-patterns tmp &&
    [[ -n "$tmp" ]]; then
diff --git a/Completion/Core/_main_complete b/Completion/Core/_main_complete
index d019351b9..a5af32f0f 100644
--- a/Completion/Core/_main_complete
+++ b/Completion/Core/_main_complete
@@ -21,7 +21,7 @@ unsetopt markdirs globsubst shwordsplit nounset ksharrays
 
 local ctxt post ret=1 tmp _compskip format _comp_ignore \
       _completers _completer _completer_num \
-      _matchers _matcher _matcher_num \
+      _matchers _matcher _matcher_num _comp_tags \
       context state line opt_args val_args curcontext="$curcontext" \
       _last_nmatches=-1 _last_menu_style _def_menu_style _menu_style sel \
       _saved_exact="${compstate[exact]}" \
@@ -193,12 +193,13 @@ done
 comppostfuncs=()
 
 _lastcomp=( "${(@kv)compstate}" )
-_lastcomp[completer]="$comp"
+_lastcomp[completer]="$_completer"
 _lastcomp[prefix]="$PREFIX"
 _lastcomp[suffix]="$SUFFIX"
 _lastcomp[iprefix]="$IPREFIX"
 _lastcomp[isuffix]="$ISUFFIX"
 _lastcomp[qiprefix]="$QIPREFIX"
 _lastcomp[qisuffix]="$QISUFFIX"
+_lastcomp[tags]="$_comp_tags"
 
 return ret
diff --git a/Completion/Core/_requested b/Completion/Core/_requested
index a582adfb9..b5efb5a9e 100644
--- a/Completion/Core/_requested
+++ b/Completion/Core/_requested
@@ -8,7 +8,7 @@ else
   tag="$1"
 fi
 
-comptags -R "$tag" &&
+comptags -R "$tag" && _comp_tags="$_comp_tags $tag" &&
     if [[ $# -gt 1 ]]; then
       _description "$@"
       return 0
diff --git a/Completion/Core/_wanted b/Completion/Core/_wanted
index f95d74451..400daa701 100644
--- a/Completion/Core/_wanted
+++ b/Completion/Core/_wanted
@@ -19,7 +19,8 @@ else
 fi
 
 if [[ $# -gt 1 ]]; then
-  _tags "$targs[@]" "$tag" && _description "$@"
+  _tags "$targs[@]" "$tag" && _comp_tags="$_comp_tags $tag" &&
+    _description "$@"
 else
-  _tags "$targs[@]" "$tag"
+  _tags "$targs[@]" "$tag" && _comp_tags="$_comp_tags $tag"
 fi