From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8692 invoked from network); 29 Jan 2003 14:08:47 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 29 Jan 2003 14:08:47 -0000 Received: (qmail 22777 invoked by alias); 29 Jan 2003 14:08:37 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 18156 Received: (qmail 22768 invoked from network); 29 Jan 2003 14:08:37 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 29 Jan 2003 14:08:37 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [212.125.75.12] by sunsite.dk (MessageWall 1.0.8) with SMTP; 29 Jan 2003 14:8:36 -0000 X-VirusChecked: Checked X-Env-Sender: kiddleo@logica.com X-Msg-Ref: server-6.tower-4.messagelabs.com!1043849311!2457 Received: (qmail 5160 invoked from network); 29 Jan 2003 14:08:31 -0000 Received: from iris.logica.co.uk (158.234.9.163) by server-6.tower-4.messagelabs.com with SMTP; 29 Jan 2003 14:08:31 -0000 Received: from finches.logica.co.uk ([158.234.142.11]) by iris.logica.co.uk (8.9.3/8.9.3/Debian 8.9.3-21) with ESMTP id OAA05801 for ; Wed, 29 Jan 2003 14:08:29 GMT X-Authentication-Warning: iris.logica.co.uk: Host [158.234.142.11] claimed to be finches.logica.co.uk Received: from finches.logica.co.uk (localhost [127.0.0.1]) by finches.logica.co.uk (8.11.6/8.11.6/SuSE Linux 0.5) with ESMTP id h0TEBYZ02394 for ; Wed, 29 Jan 2003 15:11:34 +0100 To: Zsh workers In-reply-to: <25651.1043838987@csr.com> From: Oliver Kiddle References: <25651.1043838987@csr.com> Subject: Re: bash completion functions Date: Wed, 29 Jan 2003 15:11:34 +0100 Message-ID: <2392.1043849494@finches.logica.co.uk> Sender: kiddleo@logica.com On 29 Jan, Peter wrote: > Oliver Kiddle wrote: > > Any ideas on where in the manual I should mention this function? It > > only needs a couple of lines. The User Contributions chapter seems to > > cover stuff in the Functions directory. Or would it be better mentioned > > in the FAQ? > > The reset of the completion system is all in the zshcompsys manual page. > I would either add a new section for odds and ends, or sneak it into the > section `Control Functions'. I've put it at the end of Control Functions which results in it being just before _bash_completions in the Bindable Commands section. The patch below also adds documentation for the styles used by _email_addresses and changes _email_addresses to use the more conventional reply array instead of ali for plugins (which I forgot to do before). Oliver Index: Completion/Unix/Type/_email_addresses =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_email_addresses,v retrieving revision 1.1 diff -u -r1.1 _email_addresses --- Completion/Unix/Type/_email_addresses 17 Jan 2003 09:23:35 -0000 1.1 +++ Completion/Unix/Type/_email_addresses 29 Jan 2003 13:57:33 -0000 @@ -7,14 +7,14 @@ # # Plugins are written as separate functions with names starting `_email-'. # They should either do their own completion or return the addresses in the -# ali array in the form 'alias:address' and return 300. The -c option is +# reply array in the form 'alias:address' and return 300. The -c option is # passed on to plugins (and -n could be if needed ever). New plugins will be # picked up and run automatically. # plugins (( $+functions[_email-mail] )) || _email-mail() { - ali=( ${${${(M)${(f)"$(<$files[$plugin])"}:#alias*}##alias[[:blank:]]##}/[[:blank:]]##/:} ) + reply=( ${${${(M)${(f)"$(<$files[$plugin])"}:#alias*}##alias[[:blank:]]##}/[[:blank:]]##/:} ) return 300 } (( $+functions[_email-mutt] )) || _email-mutt() { _email-mail } @@ -22,13 +22,13 @@ (( $+functions[_email-MH] )) || _email-MH() { - ali=( ${${(f)"$(_call_program aliases ali)"}/: /:} ) + reply=( ${${(f)"$(_call_program aliases ali)"}/: /:} ) return 300 } (( $+functions[_email-pine] )) || _email-pine() { - ali=( ${${${${${(f)"$(<~/.addressbook)"}:#*DELETED*}:#\ *}/ [^ ]# /:}%% *} ) + reply=( ${${${${${(f)"$(<~/.addressbook)"}:#*DELETED*}:#\ *}/ [^ ]# /:}%% *} ) return 300 } @@ -77,7 +77,7 @@ } _email_addresses() { - local -a plugins ali list args + local -a plugins reply list args local -A opts files local plugin rcfile expl ret fret @@ -147,17 +147,17 @@ if (( fret == 300 )); then if (( ! $+opts[-c] )) && [[ $opts[-n] = $plugin ]]; then - zformat -a list ' -- ' "${ali[@]}" + zformat -a list ' -- ' "${reply[@]}" _wanted mail-aliases expl 'alias' compadd "$@" \ - -d list - ${ali%%:*} && ret=0 + -d list - ${reply%%:*} && ret=0 else if (( $#args )); then - ali=( ${(SM)${ali#*:}##$~__addrspec} ) + reply=( ${(SM)${reply#*:}##$~__addrspec} ) else # remove lines not containing `@' as they probably aren't addresses - ali=( "${(@)${(M@)ali:#*@*}#*:}" ) + reply=( "${(@)${(M@)reply:#*@*}#*:}" ) fi - compadd -a "$@" "$expl[@]" ali && ret=0 + compadd -a "$@" "$expl[@]" reply && ret=0 fi fi done Index: Doc/Zsh/compsys.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v retrieving revision 1.162 diff -u -r1.162 compsys.yo --- Doc/Zsh/compsys.yo 27 Jan 2003 16:42:27 -0000 1.162 +++ Doc/Zsh/compsys.yo 29 Jan 2003 13:57:33 -0000 @@ -1244,6 +1244,15 @@ sorted alphabetically by name. If the value contains the string `tt(reverse)', sorting is done in decreasing order. ) +kindex(filter, completion style) +item(tt(filter))( +This is used by the LDAP plugin for e-mail address completion to specify +the attributes to match against when filtering entries. So for example, if +the style is set to `tt(sn)', matching is done against surnames. Standard +LDAP filtering is used so normal completion matching is bypassed. If this +style is not set, the LDAP plugin is skipped. You may also need to set the +tt(command) style before it can connect to your LDAP server though. +) kindex(force-list, completion style) item(tt(force-list))( This forces a list of completions to be shown at any point where listing is @@ -2091,6 +2100,13 @@ default), tt(_history_complete_word) will loop immediately as in a menu completion. ) +kindex(strip-comments, completion style) +item(tt(strip-comments))( +If set to `true', this style causes non-essential comment text to be +removed from the completion matches. Currently it is only used when +completing e-mail addresses where it removes any display name from the +addresses, cutting them down to plain var(user@host) form. +) kindex(subst-globs-only, completion style) item(tt(subst-globs-only))( This is used by the tt(_expand) completer. If it is set to `true', @@ -2855,6 +2871,14 @@ tt(COMPLETE_IN_WORD) option is set; otherwise, the cursor will be moved to the end of the current word before the completion code is called and hence there will be no suffix. +) +findex(bashcompinit) +item(tt(bashcompinit))( +This function provides compatibility with bash's programmable completion +system. When run it will define the functions, tt(compgen) and +tt(complete) which correspond to the bash builtins with the same names. It +will then be possible to use completion specifications and functions +written for bash. ) enditem() 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.