* old or new style completion?
@ 2007-09-29 11:36 Atom Smasher
2007-09-29 12:21 ` Stephane Chazelas
0 siblings, 1 reply; 5+ messages in thread
From: Atom Smasher @ 2007-09-29 11:36 UTC (permalink / raw)
To: zsh-users
i've got a verbose copy defined as an alias in my ~/.zshrc:
alias cpv="rsync -phb --backup-dir=/tmp/rsync -e /dev/null --progress --"
this needs a completion function similar to cp (cpv file to
file-or-directory). i'm just starting to get my hands dirty with writing
my own completion functions and i'm curious...
a) if an alias or function defined in ~/.zshrc should the corresponding
completion widget/function also be in ~/.zshrc?
b) is the old style (compctl) completion system best suited to define a
completion, if it's defined in ~/.zshrc?
c) being considered an "old" style of completion, is compctl in any danger
of being deprecated? or does it still compliment the "new" completion
system?
thanks...
--
...atom
________________________
http://atom.smasher.org/
762A 3B98 A3C3 96C9 C6B7 582A B88D 52E4 D9F5 7808
-------------------------------------------------
"A criminal is a person with predatory instincts without
sufficient capital to form a corporation."
-- Howard Scott
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: old or new style completion?
2007-09-29 11:36 old or new style completion? Atom Smasher
@ 2007-09-29 12:21 ` Stephane Chazelas
2007-09-29 15:30 ` Atom Smasher
0 siblings, 1 reply; 5+ messages in thread
From: Stephane Chazelas @ 2007-09-29 12:21 UTC (permalink / raw)
To: Atom Smasher; +Cc: zsh-users
On Sat, Sep 29, 2007 at 11:36:27PM +1200, Atom Smasher wrote:
> i've got a verbose copy defined as an alias in my ~/.zshrc:
> alias cpv="rsync -phb --backup-dir=/tmp/rsync -e /dev/null --progress --"
[...]
The completion system will complete according to the expanded
text of the alias. Here, it will complete a rsync command using
the _rsync completion function.
Above it doesn't work as you'd expect because of the "--" that
seems to confuse the completion widget.
So it would seem to be a bug in the _rsync completion function.
If you ommit the "--", it seems to work OK.
Cheers,
Stéphane
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: old or new style completion?
2007-09-29 12:21 ` Stephane Chazelas
@ 2007-09-29 15:30 ` Atom Smasher
2007-09-29 15:38 ` Clint Adams
0 siblings, 1 reply; 5+ messages in thread
From: Atom Smasher @ 2007-09-29 15:30 UTC (permalink / raw)
To: zsh-users
On Sat, 29 Sep 2007, Stephane Chazelas wrote:
> The completion system will complete according to the expanded text of
> the alias. Here, it will complete a rsync command using the _rsync
> completion function.
>
> Above it doesn't work as you'd expect because of the "--" that seems to
> confuse the completion widget.
>
> So it would seem to be a bug in the _rsync completion function.
>
> If you ommit the "--", it seems to work OK.
===================
1) if the completion widget for rsync farts after the "--" option, that's
a problem with the _rsync function.
2) whether i declare "cpv" as an alias or a function, the completion
system "interprets it" as the command is rsync, not cpv. if there's no way
around that it seems like a problem with the completion system... no?
3) in this particular case, if #1 is addressed things will work fine (with
some interesting exceptions), but #2 is still a problem.
--
...atom
________________________
http://atom.smasher.org/
762A 3B98 A3C3 96C9 C6B7 582A B88D 52E4 D9F5 7808
-------------------------------------------------
"Democracy must be something more than two wolves and a sheep
voting on what to have for dinner."
-- James Bovard
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: old or new style completion?
2007-09-29 15:30 ` Atom Smasher
@ 2007-09-29 15:38 ` Clint Adams
2007-09-29 16:06 ` Atom Smasher
0 siblings, 1 reply; 5+ messages in thread
From: Clint Adams @ 2007-09-29 15:38 UTC (permalink / raw)
To: Atom Smasher; +Cc: zsh-users
On Sun, Sep 30, 2007 at 03:30:48AM +1200, Atom Smasher wrote:
> 1) if the completion widget for rsync farts after the "--" option, that's a
> problem with the _rsync function.
Yes, _rsync is broken.
> 2) whether i declare "cpv" as an alias or a function, the completion system
> "interprets it" as the command is rsync, not cpv. if there's no way around
> that it seems like a problem with the completion system... no?
You are incorrect. Try
cpv() {
rsync "$@"
}
You will not get rsync completion unless you do a "compdef _rsync cpv".
You could demand cp-like completion instead with "compdef _cp cpv",
though that would not be useful. If you are witnessing different
results, perhaps you still have your alias set.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: old or new style completion?
2007-09-29 15:38 ` Clint Adams
@ 2007-09-29 16:06 ` Atom Smasher
0 siblings, 0 replies; 5+ messages in thread
From: Atom Smasher @ 2007-09-29 16:06 UTC (permalink / raw)
To: zsh-users
On Sat, 29 Sep 2007, Clint Adams wrote:
>> 2) whether i declare "cpv" as an alias or a function, the completion
>> system "interprets it" as the command is rsync, not cpv. if there's no
>> way around that it seems like a problem with the completion system...
>> no?
>
> You are incorrect. Try cpv() { rsync "$@" }
>
> You will not get rsync completion unless you do a "compdef _rsync cpv".
> You could demand cp-like completion instead with "compdef _cp cpv",
> though that would not be useful. If you are witnessing different
> results, perhaps you still have your alias set.
=====================
yeah, i still had the alias defined; now it works fine as a function.
since cpv is rsync, but neutered to the point of only copying to/from the
local system i wouldn't want "compdef _rsync cpv", and i'm not even sure i
need "compdef _cp cpv", since the default of auto-completing directories
and files seems to work fine.
--
...atom
________________________
http://atom.smasher.org/
762A 3B98 A3C3 96C9 C6B7 582A B88D 52E4 D9F5 7808
-------------------------------------------------
"Facts are stupid things."
-- Ronald Reagan (1988)
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-09-29 16:06 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-29 11:36 old or new style completion? Atom Smasher
2007-09-29 12:21 ` Stephane Chazelas
2007-09-29 15:30 ` Atom Smasher
2007-09-29 15:38 ` Clint Adams
2007-09-29 16:06 ` Atom Smasher
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).