zsh-users
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: clemens fischer <ino-qc@spotteswoode.de.eu.org>
Cc: zsh-users@sunsite.dk
Subject: Re: bash convert: new completion system skeleton?
Date: Fri, 24 Jan 2003 12:12:48 +0100	[thread overview]
Message-ID: <1715.1043406768@finches.logica.co.uk> (raw)
In-Reply-To: <8yxj3oiq.fsf@ID-23066.news.dfncis.de>

On 17 Jan, you wrote:
> hi.
> 
> i have lots of bash completers for my daily needs that i can't live
> without.  but bash-style completers resemble zsh's old completion
> style, which is inferiour to zsh's new system.
> 
> my completers have the following properties:  the program which's
> arguments have to be completed have some help or list function which
> i can use to enumerate the possible completions, then i just grep(1)
> out the likely candidates.

> similiar code exists for gnu-make, autoconf's configure, openssl etc.

zsh has all of these (except openssl) and a lot more besides already
written. If you've done:
  autoload -U compinit; compinit
they should work automatically.

> could somebody please offer the skeleton of a completer for the new
> system, complete with which share/zsh/4.0.6/function/_<FUNC>s to
> call, how to name the zstyle and the contexts?

To convert your bash completion for zsh, at a simple level, all you
should need to do is change the $COMP_WORDS variable to $words,
$COMP_CWORD to $CURRENT and perhaps a few others. Bash returns the
matches in the $COMPREPLY array whilst zsh uses a builtin - compadd. So
putting:
  compadd - "${COMPREPLY[@]}"
at the end of your bash function will handle that.

> i'm simply lost in all the files of the distribution, especially
> those _<helper> functions.  any pointers appreciated.  is there

The helpers are just a better way of doing what bash does with the
compgen builtin. You just call _users to complete usernames or _files
to complete files. Much more readable than `compgen -f' and much more
powerful when you look in more detail.

I could easily write a function to allow zsh to use completions written
for bash:

local COMP_REPLY
local COMP_CWORD=$CURRENT
local -a COMP_WORDS
COMP_WORDS=( $words )
setopt localoptions
emulate sh
"$@"
compadd - "${COMPREPLY[@]}"

Would be enough for _qconfirm (I think). Would that be useful? Or do we
have a perl guru who can write a program to convert the function? Of
course it is better to rewrite the functions properly to make full use
of zsh's greater power.

Oliver

This e-mail and any attachment is for authorised use by the intended recipient(s) only.  It may contain proprietary material, confidential information and/or be subject to legal privilege.  It should not be copied, disclosed to, retained or used by, any other party.  If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender.  Thank you.


  parent reply	other threads:[~2003-01-24 11:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-17 13:16 clemens fischer
2003-01-24 10:37 ` Peter Stephenson
2003-01-24 10:42 ` Borzenkov Andrey
2003-01-24 11:12 ` Oliver Kiddle [this message]
2003-01-24 11:19   ` Borzenkov Andrey
2003-01-24 19:37     ` clemens fischer
2003-01-24 21:19     ` John Buttery
2003-01-27 10:08       ` Oliver Kiddle

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=1715.1043406768@finches.logica.co.uk \
    --to=okiddle@yahoo.co.uk \
    --cc=ino-qc@spotteswoode.de.eu.org \
    --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).