zsh-users
 help / color / mirror / code / Atom feed
* Re: Re[2]: how to customize _all_matches use?
       [not found] ` <20070616190558.ZFD20407.aamtain07-winn.ispmail.ntl.com@a.mx.sunsite.dk>
@ 2007-06-16 23:17   ` Peter Stephenson
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2007-06-16 23:17 UTC (permalink / raw)
  To: zsh-users

Vadim Zeitlin wrote:
>  It does work if I do
> 
> 	zstyle ':completion:all-matches:*' tag-order ...
> 
> but I still don't know how to limit this for cvs completion only as using
> the context of ':completion:all-matches:cvs-commit:*' doesn't work. I
> wonder if _complete_help can somehow be used to show the context for
> another completer?

The patch to _complete_help below allows you to tweak the completions as
follows:

  zle -C all-matches complete-word _complete_help
  zstyle ':completion:*' help-function _generic

Then ^xa calls _complete_help which calls _generic with the context
including all-matches.  As _generic hasn't been called at that point,
unfortunately we need a very general context for help-function, so you
need to alter the style to get this to work and then change it back or
delete it, and you need to change the definition of all-matches, too.  I
won't commit this because I've a feeling there ought to be a better way
of doing it, in particular a simple way of making it work for generic
widgets with a single keystroke.

Anyway, it gives you the following (I've wrapped some long lines):


tags in context :completion:all-matches:complete:cvs::
    argument-rest  (_arguments _cvs)
tags in context :completion:all-matches:complete:cvs-commit::
    argument-rest options  (_arguments _cvs_commit _call_function
      _cvs_command _arguments _cvs)
tags in context :completion:all-matches:complete:cvs-commit:argument-rest:
    directories existing-files removed-files  (_alternative
      _cvs_files_modified _arguments _cvs_commit _call_function
      _cvs_command _arguments _cvs) 
    directories                               (_cvs_existing_directories
      _alternative _cvs_files_modified _arguments _cvs_commit
      _call_function _cvs_command _arguments _cvs) 
    files                                     (_cvs_existing_entries
      _cvs_modified_entries _alternative _cvs_files_modified _arguments
      _cvs_commit _call_function _cvs_command _arguments _cvs) 
    files                                     (_cvs_nonexistent_entries
      _alternative _cvs_files_modified _arguments _cvs_commit
      _call_function _cvs_command _arguments _cvs)


This suggests the context is being processed OK and hence tag-order
ought to pick it up.  Did you remember the ":complete:" chunk of the
context?

Index: Completion/Base/Widget/_complete_help
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Widget/_complete_help,v
retrieving revision 1.5
diff -u -r1.5 _complete_help
--- Completion/Base/Widget/_complete_help	8 Jul 2002 08:59:40 -0000	1.5
+++ Completion/Base/Widget/_complete_help	16 Jun 2007 23:08:42 -0000
@@ -37,7 +37,9 @@
   }
   trap 'unfunction compadd zstyle' EXIT INT
 
-  _main_complete
+  zstyle -s ":completion:${curcontext}:" help-function tmp ||
+  tmp=_main_complete
+  $tmp
 
   unfunction compadd zstyle
   trap - EXIT INT


I must not reply to zsh queries at all hours of the day and night
I must not reply to zsh queries at all hours of the day and night
I must not reply to zsh queries at all hours of the day and night
I must not reply to zsh queries at all hours of the day and night

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re[2]: how to customize _all_matches use?
  2007-06-16 17:25 Peter Stephenson
@ 2007-06-16 19:05 ` Vadim Zeitlin
  0 siblings, 0 replies; 2+ messages in thread
From: Vadim Zeitlin @ 2007-06-16 19:05 UTC (permalink / raw)
  To: zsh-users

On Sat, 16 Jun 2007 18:25:58 +0100 Peter Stephenson <p.w.stephenson@ntlworld.com> wrote:

PS> The following should fix it:
PS> 
PS> zstyle ':completion:all-matches:*' insert true

 Thanks a lot Peter! With your hint it does indeed work as [I] expected.

PS> This is mentioned in the manual under the style "insert", but you have
PS> to go hunting and have some idea of what you're looking for (I actually
PS> found it by looking at the completer itself.)  The business about the
PS> completer doesn't seemed to be mentioned at all, but I have the same
PS> experience as you.  It looks like the manual needs to be updated.

 Your patch in the other message indeed makes it much more clear, thanks.

PS> >  And, of course, I don't really want to have this behaviour so much for ls
PS> > as for other commands where the completion can't be replaced with just '*'.
PS> > For example, it would be very useful to have for "cvs diff" for which I use
PS> > 
PS> > 	zstyle ':completion::complete:cvs-diff:argument-rest:' \
PS> > 		tag-order existing-files removed-files directories
PS> > 
PS> > so that pressing TAB after "cvs di" normally completes only the modified
PS> > files. But pressing ^Xa also completes the sub-directories -- is there any
PS> > way I could avoid this?
PS> 
PS> I haven't tried this, but you should still be able to use the
PS> tag-order style with all-matches.  The context will be different,
PS> though; as in the styles you quoted it should start
PS> ':completion:all-matches:'.  If it's not that obvious or nothing works,
PS> let us know.

 It does work if I do

	zstyle ':completion:all-matches:*' tag-order ...

but I still don't know how to limit this for cvs completion only as using
the context of ':completion:all-matches:cvs-commit:*' doesn't work. I
wonder if _complete_help can somehow be used to show the context for
another completer?

 Anyhow, for now I'm quite happy with setting the tag-order globally and
it's very nice to have this available. Thanks once again for your help and
the manual update (and thanks to Bart for explaining why was I getting 2
completion prompts, this was quite mysterious to me so I'm glad to know the
reason now)!
VZ


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-06-16 23:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <vz-zsh@zeitlins.org>
     [not found] ` <20070616190558.ZFD20407.aamtain07-winn.ispmail.ntl.com@a.mx.sunsite.dk>
2007-06-16 23:17   ` Re[2]: how to customize _all_matches use? Peter Stephenson
2007-06-16 17:25 Peter Stephenson
2007-06-16 19:05 ` Re[2]: " Vadim Zeitlin

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).