Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: bash completion functions



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.



Messages sorted by: Reverse Date, Date, Thread, Author