about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Kiddle <opk@users.sourceforge.net>2002-01-04 12:09:29 +0000
committerOliver Kiddle <opk@users.sourceforge.net>2002-01-04 12:09:29 +0000
commit95abfc0e2ad392a404a0a1f940951afb9aa924a2 (patch)
tree040c5483e2b2efe7795f82e1e43fbe326507c653
parentae0bba2bfca67c49e7e31a44ca7b53c85bf020d5 (diff)
downloadzsh-95abfc0e2ad392a404a0a1f940951afb9aa924a2.tar.gz
zsh-95abfc0e2ad392a404a0a1f940951afb9aa924a2.tar.xz
zsh-95abfc0e2ad392a404a0a1f940951afb9aa924a2.zip
16398: updated zstyle completion and related cleanup
-rw-r--r--ChangeLog8
-rw-r--r--Completion/Base/Utility/_regex_arguments7
-rw-r--r--Completion/Unix/Type/_directories2
-rw-r--r--Completion/Unix/Type/_file_systems2
-rw-r--r--Completion/Unix/Type/_time_zone2
-rw-r--r--Completion/Zsh/Command/_zstyle173
-rw-r--r--Doc/Zsh/compsys.yo45
-rw-r--r--Doc/Zsh/compwid.yo2
8 files changed, 172 insertions, 69 deletions
diff --git a/ChangeLog b/ChangeLog
index 259ce6d54..c2575faf7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2002-01-04  Oliver Kiddle  <opk@zsh.org>
+
+	* 16398: Completion/Zsh/Command/_zstyle, Doc/Zsh/compsys.yo,
+	Completion/Base/Utility/_regex_arguments, Doc/Zsh/compwid.yo,
+	Completion/Unix/Type/_time_zone, Completion/Unix/Type/_directories,
+	Completion/Unix/Type/_file_systems: updated zstyle completion and
+	related cleanup
+
 2002-01-03  Oliver Kiddle  <opk@zsh.org>
 
 	* 16397: Completion/Base/Widget/_complete_help: use nul as separator
diff --git a/Completion/Base/Utility/_regex_arguments b/Completion/Base/Utility/_regex_arguments
index 2ace6ba72..2e8fee8f5 100644
--- a/Completion/Base/Utility/_regex_arguments
+++ b/Completion/Base/Utility/_regex_arguments
@@ -2,13 +2,6 @@
 
 ## usage: _regex_arguments funcname regex
 
-## configuration key used:
-
-# regex_arguments_path
-#  The path to a directory for caching. (default: ~/.zsh/regex_arguments)
-
-##
-
 # _regex_arguments compiles `regex' and emits the result of the state
 # machine into the function `funcname'. `funcname' parses a command line
 # according to `regex' and evaluates appropriate actions in `regex'. Before
diff --git a/Completion/Unix/Type/_directories b/Completion/Unix/Type/_directories
index 9a1a9c1f3..cb1b3fd44 100644
--- a/Completion/Unix/Type/_directories
+++ b/Completion/Unix/Type/_directories
@@ -1,3 +1,3 @@
 #compdef rmdir df du dircmp dirs
 
-_files -/ "$@"
+_path_files -/ "$@"
diff --git a/Completion/Unix/Type/_file_systems b/Completion/Unix/Type/_file_systems
index b977ac79c..4c08dec01 100644
--- a/Completion/Unix/Type/_file_systems
+++ b/Completion/Unix/Type/_file_systems
@@ -26,7 +26,7 @@ case $OSTYPE in
   ;;
 esac
 
-_wanted types expl 'file system type' compadd "$@" -M 'L:|no=' -a fss
+_wanted fstypes expl 'file system type' compadd "$@" -M 'L:|no=' -a fss
 
 
  
diff --git a/Completion/Unix/Type/_time_zone b/Completion/Unix/Type/_time_zone
index 22d8a95d8..1ae921b61 100644
--- a/Completion/Unix/Type/_time_zone
+++ b/Completion/Unix/Type/_time_zone
@@ -6,4 +6,4 @@ if (( ! $+_zoneinfo_dirs )); then
   _zoneinfo_dirs=( /usr/{share,lib,share/lib}/{zoneinfo*,locale/TZ}(/) )
 fi
 
-_wanted timezone expl 'time zone' _files -W _zoneinfo_dirs
+_wanted time-zones expl 'time zone' _files -W _zoneinfo_dirs
diff --git a/Completion/Zsh/Command/_zstyle b/Completion/Zsh/Command/_zstyle
index d8005ee30..ffd3c6dd4 100644
--- a/Completion/Zsh/Command/_zstyle
+++ b/Completion/Zsh/Command/_zstyle
@@ -1,10 +1,25 @@
 #compdef zstyle
 
-local curcontext="$curcontext" state context ostate line expl ctop
-local nm=$compstate[nmatches] mesg
-typeset -A opt_args
+local state context ostate line expl ctop suf
+local nm=$compstate[nmatches] taglist patterns pstyles
+typeset -A opt_args styles
+
+(( $+functions[_completers] )) ||
+_completers() {
+  # option: -p - needs a `_' prefix
+  local us
+  local -a disp list expl
+  
+  list=( complete approximate correct match expand list menu oldlist
+         ignored prefix history )
+  zparseopts -D -K -E 'p=us'
+  [[ -n "$us" ]] && us='_'
+  zstyle -t ":completion:${curcontext}:completers" prefix-hidden &&
+      disp=(-d list)
+  _wanted completers expl 'completer' \
+      compadd "$@" "$disp[@]" - "$us${^list[@]}"
+}
 
-typeset -A styles
 # Assoc array of styles; the values give the possible top-level
 # contexts (currently c for completion, z for zftp or cz for both),
 # followed by a colon, followed by a state to enter, empty if none.
@@ -12,18 +27,17 @@ styles=(
   accept-exact		 c:bool
   add-space		 c:bool
   ambiguous              c:bool
-  assign-list            c:
+  assign-list            c:_parameters
   auto-description	 c:
-  avoid-completer        c:
+  avoid-completer        c:completer
   break-keys             c:
-  cache-path		 'c:_wanted directories expl directory _path_files -/'
+  cache-path		 c:_directories
   cache-policy           c:_functions
   call-command           c:bool
   command                c:command
   commands               c:
   complete               c:bool
   completer		 c:completer
-  completions		 c:bool
   condition		 c:bool
   cursor		 c:cursor
   disable-stat		 c:bool
@@ -44,7 +58,6 @@ styles=(
   hidden		 c:bool
   hosts			 c:_hosts
   hosts-ports		 c:host-port
-  users-hosts-ports	 c:user-host-port
   ignore-line            c:ignline
   ignore-parents         c:ignorepar
   ignored-patterns	 c:
@@ -62,18 +75,21 @@ styles=(
   list-separator	 c:separator
   list-suffixes		 c:bool
   local			 c:
+  mail-directory         c:_directories
   match-original	 c:match-orig
   matcher		 c:
   matcher-list		 c:
   max-errors		 c:
   menu			 c:boolauto
+  muttrc                 c:_files
   numbers		 c:bool
   old-list		 c:bool
   old-matches            c:oldmatches
   old-menu		 c:bool 
   original		 c:bool
   packageset		 c:packageset
-  path			 'c:_wanted directories expl directory _path_files -/'
+  path			 c:_directories
+  pine-directory         c:_directories
   ports			 c:_ports
   prefix-hidden		 c:bool
   prefix-needed		 c:bool
@@ -93,61 +109,80 @@ styles=(
   subst-globs-only       c:bool
   substitute		 c:bool
   suffix		 c:bool
-  tag-order		 c:tag
+  tag-order		 c:tag-order
   try-to-use-pminst	 c:bool
+  urls                   c:_urls
   use-cache		 c:bool
   use-compctl		 c:urgh
   users			 c:_users
   users-hosts		 c:user-host
+  users-hosts-ports	 c:user-host-port
   verbose		 c:bool
   word			 c:bool
 
   chpwd			 z:bool
   progress		 z:progress
-  remote_glob		 z:bool
+  remote-glob		 z:bool
   titlebar		 z:bool
   update		 z:
 )
 
-local taglist
-taglist=(accounts all-files all-expansions arguments arrays
-association-keys bookmarks builtins characters colors commands corrections
-cursors cvs default descriptions devices directories directory-stack
-displays expansions extensions files fonts functions globbed-files groups
-history-words hosts indexes jobs keymaps keysyms local-directories
-libraries limits manuals maps messages modifiers modules my-accounts
-named-directories names nicknames options original other-accounts packages
-parameters path-directories paths pods ports prefixes processes
-processes-names ps regex sequences sessions signals strings tags targets
-types urls users values warnings widgets windows zsh-options)
-
-_arguments -C ':context:->contexts' ':style:->styles' '*:argument:->style-arg'
-
-while [[ -n $state ]]; do
-  ostate=$state
-  state=
-
-  case "$ostate" in
+taglist=(
+  accounts all-expansions all-files arguments arrays association-keys
+  bookmarks builtins characters colormapids colors commands contexts
+  corrections cursors default descriptions devices directories
+  directory-stack displays expansions extensions files flags fstypes
+  fonts functions globbed-files groups history-words hosts indexes
+  interfaces jobs keymaps keysyms libraries limits local-directories
+  mailboxes manuals maps messages modifiers modules my-accounts
+  named-directories names newsgroups nicknames options original
+  other-accounts packages parameters path-directories paths pods ports
+  prefixes printers processes processes-names ps regex sequences
+  sessions signals strings styles tags targets timezones types urls
+  users values version visuals warnings widgets windows zsh-options
+)
+
+_arguments -C \
+  '(: -)-L[output in form of zstyle commands]' \
+  '(: -)-d[delete style definitions]:context pattern:->patterns:*:styles:->pstyles' \
+  '(-)-e[value is evaluated when style is looked up]' \
+  ':context:->contexts' ':style:->styles' '*:argument:->style-arg'
+
+while (( $#state )); do
+  case "$state[1]" in
     contexts)
-      if [[ $PREFIX != :*: ]]; then
+      if [[ ! -prefix :*: ]]; then
 	_wanted contexts expl context compadd -P : -S : completion zftp
-      elif [[ $PREFIX = :completion:* ]] && _tags contexts; then
-        mesg=''
-        case "$PREFIX" in
-        :completion:[^:]#) mesg=function ;;
-        :completion:[^:]#:[^:]#) mesg=completer ;;
-        :completion:[^:]#:[^:]#:[^:]#) mesg='command or context' ;;
-        :completion:[^:]#:[^:]#:[^:]#:[^:]#) mesg=argument ;;
-        :completion:[^:]#:[^:]#:[^:]#:[^:]#:[^:]#) mesg=tag ;;
-	esac
-	[[ -n "$mesg" ]] && _message "$mesg"
+      elif compset -P :completion:; then
+        for ostate in functions _completers cmdorcont argument tag; do
+	  compset -P '[^:]#:' || break
+	done
+	suf=()
+	compset -S ':*' || suf=( -qS: )
+	[[ $ostate = tag ]] && suf=()
+	if compset -P '(|\\)\((*\||)'; then  # handle (x|y) patterns
+	  suf=()
+	  compset -S '(|\\)[)|]*' ||
+	      suf=( -S "${${QIPREFIX:+|}:-\|}" -r "${${QIPREFIX:+|}:-\\\\} \t)" )
+	fi
+	state+=( "$ostate" )
       fi
       ;;
 
+    patterns)
+      zstyle -g patterns
+      _wanted contexts expl 'context pattern' compadd -a patterns
+      ;;
+    
+    pstyles)
+      zstyle -g pstyles ${(Q)${(M)opt_args[-d]#*[^\\]:}%:}
+      _wanted styles expl style compadd -a pstyles
+    ;;
+
     styles)
       # Get the top-level context we're completing for, if any.
-      if [[ $words[2] = :(completion|zftp):* ]]; then
-	ctop=${words[2][2]}
+      if [[ $line[1] = :(completion|zftp):* ]]; then
+	ctop=${line[1][2]}
       else
         ctop=cz
       fi
@@ -156,9 +191,13 @@ while [[ -n $state ]]; do
       ;;
       
     style-arg)
-      state="${styles[$words[3]]#*:}"
+      state+=( "${styles[$line[2]]#*:}" )
       ;;
 
+    argument)
+      _message argument
+      ;;
+    
     bool) 
       _wanted values expl boolean compadd true false
       ;;
@@ -167,14 +206,18 @@ while [[ -n $state ]]; do
       _wanted values expl boolean compadd true false auto select
       ;;
 
+    cmdorcont)
+      _alternative -O suf \
+        'commands:command:_command ' \
+        'contexts:context:(-array-value- -brace-parameter- -command- -condition- -math- -parameter- -redirect- -subscript- -value-)'
+     ;;
+
     cursor)
       _wanted values expl 'cursor positioning' compadd complete key default
       ;;
 
     completer)
-      _wanted values expl completer \
-	compadd _complete _approximate _correct _match \
-                _expand _list _menu _oldlist _ignored _prefix _history
+      _wanted values expl completer _completers -p
       ;;
 
     fsort)
@@ -182,6 +225,17 @@ while [[ -n $state ]]; do
 	compadd name size links time date modification access inode change reverse
       ;;
 
+    function)
+      _wanted control-function expl 'control function' \
+          compadd predict-on all-matches
+      ;;
+
+    functions)
+      _wanted comp-widget expl 'completion widget' \
+          compadd $suf - all-matches complete-tag correct-word expand-word \
+	  expand-alias-word history-words
+      ;;
+
     user-host-port)
       if [[ $PREFIX != *[@:]* ]]; then
 	_users -S @
@@ -229,13 +283,18 @@ while [[ -n $state ]]; do
       ;;
 
     tag)
-      compset -q
+      _wanted tags expl tag compadd $suf -a taglist
+      ;;
+
+    tag-order)
       if compset -P '*:*:'; then
         _message description
       elif compset -P '*:'; then
         _message 'tag alias'
       else
-        _wanted tags expl tag compadd -a taglist
+        suf=()
+        compset -S ':*' || suf=( -qS: )
+        _wanted values expl tag compadd $suf -a taglist
       fi
       ;;
 
@@ -284,7 +343,13 @@ while [[ -n $state ]]; do
       ;;
 
     fake-params)
-      _message 'name and optional type'
+      if compset -P '*:'; then
+	_wanted values expl 'parameter type' compadd scalar array integer
+      else
+        suf=''
+        compset -S ':*' || suf='-qS:'
+      	_wanted values expl 'fake parameter' _parameters $suf
+      fi
       ;;
 
     ignline) 
@@ -320,12 +385,10 @@ while [[ -n $state ]]; do
       ;;
 
     _*)
-      ${=ostate}
-      ;;
-
-    *)
+      ${=state[1]} $suf
       ;;
   esac
+  shift state
 done
 
 [[ $compstate[nmatches] != $nm ]]
diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index 8c8bd96c3..0eaf4f8c4 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -356,7 +356,7 @@ the completion system.
 itemiz(\
 The var(function); in many cases this field will be blank, but when
 the completion system is called from other functions, like
-tt(predict-on) or one of the functions in the tt(Command) directory of 
+tt(predict-on) or one of the functions in the tt(Widget) directory of 
 the distribution, this field contains the name of that function, often
 in an abbreviated form.
 )
@@ -633,6 +633,11 @@ kindex(fonts, completion tag)
 item(tt(fonts))(
 used for X font names
 )
+kindex(fstypes, completion tag)
+item(tt(fstypes))(
+used when completing the available file system types (e.g. for the
+tt(mount) command)
+)
 kindex(functions, completion tag)
 item(tt(functions))(
 names of functions, normally shell functions although certain commands may
@@ -663,6 +668,10 @@ kindex(jobs, completion tag)
 item(tt(jobs))(
 used for jobs
 )
+kindex(interfaces, completion tag)
+item(tt(interfaces))(
+for network interfaces
+)
 kindex(keymaps, completion tag)
 item(tt(keymaps))(
 for names of zsh keymaps
@@ -688,6 +697,10 @@ kindex(manuals, completion tag)
 item(tt(manuals))(
 for names of manual pages
 )
+kindex(mailboxes, completion tag)
+item(tt(mailboxes))(
+for e-mail folders
+)
 kindex(maps, completion tag)
 item(tt(maps))(
 for map names (e.g. NIS maps)
@@ -716,6 +729,10 @@ kindex(names, completion tag)
 item(tt(names))(
 for all kinds of names
 )
+kindex(newsgroups, completion tag)
+item(tt(newsgroups))(
+for USENET groups
+)
 kindex(nicknames, completion tag)
 item(tt(nicknames))(
 for nicknames of NIS maps
@@ -765,7 +782,7 @@ for prefixes (like those of a URL)
 )
 kindex(printers, completion tag)
 item(tt(printers))(
-for printer names
+for print queue names
 )
 kindex(processes, completion tag)
 item(tt(processes))(
@@ -797,6 +814,10 @@ kindex(styles, completion tag)
 item(tt(styles))(
 for styles used by the zstyle builtin command
 )
+kindex(suffixes, completion tag)
+item(tt(suffixes))(
+for filename extensions
+)
 kindex(tags, completion tag)
 item(tt(tags))(
 for tags (e.g. tt(rpm) tags)
@@ -805,6 +826,10 @@ kindex(targets, completion tag)
 item(tt(targets))(
 for makefile targets
 )
+kindex(time-zones, completion tag)
+item(tt(time-zones))(
+for time zones (e.g. when setting the tt(TZ) parameter)
+)
 kindex(types, completion tag)
 item(tt(types))(
 for types of whatever (e.g. address types for the tt(xhost) command)
@@ -827,6 +852,10 @@ item(tt(version))(
 used by tt(_call_program) to look up the command to run to determine the installed
 version of various other commands (such as tt(diff) and tt(make)).
 )
+kindex(visuals, completion tag)
+item(tt(visuals))(
+for X visuals
+)
 kindex(warnings, completion tag)
 item(tt(warnings))(
 used to look up the tt(format) style for warnings
@@ -1906,6 +1935,16 @@ aliases will never be expanded and if it is set to the string
 `tt(always)', regular aliases will be expanded even if not in command
 position.
 )
+kindex(remote-access, completion style)
+item(tt(remote-access))(
+In order to generate matches for some commands such as tt(cvs) it is
+necessary to make connections to remote systems to retrieve the
+pertinent information. If this style is set to `false' such remote
+connections will not be made. Note that in some cases, in particular
+with tt(cvs), this may also prevent connections which are actually
+local because it may not be known if a certain command will make a
+remote connection.
+)
 kindex(remove-all-dups, completion style)
 item(tt(remove-all-dups))(
 The tt(_history_complete_word) bindable command and the tt(_history)
@@ -3124,7 +3163,7 @@ be generated, the action should consist of only a space. This will make
 the var(message) be displayed but no possible completions listed. Note
 that even in this case the colon at the end of the var(message) is
 needed. The only case where it can be left is when neither a var(message),
-nor a var(action) is given.
+nor an var(action) is given.
 
 Except for the `tt(->)var(string)' form below, the var(action) will be
 executed by calling the tt(_all_labels) function to process all tag labels,
diff --git a/Doc/Zsh/compwid.yo b/Doc/Zsh/compwid.yo
index 687954cb5..a26386f09 100644
--- a/Doc/Zsh/compwid.yo
+++ b/Doc/Zsh/compwid.yo
@@ -15,7 +15,7 @@ writing their own --- see dictionary entry for `hubris') should skip this
 section.  The older system based on the tt(compctl) builtin command is
 described in
 ifzman(zmanref(zshcompctl))\
-ifnzman(the chapter noderef(Completion Using compctl)).
+ifnzman(noderef(Completion Using compctl)).
 
 Completion widgets are defined by the tt(-C) option to the tt(zle)
 builtin command provided by the tt(zsh/zle) module (see