Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: _history_complete_word



I think _history_complete_word could use the new tag label stuff, too.


There is something in this function I don't understand:

There is always one match inserted immediately. That's ok for a
function like this, but why does _h_c_w then test for
`$compstate[insert] = menu'? It means that this is almost unusable
without normally using menucompletion (one can't cycle through the
matches).

Or did setting compstate[insert] to a number once start menucompletion 
so that it reported `menu' in $compstate[insert] on the next
invocation? But we can test it with $compstate[old_insert] now.

No patch for this, because I'm not completely sure which behaviour is
desired.


Bye
 Sven

diff -ru ../z.old/Completion/Commands/_history_complete_word Completion/Commands/_history_complete_word
--- ../z.old/Completion/Commands/_history_complete_word	Fri Mar 31 09:19:24 2000
+++ Completion/Commands/_history_complete_word	Fri Mar 31 09:57:06 2000
@@ -67,30 +67,26 @@
 }
 
 _history_complete_word_gen_matches () {
-  if zstyle -t ":completion:${curcontext}:history-words" list; then
-    if zstyle -t ":completion:${curcontext}:history-words" sort; then
-      _description history-words expl 'history word'
-    else
-      _description -V history-words expl 'history word'
-    fi
-  else
-    if zstyle -t ":completion:${curcontext}:history-words" sort; then
-      expl=()
-    else
-      expl=('-V' '')
-    fi
-  fi
+  local opt
 
   [[ -n "$_hist_stop" ]] && PREFIX="$_hist_old_prefix"
 
-  local rem_dups
   if zstyle -t ":completion:${curcontext}:history-words" remove-all-dups; then
-    rem_dups=''
+    opt=-
   else
-    rem_dups='-1'
+    opt=-1
   fi
+  if zstyle -t ":completion:${curcontext}:history-words" sort; then
+    opt="${opt}J"
+  else
+    opt="${opt}V"
+  fi
+
+  _wanted "$opt" history-words expl 'history word' \
+      compadd -Q - "$historywords[@]"
 
-  compadd "$expl[@]" $rem_dups -Q - "${(@)historywords:#[\$'\"]*}"
+  zstyle -t ":completion:${curcontext}:history-words" list ||
+      compstate[list]=
 
   _hist_menu_length="$compstate[nmatches]"
 

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author