zsh-users
 help / color / mirror / code / Atom feed
* bash convert:  new completion system skeleton?
@ 2003-01-17 13:16 clemens fischer
  2003-01-24 10:37 ` Peter Stephenson
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: clemens fischer @ 2003-01-17 13:16 UTC (permalink / raw)
  To: zsh-users

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.

example:  there's an anti-spam system called qconfirm
<URL:http://smarden.org/qconfirm/>, the bash completer for which is:

_qconfirm ()
{
	local i cur qopts qcmd
	COMPREPLY=()
	qopts=""
	qcmd=${COMP_WORDS[1]}
        # collect possible options to hand over 1:1
	for (( i=1 ; i<=COMP_CWORD ; i++ ))
	do
		cur="${COMP_WORDS[$i]}"
		#echo $cur >&2
		case $cur in
		    -*)
			qopts="$qopts $cur"
			;;
		    *)
			qcmd=${cur}
			break
			;;
		esac
	done
        # select the database depending on the subcommand used
	case $qcmd in
	    ac*|b[ao]*|dr*)
		which=pending
		;;
	    re*|pe*)
		which=ok
		;;
	    *)
		which=ok
		;;
	esac
        # here's the meat:  list the relevant database and pick the
        # right completion
	cur=${COMP_WORDS[COMP_CWORD]}
	COMPREPLY=( $(qconfirm $qopts list "${which}" |
		cut -d" " -s -f2 |
		egrep -i "${cur}" ))
	return 0
}
# tell the completion system which function is responsible for qconfirm
complete -F _qconfirm qconfirm

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

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?

i'm simply lost in all the files of the distribution, especially
those _<helper> functions.  any pointers appreciated.  is there
already a wiki for zsh specialists and users?

  clemens


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

end of thread, other threads:[~2003-01-27 10:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-17 13:16 bash convert: new completion system skeleton? clemens fischer
2003-01-24 10:37 ` Peter Stephenson
2003-01-24 10:42 ` Borzenkov Andrey
2003-01-24 11:12 ` Oliver Kiddle
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

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