about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-09-13 09:53:59 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-09-13 09:53:59 +0000
commit2ef449a71d2f681a85453e68b10d3af97dec14ff (patch)
tree873c17f1c1bdea725d5b13b713a77e68cf9e331b /Completion
parentafb7b41cdc21ff64949f485fd24b2012469e6fb6 (diff)
downloadzsh-2ef449a71d2f681a85453e68b10d3af97dec14ff.tar.gz
zsh-2ef449a71d2f681a85453e68b10d3af97dec14ff.tar.xz
zsh-2ef449a71d2f681a85453e68b10d3af97dec14ff.zip
zsh-workers/7797
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Commands/_verbose_list75
-rw-r--r--Completion/Core/_oldlist20
2 files changed, 90 insertions, 5 deletions
diff --git a/Completion/Commands/_verbose_list b/Completion/Commands/_verbose_list
new file mode 100644
index 000000000..b3d762ecc
--- /dev/null
+++ b/Completion/Commands/_verbose_list
@@ -0,0 +1,75 @@
+#compdef -k delete-char-or-list \C-xv
+
+# You probably want to bind this to Control-D.
+
+local odf="$compconfig[description_format]"
+local omf="$compconfig[message_format]"
+local ogm="$compconfig[group_matches]"
+local oop="$compconfig[option_prefix]"
+local odo="$compconfig[describe_options]"
+local odv="$compconfig[describe_values]"
+local what nm
+
+(( $# )) || set -- ${(s.:.)compconfig[verboselist_stages]}
+
+if [[ "$BUFFER" != "$_vl_buffer" || "$*" != "$_vl_config" ]]; then
+  _vl_buffer="$BUFFER"
+  _vl_config="$*"
+  _vl_array=( "$@" )
+  _vl_index=1
+  if (( ! $#_vl_array )); then
+    [[ -n "$compconfig[option_prefix]" ]] && _vl_array=(options)
+    [[ -z "$compconfig[describe_options]" ||
+       -z "$compconfig[describe_options]" ]] &&
+        _vl_array=( "$_vl_array[@]" options-describe )
+
+    _vl_array=( "$_vl_array[@]" normal )
+  fi
+  if [[ -z "$compstate[old_list]" ]]; then
+    if (( $_vl_array[(I)normal] )); then
+      _vl_index="$_vl_array[(I)normal]"
+    else
+      _vl_array=( normal "$_vl_array[@]" )
+    fi
+  fi
+fi
+
+# If we had a possibility to say `ignore all matches added up to now',
+# we could de-comment these thigs and wouldn't have the problem that
+# if the options were already the stage `options' is a somewhat
+# irritating no-op.
+# Or maybe we make the completion functions report if they added
+# options/description one day.
+
+# while true; do
+  what="$_vl_array[_vl_index++]"
+  [[ _vl_index -gt $#_vl_array ]] && _vl_index=1
+
+  if [[ "$what" != normal ]]; then
+    [[ -z "$odf" ]] && compconfig[description_format]='---- %d'
+    [[ -z "$omf" ]] && compconfig[message_format]='---- %d'
+    [[ -z "$ogm" ]] && compconfig[group_matches]=yes
+    [[ "$what" = *options* ]] && compconfig[option_prefix]=''
+    if [[ "$what" = *describe* ]]; then
+      compconfig[describe_options]=yes
+      compconfig[describe_values]=yes
+    fi
+  fi
+
+  if [[ -n "$compstate[old_list]" ]]; then
+    nm="$_lastcomp[nmatches]"
+  else
+    nm=-1
+  fi
+
+  _main_complete
+
+#   [[ "$what" != options || compstate[nmatches] -ne nm ]] && break
+# done
+
+compconfig[description_format]="$odf"
+compconfig[message_format]="$omf"
+compconfig[group_matches]="$ogm"
+compconfig[option_prefix]="$oop"
+compconfig[describe_options]="$odo"
+compconfig[describe_values]="$odv"
diff --git a/Completion/Core/_oldlist b/Completion/Core/_oldlist
index bdf12f90c..2efc08119 100644
--- a/Completion/Core/_oldlist
+++ b/Completion/Core/_oldlist
@@ -27,13 +27,23 @@ fi
 # If this is a completion widget, and we have a completion inserted already,
 # and the compconfig key oldlist_menu is not never, then we cycle through the
 # existing list (even if it was generated by another widget).
-if [[ -n $compstate[old_insert] && $WIDGET = *complete(|-prefix|-word) &&
-  $compconfig[oldlist_menu] != never ]]; then
+
+if [[ $compconfig[oldlist_menu] = verbose &&
+      $LASTWIDGET = _verbose_list && $WIDGET != _verbose_list &&
+      -z $compstate[old_insert] &&
+      -n $compstate[old_list] ]]; then
   compstate[old_list]=keep
-  if [[ $WIDGET = *reverse* ]]; then
-    compstate[insert]=$(( compstate[old_insert] - 1 ))
+elif [[ $WIDGET = *complete(|-prefix|-word) &&
+      $compconfig[oldlist_menu] != (never|verbose) ]]; then
+  if [[ -n $compstate[old_insert] ]]; then
+    compstate[old_list]=keep
+    if [[ $WIDGET = *reverse* ]]; then
+      compstate[insert]=$(( compstate[old_insert] - 1 ))
+    else
+      compstate[insert]=$(( compstate[old_insert] + 1 ))
+    fi
   else
-    compstate[insert]=$(( compstate[old_insert] + 1 ))
+    return 1
   fi
   return 0
 fi