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

Re: adding the original string as a completion match

Sven Wischnowsky wrote:
> Something like _all_matches is problematic because whether menu
> completion is to be used is decided very late, after all the
> completers have been called.  It would be easier to add a style tested
> by _main_complete itself saying whether the original string should be
> added as a match or only as a description.  Other function could

Looking at where in _main_complete I would need to add this, it seems
that it could be done with a post function setup from a completer which
would be like _all_matches. Your suggestion is probably better though.

I tried this:

  if [[ $compstate[insert] = *menu* && "$compstate[nmatches]" -gt 1 &&
      -n $PREFIX$SUFFIX ]]; then
    _description -V original expl original
    compadd "$expl[@]" -U -Q - "$PREFIX$SUFFIX"

There needs to be more things in the if condition though. In
particular, it has problems when the matches added are added after part
of PREFIX will have been moved to IPREFIX, e.g. cd Mail/<tab> results
in the slash being removed. Any idea on how to get it working or if it
is even possible? If not, I'll commit the _match change instead.

> > And another question, is there any way with _all_matches that I can get
> > it to just insert all the matches and never list all the things which

> There should be a possibility for this by setting compstate[insert]=-1
> after _all_matches added that all-matches-match.  Haven't tried,
> though...

That didn't seem to work but compstate[insert]=all does the job. Hence
the following patch.

Thanks Sven.


Index: Completion/Base/Completer/_all_matches
RCS file: /cvsroot/zsh/zsh/Completion/Base/Completer/_all_matches,v
retrieving revision 1.1
diff -u -r1.1 _all_matches
--- Completion/Base/Completer/_all_matches	2 Apr 2001 11:05:27 -0000	1.1
+++ Completion/Base/Completer/_all_matches	28 Mar 2002 16:53:05 -0000
@@ -33,8 +33,12 @@
   if [[ "$compstate[nmatches]" -gt 1 && $not[(I)(|_)$_completer] -eq 0 ]]; then
     local expl
-    _description all-matches expl 'all matches'
-    compadd "$expl[@]" -C
+    if zstyle -t "$_all_matches_context" insert; then
+      compstate[insert]=all
+    else
+      _description all-matches expl 'all matches'
+      compadd "$expl[@]" -C
+    fi
   unset _all_matches_context
Index: Doc/Zsh/compsys.yo
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v
retrieving revision 1.152
diff -u -r1.152 compsys.yo
--- Doc/Zsh/compsys.yo	27 Mar 2002 16:10:11 -0000	1.152
+++ Doc/Zsh/compsys.yo	28 Mar 2002 16:53:06 -0000
@@ -1461,6 +1461,11 @@
 tt(EXTENDED_GLOB) option is in effect, so the characters `tt(#)',
 `tt(~)' and `tt(^)' have special meanings in the patterns.
+kindex(insert, completion style)
+This style is used by the tt(_all_matches) completer to decide whether to
+insert the list of all matches instead of adding it as another match.
 kindex(insert-ids, completion style)
 When completing process IDs, for example as arguments to the tt(kill) and

This e-mail and any attachment is for authorised use by the intended recipient(s) only.  It may contain proprietary material, confidential information and/or be subject to legal privilege.  It should not be copied, disclosed to, retained or used by, any other party.  If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender.  Thank you.

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