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

PATCH: Use (( $+functions[...] )) rather than builtin functions ... >&-



I modified some completion functions to use parameter module for
existence test of functions.

Also, this patch fix following problems.

* _cvs_log didn't exist.
* whois D<TAB> complete nothing.

Index: Completion/Base/_combination
===================================================================
RCS file: /projects/zsh/zsh/Completion/Base/_combination,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 _combination
--- Completion/Base/_combination	1999/09/22 13:33:14	1.1.1.1
+++ Completion/Base/_combination	1999/11/02 12:18:14
@@ -88,8 +88,8 @@
   fi
   tmp=( ${tmp%%$sep*} )
 
-  compadd "$@" - $tmp || { builtin functions _$key >&- && _$key "$@" }
+  compadd "$@" - $tmp || { (( $+functions[_$key] )) && "_$key" "$@" }
 else
-  builtin functions _$key >&- && _$key "$@"
+  (( $+functions[_$key] )) && "_$key" "$@"
 fi
 
Index: Completion/Core/compinit
===================================================================
RCS file: /projects/zsh/zsh/Completion/Core/compinit,v
retrieving revision 1.1.1.28
diff -u -r1.1.1.28 compinit
--- Completion/Core/compinit	1999/11/02 09:09:21	1.1.1.28
+++ Completion/Core/compinit	1999/11/02 12:18:15
@@ -389,7 +389,7 @@
 
   shift
 
-  if builtin functions "$1" >& /dev/null; then
+  if (( $+functions[$1] )); then
     "$@"
     _ret="$?"
     [[ -n "$_name" ]] && eval "${_name}=${_ret}"
Index: Completion/User/_cvs
===================================================================
RCS file: /projects/zsh/zsh/Completion/User/_cvs,v
retrieving revision 1.1.1.13
diff -u -r1.1.1.13 _cvs
--- Completion/User/_cvs	1999/10/26 15:36:14	1.1.1.13
+++ Completion/User/_cvs	1999/11/02 12:18:15
@@ -19,7 +19,7 @@
 
 # define cvs command dispatch function.
 
-builtin functions _cvs_command >&- ||
+(( $+functions[_cvs_command] )) ||
 _cvs_command () {
   typeset -A cmds
   cmds=(add " ad new "          admin " adm rcs "       annotate " ann "
@@ -45,7 +45,7 @@
 
 # define completion functions for each cvs command
 
-builtin functions _cvs_add >&- ||
+(( $+functions[_cvs_add] )) ||
 _cvs_add () {
   # "+k:m:"
   _arguments -s \
@@ -54,7 +54,7 @@
     '*:file:_cvs_files_unmaintained' \
 }
 
-builtin functions _cvs_admin >&- ||
+(( $+functions[_cvs_admin] )) ||
 _cvs_admin () {
   # "+ib::c:a:A:e:l::u::LUn:N:m:o:s:t::IqxV:k:"
   _arguments -s \
@@ -77,7 +77,7 @@
     '*:file:_cvs_files'
 }
 
-builtin functions _cvs_admin_t >&- ||
+(( $+functions[_cvs_admin_t] )) ||
 _cvs_admin_t () {
   if compset -P -; then
     _message 'descriptive text'
@@ -86,7 +86,7 @@
   fi
 }
 
-builtin functions _cvs_annotate >&- ||
+(( $+functions[_cvs_annotate] )) ||
 _cvs_annotate () {
   # "+lr:D:fR"
   _arguments -s \
@@ -96,7 +96,7 @@
     '*:file:_cvs_files'
 }
 
-builtin functions _cvs_checkout >&- ||
+(( $+functions[_cvs_checkout] )) ||
 _cvs_checkout () {
   # "+ANnk:d:flRpQqcsr:D:j:P"
   _arguments -s \
@@ -109,7 +109,7 @@
     '*:module:_cvs_modules'
 }
 
-builtin functions _cvs_commit >&- ||
+(( $+functions[_cvs_commit] )) ||
 _cvs_commit () {
   # "+nlRm:fF:r:"
   _arguments -s \
@@ -120,7 +120,7 @@
     '*:file:_cvs_files_modified'
 }
 
-builtin functions _cvs_diff >&- ||
+(( $+functions[_cvs_diff] )) ||
 _cvs_diff () {
   # "+abcdefhilnpstuw0123456789BHNRC:D:F:I:L:U:V:W:k:r:"
   _arguments -s \
@@ -169,12 +169,12 @@
     '*:file:_cvs_diff_arg'
 }
 
-builtin functions _cvs_diff_arg >&- ||
+(( $+functions[_cvs_diff_arg] )) ||
 _cvs_diff_arg () {
   _cvs_files_modified || _cvs_files
 }
 
-builtin functions _cvs_edit >&- ||
+(( $+functions[_cvs_edit] )) ||
 _cvs_edit () {
   # "+lRa:"
   _arguments -s \
@@ -183,7 +183,7 @@
     '*:file:_cvs_files'
 }
 
-builtin functions _cvs_editors >&- ||
+(( $+functions[_cvs_editors] )) ||
 _cvs_editors () {
   # "+lR"
   _arguments -s \
@@ -191,7 +191,7 @@
     '*:file:_cvs_files'
 }
 
-builtin functions _cvs_export >&- ||
+(( $+functions[_cvs_export] )) ||
 _cvs_export () {
   # "+Nnk:d:flRQqr:D:"
   _arguments -s \
@@ -203,7 +203,7 @@
     '*:module:_cvs_modules'
 }
 
-builtin functions _cvs_history >&- ||
+(( $+functions[_cvs_history] )) ||
 _cvs_history () {
   # "+Tacelow?D:b:f:m:n:p:r:t:u:x:X:z:"
   _arguments -s \
@@ -223,7 +223,7 @@
     '*:file:_cvs_files'
 }
 
-builtin functions _cvs_history_x >&- ||
+(( $+functions[_cvs_history_x] )) ||
 _cvs_history_x () {
   _values -s '' 'type' \
     'F[release]' \
@@ -239,7 +239,7 @@
     'R[A file was removed]'
 }
 
-builtin functions _cvs_import >&- ||
+(( $+functions[_cvs_import] )) ||
 _cvs_import () {
   # "+Qqdb:m:I:k:W:"
   _arguments -s \
@@ -254,22 +254,34 @@
     ':release tag:'
 }
 
-builtin functions _cvs_init >&- ||
+(( $+functions[_cvs_init] )) ||
 _cvs_init () {
   false
 }
 
-builtin functions _cvs_login >&- ||
+(( $+functions[_cvs_log] )) ||
+_cvs_log () {
+  # "+bd:hlNRr::s:tw::"
+  _arguments -s \
+    -{b,h,l,N,R,t} \
+    '-d+:dates:' \
+    '-r-:revisions:' \
+    '-s+:states:' \
+    '-w-:logins:' \
+    '*:file:_cvs_files'
+}
+
+(( $+functions[_cvs_login] )) ||
 _cvs_login () {
   false
 }
 
-builtin functions _cvs_logout >&- ||
+(( $+functions[_cvs_logout] )) ||
 _cvs_logout () {
   false
 }
 
-builtin functions _cvs_rdiff >&- ||
+(( $+functions[_cvs_rdiff] )) ||
 _cvs_rdiff () {
   # "+V:k:cuftsQqlRD:r:"
   _arguments -s \
@@ -281,7 +293,7 @@
     '*:module:_cvs_modules'
 }
 
-builtin functions _cvs_release >&- ||
+(( $+functions[_cvs_release] )) ||
 _cvs_release () {
   # "+Qdq"
   _arguments -s \
@@ -289,7 +301,7 @@
     '*:directory:_files -/'
 }
 
-builtin functions _cvs_remove >&- ||
+(( $+functions[_cvs_remove] )) ||
 _cvs_remove () {
   # "+flR"
   _arguments -s \
@@ -297,7 +309,7 @@
     '*:file:_cvs_files_removed'
 }
 
-builtin functions _cvs_status >&- ||
+(( $+functions[_cvs_status] )) ||
 _cvs_status () {
   # "+vlR"
   _arguments -s \
@@ -305,7 +317,7 @@
     '*:file:_cvs_files'
 }
 
-builtin functions _cvs_tag >&- ||
+(( $+functions[_cvs_tag] )) ||
 _cvs_tag () {
   # "+FQqlRcdr:D:bf"
   _arguments -s \
@@ -315,7 +327,7 @@
     '*:file:_cvs_files'
 }
 
-builtin functions _cvs_unedit >&- ||
+(( $+functions[_cvs_unedit] )) ||
 _cvs_unedit () {
   # "+lR"
   _arguments -s \
@@ -323,7 +335,7 @@
     '*:file:_cvs_files'
 }
 
-builtin functions _cvs_update >&- ||
+(( $+functions[_cvs_update] )) ||
 _cvs_update () {
   # "+ApPflRQqduk:r:D:j:I:W:"
   _arguments -s \
@@ -337,7 +349,7 @@
     '*:file:_cvs_files'
 }
 
-builtin functions _cvs_watch >&- ||
+(( $+functions[_cvs_watch] )) ||
 _cvs_watch () {
   if (( CURRENT == 2 )); then
     compadd on off add remove
@@ -360,7 +372,7 @@
   fi
 }
 
-builtin functions _cvs_watchers >&- ||
+(( $+functions[_cvs_watchers] )) ||
 _cvs_watchers () {
   # "+lR"
   _arguments -s \
@@ -368,17 +380,17 @@
     ':*:file:_cvs_files'
 }
 
-builtin functions _cvs_root >&- ||
+(( $+functions[_cvs_root] )) ||
 _cvs_root () {
   compadd "$@" $_cvs_roots || _files "$@" -/
 }
 
-builtin functions _cvs_tempdir >&- ||
+(( $+functions[_cvs_tempdir] )) ||
 _cvs_tempdir () {
   compadd "$@" $TMPPREFIX:h $TMPDIR /tmp
 }
 
-builtin functions _cvs_user_variable >&- ||
+(( $+functions[_cvs_user_variable] )) ||
 _cvs_user_variable () {
   if compset -P '*='; then
     _default
@@ -389,39 +401,39 @@
 
 # define completion functions for cvs global options.
 
-builtin functions _cvs_bindir >&- ||
+(( $+functions[_cvs_bindir] )) ||
 _cvs_bindir () {
   compadd "$@" /usr/local/bin || _files "$@" -/
 }
 
-builtin functions _cvs_editor >&- ||
+(( $+functions[_cvs_editor] )) ||
 _cvs_editor () {
   compadd "$@" vi
 }
 
-builtin functions _cvs_gzip_level >&- ||
+(( $+functions[_cvs_gzip_level] )) ||
 _cvs_gzip_level () {
   compadd "$@" 9
 }
 
 # define completion functions for cvs common options and arguments.
 
-builtin functions _cvs_D >&- ||
+(( $+functions[_cvs_D] )) ||
 _cvs_D () {
   compadd "$@" today yesterday week\ ago month\ ago
 }
 
-builtin functions _cvs_k >&- ||
+(( $+functions[_cvs_k] )) ||
 _cvs_k () {
   compadd "$@" kv kvl k o b v
 }
 
-builtin functions _cvs_m >&- ||
+(( $+functions[_cvs_m] )) ||
 _cvs_m () {
   _message "log message"
 }
 
-builtin functions _cvs_modules >&- ||
+(( $+functions[_cvs_modules] )) ||
 _cvs_modules () {
   local root=$CVSROOT
   [[ -f CVS/Root ]] && root=$(<CVS/Root)
@@ -435,14 +447,14 @@
   fi
 }
 
-builtin functions _cvs_revisions >&- ||
+(( $+functions[_cvs_revisions] )) ||
 _cvs_revisions () {
   compadd - ${${${(M)${(f)"$(cvs -q status -vl .)"}:#	*}##[ 	]##}%%[ 	]*}
 }
 
 # define completion functions for files maintained by cvs.
 
-builtin functions _cvs_setup_prefix >&- ||
+(( $+functions[_cvs_setup_prefix] )) ||
 _cvs_setup_prefix () {
   if [[ -prefix */ ]]; then
     qpref="${PREFIX%/*}/"
@@ -453,17 +465,17 @@
   fi
 }
 
-builtin functions _cvs_extract_directory_entries >&- ||
+(( $+functions[_cvs_extract_directory_entries] )) ||
 _cvs_extract_directory_entries () {
   entries=($entries ${${${(M)rawentries:#D/*}#D/}%%/*})
 }
 
-builtin functions _cvs_extract_file_entries >&- ||
+(( $+functions[_cvs_extract_file_entries] )) ||
 _cvs_extract_file_entries () {
   entries=($entries ${${${(M)rawentries:#/*}#/}%%/*})
 }
 
-builtin functions _cvs_extract_modifiedfile_entries >&- ||
+(( $+functions[_cvs_extract_modifiedfile_entries] )) ||
 _cvs_extract_modifiedfile_entries () {
   if [[ -n "$compconfig[cvs_disable_stat]" ]] ||
     ! { zmodload -e stat || zmodload stat }; then
@@ -478,7 +490,7 @@
   entries=($entries ${ents%%/*})
 }
 
-builtin functions _cvs_setup_allentries >&- ||
+(( $+functions[_cvs_setup_allentries] )) ||
 _cvs_setup_allentries () {
   entries=()
   if [[ -f ${pref}CVS/Entries ]]; then
@@ -489,7 +501,7 @@
   fi
 }
 
-builtin functions _cvs_setup_direntries >&- ||
+(( $+functions[_cvs_setup_direntries] )) ||
 _cvs_setup_direntries () {
   entries=()
   if [[ -f ${pref}CVS/Entries ]]; then
@@ -499,7 +511,7 @@
   fi
 }
 
-builtin functions _cvs_setup_modentries >&- ||
+(( $+functions[_cvs_setup_modentries] )) ||
 _cvs_setup_modentries () {
   entries=()
   if [[ -f ${pref}CVS/Entries ]]; then
@@ -510,7 +522,7 @@
   fi
 }
 
-builtin functions _cvs_directories >&- ||
+(( $+functions[_cvs_directories] )) ||
 _cvs_directories () {
   if [[ -d ${pref}CVS ]]; then
     _cvs_setup_direntries
@@ -520,7 +532,7 @@
   fi
 }
 
-builtin functions _cvs_files >&- ||
+(( $+functions[_cvs_files] )) ||
 _cvs_files () {
   local qpref pref entries
   _cvs_setup_prefix
@@ -532,7 +544,7 @@
   fi
 }
 
-builtin functions _cvs_files_modified >&- ||
+(( $+functions[_cvs_files_modified] )) ||
 _cvs_files_modified () {
   local qpref pref entries
   _cvs_setup_prefix
@@ -544,7 +556,7 @@
   fi
 }
 
-builtin functions _cvs_files_removed >&- ||
+(( $+functions[_cvs_files_removed] )) ||
 _cvs_files_removed () {
   local qpref pref entries
   _cvs_setup_prefix
@@ -561,7 +573,7 @@
   fi
 }
 
-builtin functions _cvs_files_unmaintained >&- ||
+(( $+functions[_cvs_files_unmaintained] )) ||
 _cvs_files_unmaintained () {
   local qpref pref entries
   _cvs_setup_prefix
Index: Completion/User/_whois
===================================================================
RCS file: /projects/zsh/zsh/Completion/User/_whois,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 _whois
--- Completion/User/_whois	1999/10/26 15:36:15	1.1.1.2
+++ Completion/User/_whois	1999/11/02 12:18:15
@@ -5,7 +5,7 @@
   $_whois_comp
 }
 
-builtin functions _whois_setup >&- ||
+(( $+functions[_whois_setup] )) ||
 _whois_setup () {
   (( $+_whois_defaultserver )) ||
     _whois_defaultserver='whois.internic.net'
@@ -64,6 +64,7 @@
   (( $+_whois_arguments )) || {
     local help="$(whois </dev/null 2>&1)"
     local tmp opt opts
+    local hostopt=-h+
 
     if [[ $help = *"user[@<whois.server>]"* ]]; then
       _whois_comp=_whois_fwhois
@@ -71,6 +72,7 @@
       _whois_comp=_whois_multi
     else
       _whois_comp=_whois_single
+      hostopt=-h
     fi
 
     _whois_arguments=()
@@ -95,9 +97,13 @@
     for opt in $tmp; do
       opts=(-${^tmp:#$opt})
       if (( $#opts )); then opts="($opts)"; else opts=; fi
-      _whois_arguments=("$_whois_arguments[@]"
-	"${opts}-${opt}[${${${(@M)_whois_servers:#*:$opt}%:?}:-specify host}]${(M)${(M)opt:#h}/h/:host:_whois_hosts}"
-      )
+      if [[ $opt = h ]]; then
+	_whois_arguments=("$_whois_arguments[@]"
+	  "${opts}${hostopt}[specify host]:host:_whois_hosts")
+      else
+	_whois_arguments=("$_whois_arguments[@]"
+	  "${opts}-${opt}[${${(@M)_whois_servers:#*:$opt}%:?}]")
+      fi
     done
   }
 }
@@ -113,7 +119,7 @@
 
   case "$state" in
   identifier)
-    if [[ -z "$QIPREFIX" ]]; then
+    if [[ -z "$QIPREFIX" && -z "$PREFIX" ]]; then
       compadd -QS '' \'
       return
     fi
@@ -125,7 +131,7 @@
         break
       fi
     done
-    if builtin functions "_whois:$host" >&-; then
+    if (( $+functions[_whois:$host] )); then
       "_whois:$host" "$expl[@]"
     else
       _message "identifier"
@@ -152,7 +158,7 @@
         break
       fi
     done
-    if builtin functions "_whois:$host" >&-; then
+    if (( $+functions[_whois:$host] )); then
       "_whois:$host" "$expl[@]"
     else
       _message "identifier"
@@ -165,13 +171,13 @@
   if compset -P '*@'; then
     _whois_hosts "$@"
   else
-    if [[ -z "$QIPREFIX" ]]; then
+    if [[ -z "$QIPREFIX" && -z "$PREFIX" ]]; then
       compadd -QS '' \'
       return
     fi
     compset -q
     host="$_whois_defaultserver"
-    if builtin functions "_whois:$host" >&-; then
+    if (( $+functions[_whois:$host] )); then
       "_whois:$host" "$@"
     else
       _message "identifier"
@@ -189,7 +195,7 @@
   compadd "$@" - whois || _ports "$@"
 }
 
-builtin functions _whois:whois.internic.net >&- ||
+(( $+functions[_whois:whois.internic.net] )) ||
 _whois:whois.internic.net () {
   if (( CURRENT == 1 )); then
     compadd HELP DOMAIN HOST
@@ -198,7 +204,7 @@
   fi
 }
 
-builtin functions _whois:whois.nic.ad.jp >&- ||
+(( $+functions[_whois:whois.nic.ad.jp] )) ||
 _whois:whois.nic.ad.jp () {
   if (( CURRENT == 1 )); then
     compadd HELP DOM NET HOST PERSON CONN COM
-- 
Tanaka Akira



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