zsh-users
 help / color / mirror / code / Atom feed
* Yes, another completion question
@ 2004-10-27 17:08 DervishD
  2004-10-27 17:27 ` Bart Schaefer
  0 siblings, 1 reply; 7+ messages in thread
From: DervishD @ 2004-10-27 17:08 UTC (permalink / raw)
  To: Zsh Users

    Hi all :)

    After playing with compsys a bit I've started to play with
compctl. Well, I don't have any doubt about compsys being more
powerful with the shipped functions but...

    What I mean is: if I just want to tweak a bit the default
completions (that is, no functions, just the default widgets) so cd
only gets directories completed and pax only tarballs, is compsys the
solution? I don't think so, but I really would like your advice.

    If I want to use compsys so 'cd' only gets directories completed
when I hit tab, I must rewrite expand-or-complete, taking into
account if I'm dealing with relative paths, absolute paths, named
directories and maybe a dozen or more additional problems, but with
compctl I just do 'compctl -/ cd' and it works.

    I'm sure that I'm wrong, but as I see the issue, compsys is only
useful with the shipped functions, because compadd is very low level
and a lot of work must be done in order to make it work as intended.
All that additional work is already done in the shipped functions,
but I don't feel like using that lot of code just to make cd complete
directories only...

    The new completion system is more configurable, more powerful,
etc. but I don't think I need all that configuration and power. In
fact I prefer the old way, with a dozen compctl commands to make my
life easier... Am I plainly wrong? Is compctl going to dissappear
soon and I should not put a minute of work in writing my compctl
recipes? Only a thicko would use compctl instead of compsys?...

    I don't want to start a flamewar 'compsys vs. compctl', just want
to know more about all that to make an oppinion.

    Thanks for all, boys :))

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736
http://www.dervishd.net & http://www.pleyades.net/


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

* Re: Yes, another completion question
  2004-10-27 17:08 Yes, another completion question DervishD
@ 2004-10-27 17:27 ` Bart Schaefer
  2004-10-27 17:49   ` DervishD
  0 siblings, 1 reply; 7+ messages in thread
From: Bart Schaefer @ 2004-10-27 17:27 UTC (permalink / raw)
  To: Zsh Users

On Wed, 27 Oct 2004, DervishD wrote:

>     The new completion system is more configurable, more powerful,
> etc. but I don't think I need all that configuration and power. In
> fact I prefer the old way, with a dozen compctl commands to make my
> life easier... Am I plainly wrong?

No, not plainly. :-)

"New completion" started out with the noble goal of replacing the rather 
arcane "compctl -x" syntax with the only somewhat less arcane but at least 
more familiar syntax of the shell language.

However, once given a system that could do more powerful things, people 
wanted to take full advantage of it. ("Gosh, if completion can do that, 
couldn't it also do this little bit of extra work too?"  Repeat until the 
"little bit" of extra work done exceeds the original effort.)  The result 
is the current compsys collection of functions.

If you're not one of the people who wants or needs all of those extra 
little bits, there's no reason to use it.  Hence "compcall" and other 
hooks for dropping from one system into the other.  Also hence the use of
autoloading for all the compsys functions, so that even if you enable the
whole thing you only load the bits you actually call upon.

> Is compctl going to dissappear soon and I should not put a minute of 
> work in writing my compctl recipes?

I don't think there's any reason that compctl will disappear -- but it's
unlikely to get any bugfixes or further improvements, either.


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

* Re: Yes, another completion question
  2004-10-27 17:27 ` Bart Schaefer
@ 2004-10-27 17:49   ` DervishD
  2004-10-27 18:49     ` DervishD
  0 siblings, 1 reply; 7+ messages in thread
From: DervishD @ 2004-10-27 17:49 UTC (permalink / raw)
  To: zsh-users

    Hi Bart :)

 * Bart Schaefer <schaefer@brasslantern.com> dixit:
> "New completion" started out with the noble goal of replacing the rather 
> arcane "compctl -x" syntax with the only somewhat less arcane but at least 
> more familiar syntax of the shell language.

    Given the possibility of -K to compctl I think I will never need
-x. Moreover, the syntax of -x is arcane, ok, but the things you must
do in order to make compadd work as desired is even bigger.

    I know, the work is already done, but using a thing as big and
complex as the function system provided with zsh makes me feel...
weird. For me compctl is cosier (if such a word exists in english).

> If you're not one of the people who wants or needs all of those extra 
> little bits, there's no reason to use it.

    I've written half a dozen of compctl commands (more or less)
since my first message and I think I already have the completion
system as I like it. Obviously, there is no reason for me to use
compsys. In fact, compinstall will need more of my time than writing
a couple more compctl commands, even if complex ones.

> > Is compctl going to dissappear soon and I should not put a minute of 
> > work in writing my compctl recipes?
> I don't think there's any reason that compctl will disappear -- but it's
> unlikely to get any bugfixes or further improvements, either.

    I haven't found any bug in compctl yet, although I haven't been
using it for a long time. Anyway, I've got a segfault with compadd...
surely fixed in 4.1.x and higher.

    Thanks for your advice, Bart, you're great :)

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736
http://www.dervishd.net & http://www.pleyades.net/


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

* Re: Yes, another completion question
  2004-10-27 17:49   ` DervishD
@ 2004-10-27 18:49     ` DervishD
  2004-10-29 15:17       ` Yet " William Scott
  0 siblings, 1 reply; 7+ messages in thread
From: DervishD @ 2004-10-27 18:49 UTC (permalink / raw)
  To: zsh-users

    Hi Bart :)

 * DervishD <zsh@dervishd.net> dixit:
> > I don't think there's any reason that compctl will disappear -- but it's
> > unlikely to get any bugfixes or further improvements, either.
>     I haven't found any bug in compctl yet, although I haven't been
> using it for a long time. Anyway, I've got a segfault with compadd...
> surely fixed in 4.1.x and higher.

    I don't know if it's a bug, but no matter if I try with a
function, a variable or a literal array I cannot get 'compctl -y' to
work. For example:

    function lista () {
        reply=(one two three)
    }

    compctl -f -y lista ls

    And 'ls <TAB>' doesn't show the list. In fact, it doesn't show
any list. Same result with 

    compctl -f -y '(one two three)' ls

    and

    lista=(one two three)
    compctl -f -y '$lista' ls

    But this works:

    compctl -f -y '(one)' ls

    Shows 'one' instead of the list of completions, but nothing more :?

    Is this a known bug? I'm tempted with writing my own shell
functions for completions and using compsys (it is maintained after
all) but I'm afraid I lack the needed knowledge... Anyway.

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736
http://www.dervishd.net & http://www.pleyades.net/


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

* Yet another completion question
  2004-10-27 18:49     ` DervishD
@ 2004-10-29 15:17       ` William Scott
  2004-11-01 12:42         ` DervishD
  0 siblings, 1 reply; 7+ messages in thread
From: William Scott @ 2004-10-29 15:17 UTC (permalink / raw)
  To: DervishD; +Cc: zsh-users

Hi Folks:

I have a completion that works in the old form and would like
to write a completion function.  This is for a command called
"open" on Apple OS X.

eg: open -a Netscape

is the functional equivalent of clicking on the Netscape application,

eg:  open -a Microsoft\ Word

opens the devil's ware, etc.

I have a function that produces a list of applications, complete with
escaped spaces, like this:

Microsoft\ Word
NFS\ Manager
Nemo_invoker
NetInfo\ Manager
NetRestore
NetRestore\ Helper
Netscape


and I am using compctl to read in a file it produces, since this takes
awhile to produce:

 compctl -f  -x 'c[-1,-a] p[2,2]' -s "$(cat ~/.zshapplist)" \
          -M 'm:{A-Za-z}={a-zA-Z} r: ||[^ ]=**' -- open

This works.  I figured out the -s was critical to getting this to
work right with the applications having escaped spaces.

But what I would like to do is use the new completion system and cache
these completions in the proper z-shell manner.


I can't seem to figure out how to use compadd syntax in analogy to the -s
option of compctl.

I would be grateful for any and all suggestions.

Bill Scott


William G. Scott

Associate Professor
Department of Chemistry and Biochemistry
and The Center for the Molecular Biology of RNA
Sinsheimer Laboratories
University of California at Santa Cruz
Santa Cruz, California 95064
USA


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

* Re: Yet another completion question
  2004-10-29 15:17       ` Yet " William Scott
@ 2004-11-01 12:42         ` DervishD
  2004-11-01 13:13           ` William Scott
  0 siblings, 1 reply; 7+ messages in thread
From: DervishD @ 2004-11-01 12:42 UTC (permalink / raw)
  To: William Scott; +Cc: zsh-users

    Hi William :)

 * William Scott <wgscott@chemistry.ucsc.edu> dixit:
> I have a completion that works in the old form and would like
> to write a completion function.
[...]
> and I am using compctl to read in a file it produces, since this takes
> awhile to produce:
> 
>  compctl -f  -x 'c[-1,-a] p[2,2]' -s "$(cat ~/.zshapplist)" \
>           -M 'm:{A-Za-z}={a-zA-Z} r: ||[^ ]=**' -- open
> 
> This works.  I figured out the -s was critical to getting this to
> work right with the applications having escaped spaces.
> 
> But what I would like to do is use the new completion system and cache
> these completions in the proper z-shell manner.

    I'm NOT an expert in completion. In fact, I'm NOT even a NEWBIE.
I'll just tell you what I would do. If your compctl code works, keep
on using it. If, by all means, you really want to write that code in
the compsys way, do it at the higher level possible, using _arguments
and the like, but don't use compadd directly. Otherwise you will need
to write a lot more of code just to make compadd work as compctl
worked, and all that code is already written for you thanks to zsh
developers and contributors. There is no real point in rewriting code
written by clever programmers, unless you're (as I am) pathologically
impulsed to do so O:)))

    Probably you will be able to rewrite your compctl recipe using
the new system in a couple of lines of code if you use the higher
level functions (_wanted, _arguments, etc.). I don't know how to use
them, but AFAIK they are documented properly in the zsh user's
manual.

> I can't seem to figure out how to use compadd syntax in analogy to the -s
> option of compctl.

    You don't need it: when you're writing a shell function to do the
completion, if compsys doesn't have already one that suits you to do
the same job, you can simply use shell constructions to do the job,
create a list (an array will do) and use compadd to add such list to
the completion list.

    BTW: do you really need -s? won't you get the same result with
'-k'?

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736
http://www.dervishd.net & http://www.pleyades.net/


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

* Re: Yet another completion question
  2004-11-01 12:42         ` DervishD
@ 2004-11-01 13:13           ` William Scott
  0 siblings, 0 replies; 7+ messages in thread
From: William Scott @ 2004-11-01 13:13 UTC (permalink / raw)
  To: DervishD; +Cc: William Scott, zsh-users


Dear Raul:

It turns out Motoi Washida has written a very nice set of OS X completion
fuctions that are in the zsh CVS, so no point in me reinventing the wheel.

>
>     BTW: do you really need -s? won't you get the same result with
> '-k'?

No, because of the blasted spaces that have to be escaped.

Anyway, the question is moot now.

Many thanks for your advice.

Bill




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

end of thread, other threads:[~2004-11-01 13:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-27 17:08 Yes, another completion question DervishD
2004-10-27 17:27 ` Bart Schaefer
2004-10-27 17:49   ` DervishD
2004-10-27 18:49     ` DervishD
2004-10-29 15:17       ` Yet " William Scott
2004-11-01 12:42         ` DervishD
2004-11-01 13:13           ` William Scott

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