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

Re: cvs-like file completion



Chris Johnson <cjohnson@xxxxxxxxxx>:
> Hi.  Anyone familiar with the intimacies of completion know how I could
> make completion work like it does after "cvs add", but for a custom
> shell script?
> 
> That is, I want to complete for a script cvsvimdiff all files that need
> committing to the cvs repository.  Something like:
> 
>    compdef cvsvimdiff="cvs add"
> 
> This isn't legal, of course, but that's the idea.

If the cvs completion function file _cvs is already loaded (and not
only marked for autoloading by compinit), you could do:

  % compdef _cvs_files_unmaintained cvsvimdiff

That means, if you didn't use '_cvs' completion yet, you will get:

(eval):1: command not found: _cvs_files_unmaintained

To cure this, use '_cvs' by doing '_cvs add <TAB>', or source the
'_cvs' file by hand (and ignore the error message):

[snip]
% source /usr/share/zsh/4.3.4/functions/Completion/Unix/_cvs
_arguments:comparguments:303: can only be called from completion function
[snap]

Note, that AFAICS this only works, because '_cvs' creates a function,
that is dedicated to the task of finding uncommited files. For other
commands, this idea might not work.

Regards, Frank

PS: I don't know if there are better solutions for this problem. :-)

-- 
In protocol design, perfection has been reached not when there is
nothing left to add, but when there is nothing left to take away.
                                                  -- RFC 1925



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