zsh-users
 help / color / mirror / code / Atom feed
From: DervishD <zsh@dervishd.net>
To: William Scott <wgscott@chemistry.ucsc.edu>
Cc: zsh-users@sunsite.dk
Subject: Re: Yet another completion question
Date: Mon, 1 Nov 2004 13:42:37 +0100	[thread overview]
Message-ID: <20041101124237.GA16236@DervishD> (raw)
In-Reply-To: <Pine.GSO.4.43.0410290808140.9882-100000@hydrogen.ucsc.edu>

    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/


  reply	other threads:[~2004-11-01 12:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-27 17:08 Yes, " 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 [this message]
2004-11-01 13:13           ` William Scott

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20041101124237.GA16236@DervishD \
    --to=zsh@dervishd.net \
    --cc=wgscott@chemistry.ucsc.edu \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).