Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: updated _zstyle and cleanup of related stuff
- X-seq: zsh-workers 16398
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: PATCH: updated _zstyle and cleanup of related stuff
- Date: Fri, 04 Jan 2002 12:02:18 +0000
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- Sender: kiddleo@xxxxxxxxxxxxxxxxx
The lack of useful completion after zstyle -d was annoying me so this
adds that. I also made the completion of new contexts more useful with
completions for each component. (x|y) style patterns are handled. I'd
like to do something better after things like :*: though.
Then, I've done a general clean-up of a number of style/tag things. The
`completions' tag doesn't seem to exist anymore though compinstall
(which I've not touched) still offers to create it. I've documented the
remote-access style but would appreciate if someone could check it as I
may be wrong. And, I've documented a few more tags.
Oliver
Index: Completion/Base/Utility/_regex_arguments
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Utility/_regex_arguments,v
retrieving revision 1.2
diff -u -r1.2 _regex_arguments
--- Completion/Base/Utility/_regex_arguments 2001/05/29 17:54:08 1.2
+++ Completion/Base/Utility/_regex_arguments 2002/01/04 11:41:54
@@ -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
Index: Completion/Zsh/Command/_zstyle
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Command/_zstyle,v
retrieving revision 1.4
diff -u -r1.4 _zstyle
--- Completion/Zsh/Command/_zstyle 2001/07/25 12:18:24 1.4
+++ Completion/Zsh/Command/_zstyle 2002/01/04 11:41:54
@@ -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 @@
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 @@
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 @@
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 @@
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=
+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
+)
- case "$ostate" in
+_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 @@
;;
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 @@
_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 @@
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 @@
;;
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 @@
;;
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 @@
;;
_*)
- ${=ostate}
- ;;
-
- *)
+ ${=state[1]} $suf
;;
esac
+ shift state
done
[[ $compstate[nmatches] != $nm ]]
Index: Completion/Unix/Type/_directories
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_directories,v
retrieving revision 1.2
diff -u -r1.2 _directories
--- Completion/Unix/Type/_directories 2001/08/06 14:42:04 1.2
+++ Completion/Unix/Type/_directories 2002/01/04 11:41:54
@@ -1,3 +1,3 @@
#compdef rmdir df du dircmp dirs
-_files -/ "$@"
+_path_files -/ "$@"
Index: Completion/Unix/Type/_file_systems
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_file_systems,v
retrieving revision 1.1
diff -u -r1.1 _file_systems
--- Completion/Unix/Type/_file_systems 2001/12/11 15:46:22 1.1
+++ Completion/Unix/Type/_file_systems 2002/01/04 11:41:54
@@ -26,7 +26,7 @@
;;
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
Index: Completion/Unix/Type/_time_zone
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_time_zone,v
retrieving revision 1.2
diff -u -r1.2 _time_zone
--- Completion/Unix/Type/_time_zone 2001/11/02 12:28:31 1.2
+++ Completion/Unix/Type/_time_zone 2002/01/04 11:41:54
@@ -6,4 +6,4 @@
_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
Index: Doc/Zsh/compsys.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v
retrieving revision 1.137
diff -u -r1.137 compsys.yo
--- Doc/Zsh/compsys.yo 2001/10/10 20:10:44 1.137
+++ Doc/Zsh/compsys.yo 2002/01/04 11:41:55
@@ -356,7 +356,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
)
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 @@
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 @@
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 @@
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 @@
`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 @@
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,
Index: Doc/Zsh/compwid.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compwid.yo,v
retrieving revision 1.32
diff -u -r1.32 compwid.yo
--- Doc/Zsh/compwid.yo 2001/07/25 10:45:59 1.32
+++ Doc/Zsh/compwid.yo 2002/01/04 11:41:55
@@ -15,7 +15,7 @@
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
This email has been scanned for all viruses by the MessageLabs SkyScan service. For more information on a pro-active anti-virus service working around the clock, around the globe visit http://www.messagelabs.com/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author