summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--Completion/Debian/Command/_bts206
-rw-r--r--Completion/Unix/Command/_elm21
-rw-r--r--Completion/Unix/Command/_mail21
-rw-r--r--Completion/Unix/Command/_mutt58
-rw-r--r--Completion/Unix/Command/_pine32
-rw-r--r--Completion/Unix/Type/_email_addresses172
-rw-r--r--Completion/X/Command/_mozilla12
-rw-r--r--Completion/X/Command/_netscape12
-rw-r--r--Completion/Zsh/Command/_zstyle5
10 files changed, 319 insertions, 229 deletions
diff --git a/ChangeLog b/ChangeLog
index efa4ba7bb..1c937a1fe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2003-01-17  Oliver Kiddle  <opk@zsh.org>
+
+	* 18121: Completion/Unix/Type/_email_addresses,
+	Completion/Debian/Command/_bts, Completion/Unix/Command/_elm,
+	Completion/Unix/Command/_mail, Completion/Unix/Command/_mutt,
+	Completion/Unix/Command/_pine, Completion/X/Command/_mozilla,
+	Completion/X/Command/_netscape,	Completion/Zsh/Command/_zstyle:
+	add new function for completing e-mail addresses
+
 2003-01-07  Oliver Kiddle  <opk@zsh.org>
 
 	* 18060: Completion/Zsh/Command/_zmv, Doc/Zsh/contrib.yo,
diff --git a/Completion/Debian/Command/_bts b/Completion/Debian/Command/_bts
index 61f36a841..55dac987e 100644
--- a/Completion/Debian/Command/_bts
+++ b/Completion/Debian/Command/_bts
@@ -1,118 +1,100 @@
 #compdef bts
+
 local expl
 
 compset -N '[,.]' || compset -n 2
 
-if [[ CURRENT -eq 1 ]];
-then
- _wanted cmd expl 'bts command' \
- compadd show bugs close reopen retitle reassign merge unmerge tag \
-         severity forwarded notforwarded help
-else
- case "$words[1]" in
- 	show|close|unmerge|notforwarded)
-	 if [[ CURRENT -eq 2 ]];
-	 then
-	  _wanted bugnum expl 'bug number' compadd
-	 else
-	  _wanted sep expl 'separator' compadd -S ' ' , .
-	 fi
-	;;
-	bugs)
-	 if [[ CURRENT -eq 2 ]];
-	 then
-	  _wanted package expl 'package' _deb_packages avail
-	  _wanted maintainer expl 'package maintainer' compadd $DEBEMAIL
-	 fi
-	  _wanted sep expl 'separator' compadd -S ' ' , .
-	;;
-	reopen)
-	 if [[ CURRENT -eq 2 ]];
-	 then
-	  _wanted bugnum expl 'bug number' compadd
-	 elif [[ CURRENT -eq 3 ]];
-	 then
-	  _wanted submitter expl 'new submitter' compadd $DEBEMAIL
-	 else
-	  _wanted sep expl 'separator' compadd -S ' ' , .
-	 fi
-	;;
-	retitle)
-	 if [[ CURRENT -eq 2 ]];
-	 then
-	  _wanted bugnum expl 'bug number' compadd
-	 elif [[ CURRENT -eq 3 ]];
-	 then
-	  _wanted submitter expl 'new title' compadd
-	 else
-	  _wanted sep expl 'separator' compadd -S ' ' , .
-	 fi
-	;;
-	reassign)
-	 if [[ CURRENT -eq 2 ]];
-	 then
-	  _wanted bugnum expl 'bug number' compadd
-	 elif [[ CURRENT -eq 3 ]];
-	 then
-	  _wanted submitter expl 'new package' _deb_packages avail
-	 else
-	  _wanted sep expl 'separator' compadd -S ' ' , .
-	 fi
-	;;
-	merge)
-	 _wanted bugnum expl 'bug number' compadd
-	 if [[ CURRENT -gt 2 ]];
-	 then
-	  _wanted sep expl 'separator' compadd -S ' ' , .
-	 fi
-	;;
-	tag)
-	 if [[ CURRENT -eq 2 ]];
-	 then
-	  _wanted bugnum expl 'bug number' compadd
-	 elif [[ CURRENT -eq 3 ]];
-	 then
-	  _wanted operator expl 'operator' compadd - '+' '-' '='
-	 elif [[ CURRENT -eq 4 ]];
-	 then
-	  _wanted tag expl 'tag' \
-	  compadd patch wontfix moreinfo unreproducible fixed \
-	          security potato woody sid help pending upstream \
-		  sarge experimental
-	 else
-	  _wanted tag expl 'tag' \
-	  compadd patch wontfix moreinfo unreproducible fixed \
-	          security potato woody sid help pending upstream \
-		  sarge experimental
-	  _wanted sep expl 'separator' compadd -S ' ' , .
-	 fi
-	;;
-	severity)
-	 if [[ CURRENT -eq 2 ]];
-	 then
-	  _wanted bugnum expl 'bug number' compadd
-	 elif [[ CURRENT -eq 3 ]];
-	 then
-	  _wanted severity expl 'severity' \
-	  compadd wishlist minor normal serious important critical grave
-	 else
-	  _wanted sep expl 'separator' compadd -S ' ' , .
-	 fi
-	;;
-	forwarded)
-	 if [[ CURRENT -eq 2 ]];
-	 then
-	  _wanted bugnum expl 'bug number' compadd
-	 elif [[ CURRENT -eq 3 ]];
-	 then
-	  _wanted upstream expl 'upstream email' compadd
-	 else
-	  _wanted sep expl 'separator' compadd -S ' ' , .
-	 fi
-	;;
-	help)
-	;&
-	*) _wanted sep expl 'separator' compadd -S ' ' , .
-	;;
- esac
+if [[ CURRENT -eq 1 ]]; then
+  _wanted cmd expl 'bts command' compadd show bugs close reopen retitle \
+      reassign merge unmerge tag severity forwarded notforwarded help
+  return
 fi
+
+case "$words[1]" in
+  show|close|unmerge|notforwarded)
+    if [[ CURRENT -eq 2 ]]; then
+      _message -e bugnum 'bug number'
+    else
+      _wanted sep expl 'separator' compadd -S ' ' , .
+    fi
+  ;;
+  bugs)
+    if [[ CURRENT -eq 2 ]]; then
+      _wanted package expl 'package' _deb_packages avail
+      _wanted maintainer expl 'package maintainer' compadd $DEBEMAIL
+    fi
+    _wanted sep expl 'separator' compadd -S ' ' , .
+  ;;
+  reopen)
+    if [[ CURRENT -eq 2 ]]; then
+      _message -e bugnum 'bug number'
+    elif [[ CURRENT -eq 3 ]]; then
+      _wanted submitter expl 'new submitter' compadd $DEBEMAIL
+    else
+      _wanted sep expl 'separator' compadd -S ' ' , .
+    fi
+  ;;
+  retitle)
+    if [[ CURRENT -eq 2 ]]; then
+      _message -e bugnum 'bug number'
+    elif [[ CURRENT -eq 3 ]]; then
+     _message -e submitter 'new title'
+    else
+     _wanted sep expl 'separator' compadd -S ' ' , .
+    fi
+  ;;
+  reassign)
+    if [[ CURRENT -eq 2 ]]; then
+      _message -e bugnum 'bug number'
+    elif [[ CURRENT -eq 3 ]]; then
+     _wanted submitter expl 'new package' _deb_packages avail
+    else
+     _wanted sep expl 'separator' compadd -S ' ' , .
+    fi
+  ;;
+  merge)
+    _message -e bugnum 'bug number'
+    if [[ CURRENT -gt 2 ]]; then
+     _wanted sep expl 'separator' compadd -S ' ' , .
+    fi
+  ;;
+  tag)
+    if [[ CURRENT -eq 2 ]]; then
+      _message -e bugnum 'bug number'
+    elif [[ CURRENT -eq 3 ]]; then
+      _wanted operator expl 'operator' compadd - '+' '-' '='
+    elif [[ CURRENT -eq 4 ]]; then
+      _wanted tag expl 'tag' \
+	 compadd patch wontfix moreinfo unreproducible fixed security \
+	 potato woody sid help pending upstream sarge experimental
+    else
+      _wanted tag expl 'tag' \
+	  compadd patch wontfix moreinfo unreproducible fixed security \
+	  potato woody sid help pending upstream sarge experimental
+      _wanted sep expl 'separator' compadd -S ' ' , .
+    fi
+  ;;
+  severity)
+    if [[ CURRENT -eq 2 ]]; then
+      _message -e bugnum 'bug number'
+    elif [[ CURRENT -eq 3 ]]; then
+      _wanted severity expl 'severity' \
+	  compadd wishlist minor normal serious important critical grave
+    else
+      _wanted sep expl 'separator' compadd -S ' ' , .
+    fi
+  ;;
+  forwarded)
+    if [[ CURRENT -eq 2 ]]; then
+      _message -e bugnum 'bug number'
+    elif [[ CURRENT -eq 3 ]]; then
+     _wanted upstream expl 'upstream email' _email_addresses -c
+    else
+     _wanted sep expl 'separator' compadd -S ' ' , .
+    fi
+  ;;
+  help)
+  ;&
+  *) _wanted sep expl 'separator' compadd -S ' ' , .
+  ;;
+esac
diff --git a/Completion/Unix/Command/_elm b/Completion/Unix/Command/_elm
index 34a30649c..2918a5de0 100644
--- a/Completion/Unix/Command/_elm
+++ b/Completion/Unix/Command/_elm
@@ -1,9 +1,7 @@
 #compdef elm
 
-local curcontext="$curcontext" state line expl suf
-
-_arguments -C -s \
-  '::recipient:->userhost' \
+_arguments -s \
+  '::recipient:_email_addresses' \
   '-a[use the arrow pointer regardless]' \
   '-A+[attach file]:file attachment:_files' \
   '-c[check the given aliases only]:*:alias' \
@@ -17,17 +15,4 @@ _arguments -C -s \
   '-V[enable sendmail voyeur mode]' \
   '-v[display elm version]' \
   '-w[write .elm/elmrc]' \
-  '-z[start only if new messages]' && return 0
-
-if [[ "$state" = userhost ]]; then
-  if compset -P '*@'; then
-    _description hosts expl 'remote host name'
-    _hosts "$expl[@]" && return 0
-  else
-    compset -S '@*' || suf='@'
-    _description users expl 'login name'
-    _users "$expl[@]" -q -S "$suf" && return 0
-  fi
-fi
-
-return 1
+  '-z[start only if new messages]'
diff --git a/Completion/Unix/Command/_mail b/Completion/Unix/Command/_mail
index 82a3a59d0..90c75359d 100644
--- a/Completion/Unix/Command/_mail
+++ b/Completion/Unix/Command/_mail
@@ -1,24 +1,9 @@
-#compdef mail mailx Mail mush zmail nail
+#compdef mail mailx=mail Mail=mail mush zmail nail=mail
 
-local curcontext="$curcontext" state line expl suf
-
-_arguments -C -s \
+_arguments -s \
   '(-f -u)*-b[specify a BCC recipient]:BCC recipient:->userhost' \
   '(-f -u)*-c[specify a CC recipient]:CC recipient:->userhost' \
   '(-b -c -u -s *)-f+[specify mail folder]:mailbox:_mailboxes' \
   '(-f -u)-s+[specify a subject]:subject:' \
   "(-b -c -f -s *)-u+[read specified user's mail]:user:_users" \
-  '(-f -u)*:recipient:->userhost' && return 0
-
-if [[ "$state" = userhost ]]; then
-  if compset -P '*@'; then
-    _description hosts expl 'remote host name'
-    _hosts "$expl[@]" && return 0
-  else
-    compset -S '@*' || suf='@'
-    _description users expl 'login name'
-    _users "$expl[@]" -q -S "$suf" && return 0
-  fi
-fi
-
-return 1
+  "(-f -u)*:recipient:_email_addresses -n $service"
diff --git a/Completion/Unix/Command/_mutt b/Completion/Unix/Command/_mutt
index 21e383484..c9ff98af4 100644
--- a/Completion/Unix/Command/_mutt
+++ b/Completion/Unix/Command/_mutt
@@ -1,39 +1,23 @@
 #compdef mutt
 
-local curcontext="$curcontext" state line expl suf
-typeset -A opt_args
-
-_arguments -C -s \
-    '::recipient:->userhost' \
-    '*-a[attach file using MIME]:file attachment:_files' \
-    '*-b[specify a BCC recipient]:BCC recipient:->userhost' \
-    '*-c[specify a CC recipient]:CC recipient:->userhost' \
-    '-e+[specify a post-init configuration command]:post-init configuration:' \
-    '-f+[specify mailbox to load]:mailbox: _mailboxes' \
-    '-F+[specify an init file]:init file:_files' \
-    '-h[display help]' \
-    '-H+[specify a draft file for message]:draft file:_files' \
-    '-i+[specify file to include in message]:include file:_files' \
-    '-m+[specify default mailbox type]:mailbox type:(mbox MMDF MH Maildir)' \
-    '-n[bypass system configuration]' \
-    '-p[resume postponed message]' \
-    '-R[open in read-only mode]' \
-    '-s+[specify a subject]:subject:' \
-    '-v[display mutt version]' \
-    '-x[emulate mailx compose]' \
-    '-y[start listing mailboxes]' \
-    '-z[start only if new messages]' \
-    '-Z[open first mailbox with new mail]' && return 0
-
-if [[ "$state" = userhost ]]; then
-  if compset -P '*@'; then
-    _description hosts expl 'remote host name'
-    _hosts "$expl[@]" -q -S, && return 0
-  else
-    compset -S '@*' || suf='@'
-    _description users expl 'login name'
-    _users "$expl[@]" -q -S "$suf" && return 0
-  fi
-fi
-
-return 1
+_arguments -s \
+  '::recipient:_email_addresses -n mutt' \
+  '*-a[attach file using MIME]:file attachment:_files' \
+  '*-b[specify a BCC recipient]:BCC recipient:_email_addresses -n mutt' \
+  '*-c[specify a CC recipient]:CC recipient:_email_addresses -n mutt' \
+  '-e+[specify a post-init configuration command]:post-init configuration:' \
+  '-f+[specify mailbox to load]:mailbox: _mailboxes' \
+  '-F+[specify an init file]:init file:_files' \
+  '-h[display help]' \
+  '-H+[specify a draft file for message]:draft file:_files' \
+  '-i+[specify file to include in message]:include file:_files' \
+  '-m+[specify default mailbox type]:mailbox type:(mbox MMDF MH Maildir)' \
+  '-n[bypass system configuration]' \
+  '-p[resume postponed message]' \
+  '-R[open in read-only mode]' \
+  '-s+[specify a subject]:subject:' \
+  '-v[display mutt version]' \
+  '-x[emulate mailx compose]' \
+  '-y[start listing mailboxes]' \
+  '-z[start only if new messages]' \
+  '-Z[open first mailbox with new mail]'
diff --git a/Completion/Unix/Command/_pine b/Completion/Unix/Command/_pine
index 9ee0b44c9..1902074a8 100644
--- a/Completion/Unix/Command/_pine
+++ b/Completion/Unix/Command/_pine
@@ -1,9 +1,8 @@
 #compdef pine pinef
 
-local curcontext="$curcontext" state line expl suf
 local optfile getopts='pine -conf' sortorder lusortorder opts send idx
 
-if [[ -n $+_cache_pine_options ]]; then
+if (( $#_cache_pine_options )); then
   for optfile in ~/.pinerc /etc/pine.conf; do
     if [[ -f $optfile ]]; then
       getopts="cat $optfile"
@@ -20,7 +19,7 @@ opts=( -h -v -F -conf -create_lu -pinerc -copy_abook -copy_pinerc)  # exclusive
 idx=( -f -c -i -I -n -o -sort )  # options used when viewing messages
 send=( -attach -attachlist -attach_and_delete -url )  # options when sending
 
-_arguments -C -s \
+_arguments -s \
   "($opts $idx $send -bail -d -k -z -r -p -P *)-h[display help]" \
   "($opts $idx $send -bail -d -k -z -r -p -P *)-v[display version information]" \
   "($opts $idx $send -r *)-F+[specify file to open and page through]:file:_files" \
@@ -32,7 +31,7 @@ _arguments -C -s \
   "($opts $idx -url)-attach[go directly into composer with given file]:file:_files" \
   "($opts $idx -url)-attachlist[go to composer with given files]:file:_files" \
   "($opts $idx -url)-attach_and_delete[go to composer, attach file, delete when finished]:file:_files" \
-  "($opts $idx $send)-url[open the given URL]:url:->url" \
+  "($opts $idx $send)-url[open the given URL]:url:_email_addresses -c -P mailto\:" \
   "($opts $send)-f+[specify mailbox to load]:mailbox: _mailboxes" \
   "($opts $send)-c+[specify context to apply to -f arg]: :_guard '[0-9]#' number" \
   "($opts $send)-sort[specify sort order of folder]:sort order:(${(j: :)sortorder})" \
@@ -48,26 +47,5 @@ _arguments -C -s \
   \(${(j. .)opts:#-F}')-P+[use alternate pine.conf file]:alternate pine.conf:_files' \
   \(${(j. .)opts:#-F}')-x[use configuration exceptions file]:configuration exceptions file:_files' \
   \(${(j. .)opts:#-F}")-bail[exit if pinerc file doesn't already exist]" \
-  '*::recipient:->userhost' \
-  ${^_cache_pine_options}':option value' && return 0
-
-if [[ "$state" = url ]]; then
-  if compset -P 'mailto:'; then
-    state=userhost
-  else
-    compadd -S: mailto && return 0
-  fi
-fi
-
-if [[ "$state" = userhost ]]; then
-  if compset -P '*@'; then
-    _description hosts expl 'remote host name'
-    _hosts "$expl[@]" && return 0
-  else
-    compset -S '@*' || suf='@'
-    _description users expl 'login name'
-    _users "$expl[@]" -q -S "$suf" && return 0
-  fi
-fi
-
-return 1
+  '*::recipient:_email_addresses -n pine' \
+  ${^_cache_pine_options}':option value'
diff --git a/Completion/Unix/Type/_email_addresses b/Completion/Unix/Type/_email_addresses
new file mode 100644
index 000000000..fe4f252c8
--- /dev/null
+++ b/Completion/Unix/Type/_email_addresses
@@ -0,0 +1,172 @@
+#autoload
+# options:
+#
+# -n plugin - can complete nicknames from specified plugin
+# -s sep    - complete a list of addresses separated by specified character
+# -c        - e-mail address must be of form user@host (no comments or aliases)
+#
+# 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
+# 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:]]##/:} )
+  return 300
+}
+(( $+functions[_email-mutt] )) || _email-mutt() { _email-mail }
+(( $+functions[_email-mush] )) || _email-mush() { _email-mail }
+
+(( $+functions[_email-MH] )) ||
+_email-MH() {
+  ali=( ${${(f)"$(_call_program aliases ali)"}/: /:} )
+  return 300
+}
+
+(( $+functions[_email-pine] )) ||
+_email-pine() {
+  ali=( ${${${${${(f)"$(<~/.addressbook)"}:#*DELETED*}:#\ *}/	[^	]#	/:}%%	*} )
+  return 300
+}
+
+(( $+functions[_email-ldap] )) ||
+_email-ldap() {
+  local -a expl ali res filter
+  local -A opts
+  local dn cn mail
+  
+  zparseopts -D -E -A opts c
+
+  zstyle -a ":completion:${curcontext}:$curtag" filter filter
+  (( $#filter )) || return
+  
+  filter=( "("${filter}"=${PREFIX}*${SUFFIX})" )
+  (( $#filter > 1 )) && filter="(|"${(j..)filter}")"
+  res=( ${(f)"$(_call_program $curtag ldapsearch -LLL \$filter cn mail 2>/dev/null)"} )
+  (( $#res > 1 )) || return
+
+  for dn cn mail in "${res[@]}"; do
+    if (( $+opts[-c] )); then
+      ali+=( "${mail#*: }" )
+    else
+      cn="${cn#*: }"
+      [[ $cn = *$~__specials* ]] && cn="\"$cn\""
+      ali+=( "$cn <${mail#*: }>" )
+    fi
+  done
+  compstate[insert]=menu
+  _wanted email-ldap expl 'matching names' \
+      compadd -U -i "$IPREFIX" -I "$ISUFFIX" "$@" -a - ali
+}
+
+(( $+functions[_email-local] )) ||
+_email-local() {
+  local suf opts
+  zparseopts -D -E -A opts c S:=suf
+
+  if compset -P '*@'; then
+    _hosts "$@" "$suf[@]"
+  else
+    suf=()
+    compset -S '@*' || suf=( -qS @ )
+    _users "$suf[@]" "$@"
+  fi
+}
+
+_email_addresses() {
+  local -a plugins ali list args
+  local -A opts files
+  local plugin rcfile expl ret fret
+
+  local __specialx='][()<>@,;:\\".'
+  local __spacex=" 	"				# Space, tab
+  local __specials="[$__specialx]"
+  local __atom="[^$__specialx$__spacex]##"
+  local __space="[$__spacex]#"				# Really, space or comment
+  local __qtext='[^"\\]'
+  local __qpair='\\?'
+  local __beginq='"'
+  local __endq='(|[^\\])"'
+  local __dot="$__space.$__space"
+
+  local __domainref="$__atom"
+  local __domainlit='\[([^]]|'"$__qpair"')#(|[^\\])\]'
+  local __quotedstring="$__beginq($__qtext|$__qpair)#$__endq"
+  local __word="($__atom|$__quotedstring)"
+  local __phrase="($__space$__word$__space)#"		# Strictly, should use `##'
+  local __localpart="$__word($__dot$__word)#"
+
+  local __subdomain="($__domainref|$__domainlit)"
+  local __domain="$__subdomain($__dot$__subdomain)#"
+  local __addrspec="$__localpart$__space@$__space$__domain"
+
+  local __addresses="($__qtext|$__quotedstring)##"
+
+  zparseopts -D -E -A opts n: s: c
+  set -- "$@" -M 'r:|[.@]=* r:|=* m:{a-zA-Z}={A-Za-z}'
+
+  if [[ -n $opts[-s] ]]; then
+    # remove up to the last unquoted separator
+    if [[ ${(Q)PREFIX} = (#b)($~__addresses$opts[-s])* ]]; then
+      IFS="$opts[-s]" eval 'compset -P $(( ${#${=${:-x${match[1]}x}}} - 1 )) "*${opts[-s]}"'
+    fi
+
+    # for the suffix, I'm too lazy to work out how to preserve quoted separators
+    compset -S "$opts[-s]*" || set -- -q -S "$opts[-s]" "$@"
+  fi
+
+  # get list of all plugins except any with missing config files
+  files=( mutt ~/.muttrc mush ~/.mushrc mail ${MAILRC:-~/.mailrc} pine ~/.addressbook )
+  plugins=( 
+    ${${(k)functions[(I)_email-*]#*-}:#(${(kj.|.)~files})}
+    $files(Ne:'REPLY=( ${(k)files[(r)$REPLY]} ):')
+  )
+
+  ret=1
+  _tags email-$plugins
+  while _tags; do
+    for plugin in $plugins; do
+      if _requested email-$plugin; then
+	while _next_label email-$plugin expl 'email address'; do
+
+          args=()
+	  if (( $+opts[-c] )) || zstyle -t \
+	      ":completion:${curcontext}:$curtag" strip-comments
+	  then
+	    args=( '-c' )
+	  fi
+	  
+	  if ! _call_function fret _email-$plugin "$@" $args; then
+	    _message "$plugin: plugin not found"
+	    continue
+	  fi
+	  ret=$(( ret && fret ))
+
+	  if (( fret == 300 )); then
+	    if (( ! $+opts[-c] )) && [[ $opts[-n] = $plugin ]]; then
+	      zformat -a list ' -- ' "${ali[@]}"
+	      _wanted mail-aliases expl 'alias' compadd "$@" \
+		  -d list - ${ali%%:*} && ret=0
+	    else
+	      if (( $#args )); then
+		ali=( ${(SM)${ali#*:}##$~__addrspec} )
+	      else
+		# remove lines not containing `@' as they probably aren't addresses
+		ali=( "${(@)${(M@)ali:#*@*}#*:}" )
+	      fi
+	      compadd -a "$@" "$expl[@]" ali && ret=0
+	    fi
+	  fi
+	done
+      fi
+    done
+    (( ret )) || return 0
+  done
+
+  return 1
+}
+
+_email_addresses "$@"
diff --git a/Completion/X/Command/_mozilla b/Completion/X/Command/_mozilla
index 30cfe8dc9..4f129476f 100644
--- a/Completion/X/Command/_mozilla
+++ b/Completion/X/Command/_mozilla
@@ -58,13 +58,7 @@ if [[ "$state" = "remote" ]]; then
       fi
     ;;
     mailto*)
-      compset -P "*,"
-      if compset -P '*@'; then
-        _wanted hosts expl 'remote host name' _hosts -q -S, && ret=0
-      else
-        compset -S "@*" || suf="@"
-        _wanted users expl 'login name' _users -q -S "$suf" && ret=0
-      fi
+      _email_addresses -s, -c && ret=0
     ;;
     *)
       compset -S '(|\\)\(*' || suf="${${QIPREFIX:+(}:-\(}"
@@ -83,13 +77,15 @@ if [[ "$state" = "urls" ]]; then
             license logo memory-cache mozilla plugins && ret=0
   elif compset -P news: ; then
     _newsgroups "$@" && ret=0
+  elif compset -P mailto: ; then
+    _email_addresses -c && ret=0
   else
     _tags prefixes
     while _tags; do
       while _next_label prefixes expl 'URL prefix' "$@"; do
         _urls "$expl[@]" && ret=0
 	compset -S '[^:]*'
-        compadd -S '' "$expl[@]" about: news: mocha: javascript: && ret=0
+        compadd -S '' "$expl[@]" about: news: mailto: mocha: javascript: && ret=0
       done
       (( ret )) || return 0
     done
diff --git a/Completion/X/Command/_netscape b/Completion/X/Command/_netscape
index 617ec37de..a6f9ac3fc 100644
--- a/Completion/X/Command/_netscape
+++ b/Completion/X/Command/_netscape
@@ -48,13 +48,7 @@ if [[ "$state" = "remote" ]]; then
       fi
     ;;
     mailto*)
-      compset -P "*,"
-      if compset -P '*@'; then
-        _wanted hosts expl 'remote host name' _hosts -q -S, && ret=0
-      else
-        compset -S "@*" || suf="@"
-        _wanted users expl 'login name' _users -q -S "$suf" && ret=0
-      fi
+      _email_addresses -s, -c && ret=0
     ;;
     *)
       compset -S '(|\\)\(*' || suf="${${QIPREFIX:+(}:-\(}"
@@ -77,13 +71,15 @@ if [[ "$state" = "urls" ]]; then
 	    	image-cache license logo memory-cache mozilla plugins && ret=0
       elif compset -P news: ; then
 	_newsgroups "$@" && ret=0
+      elif compset -P mailto: ; then
+        _email_addresses -c && ret=0
       else
 	_tags prefixes
 	while _tags; do
 	  while _next_label prefixes expl 'URL prefix' "$@"; do
             _urls "$expl[@]" && ret=0
 	    compset -S '[^:]*'
-            compadd -S '' "$expl[@]" about: news: mocha: javascript: && ret=0
+            compadd -S '' "$expl[@]" about: news: mailto: mocha: javascript: && ret=0
 	  done
 	  (( ret )) || return 0
 	done
diff --git a/Completion/Zsh/Command/_zstyle b/Completion/Zsh/Command/_zstyle
index e72074202..4090f0ac3 100644
--- a/Completion/Zsh/Command/_zstyle
+++ b/Completion/Zsh/Command/_zstyle
@@ -48,6 +48,7 @@ styles=(
   fake-parameters	 c:fake-params
   file-patterns		 c:filepat
   file-sort              c:fsort
+  filter		 c:
   force-list             c:
   format		 c:
   glob			 c:bool
@@ -109,6 +110,7 @@ styles=(
   squeeze-slashes	 c:bool
   stop			 c:stop
   stop-keys		 c:
+  strip-comments	 c:bool
   subst-globs-only       c:bool
   substitute		 c:bool
   suffix		 c:bool
@@ -143,6 +145,7 @@ taglist=(
   prefixes printers processes processes-names ps regex sequences
   sessions signals strings styles tags targets timezones types urls
   users values variant visuals warnings widgets windows zsh-options
+  email-address ${(k)functions[(I)_email-*]#_}
 )
 
 _arguments -C \
@@ -294,7 +297,7 @@ while (( $#state )); do
       if compset -P '*:*:'; then
         _message -e descriptions description
       elif compset -P '*:'; then
-        _message -e aliases 'tag alias'
+        _message -e labels 'tag label'
       else
         suf=()
         compset -S ':*' || suf=( -qS: )