zsh-users
 help / color / mirror / code / Atom feed
* cvs-like file completion
@ 2007-06-12 12:18 Chris Johnson
  2007-06-12 12:36 ` Frank Terbeck
  0 siblings, 1 reply; 5+ messages in thread
From: Chris Johnson @ 2007-06-12 12:18 UTC (permalink / raw)
  To: zsh-users

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.

Thanks for any input!

-- 
Chris Johnson
cjohnson@cs.utk.edu
http://www.cs.utk.edu/~cjohnson


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

* Re: cvs-like file completion
  2007-06-12 12:18 cvs-like file completion Chris Johnson
@ 2007-06-12 12:36 ` Frank Terbeck
  2007-06-12 12:40   ` Frank Terbeck
  2007-06-12 13:01   ` Peter Stephenson
  0 siblings, 2 replies; 5+ messages in thread
From: Frank Terbeck @ 2007-06-12 12:36 UTC (permalink / raw)
  To: zsh-users

Chris Johnson <cjohnson@cs.utk.edu>:
> 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


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

* Re: cvs-like file completion
  2007-06-12 12:36 ` Frank Terbeck
@ 2007-06-12 12:40   ` Frank Terbeck
  2007-06-12 13:01   ` Peter Stephenson
  1 sibling, 0 replies; 5+ messages in thread
From: Frank Terbeck @ 2007-06-12 12:40 UTC (permalink / raw)
  To: zsh-users

Frank Terbeck <ft@bewatermyfriend.org>:
[...]
>   % 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
[...]

Just a clarification:
You get the error, when you try completion for cvsvimdiff (without
'_cvs' being loaded), not when entering the 'compdef' command.

Regards, Frank

-- 
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


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

* Re: cvs-like file completion
  2007-06-12 12:36 ` Frank Terbeck
  2007-06-12 12:40   ` Frank Terbeck
@ 2007-06-12 13:01   ` Peter Stephenson
  2007-06-12 16:11     ` Chris Johnson
  1 sibling, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2007-06-12 13:01 UTC (permalink / raw)
  To: zsh-users

Frank Terbeck wrote:
> Chris Johnson <cjohnson@cs.utk.edu>:
> > 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"
> > 
> 
> If the cvs completion function file _cvs is already loaded (and not
> only marked for autoloading by compinit), you could do:

  autoload +X _cvs

will load the _cvs completion.

  _cvs_only_add() {
    autoload +X _cvs
    _cvs_files_unmaintained "$@"
  }
  compdef _cvs_only_add cvsvimdiff

would do the trick, E&OE.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php

To get further information regarding CSR, please visit our Investor Relations page at http://ir.csr.com/csr/about/overview


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

* Re: cvs-like file completion
  2007-06-12 13:01   ` Peter Stephenson
@ 2007-06-12 16:11     ` Chris Johnson
  0 siblings, 0 replies; 5+ messages in thread
From: Chris Johnson @ 2007-06-12 16:11 UTC (permalink / raw)
  To: zsh-users

Peter Stephenson sent me the following 1.0K:

> > > 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"
>
>   _cvs_only_add() {
>     autoload +X _cvs
>     _cvs_files_unmaintained "$@"
>   }
>   compdef _cvs_only_add cvsvimdiff

Thanks, Frank and Peter.  This works just great.  I mistyped above,
though, with the "cvs add".  I intended "cvs commit", for which I can
use the _cvs_files_modified function.

-- 
Chris Johnson
cjohnson@cs.utk.edu
http://www.cs.utk.edu/~cjohnson


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

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

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-12 12:18 cvs-like file completion Chris Johnson
2007-06-12 12:36 ` Frank Terbeck
2007-06-12 12:40   ` Frank Terbeck
2007-06-12 13:01   ` Peter Stephenson
2007-06-12 16:11     ` Chris Johnson

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).