Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Questions/comments on completion code that arise from PWS's zsh guide
- X-seq: zsh-workers 9876
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: Re: Questions/comments on completion code that arise from PWS's zsh guide
- Date: Fri, 25 Feb 2000 14:16:22 +0100 (MET)
- In-reply-to: "Bart Schaefer"'s message of Wed, 23 Feb 2000 16:17:08 +0000
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
Bart Schaefer wrote:
> Why does the users-hosts style want `user:host'? Is there a problem with
> the @ sign that I fail to see?
This changes _combination to accept a pattern after the -s
option. Then it changes the places where users-hosts is used to allow
both `user:host' and `user@host'.
Question: should we change the hosts-ports-users style to
`users-hosts-ports' and allow `user@host:port' (although that would
then also allow `user@host@port' because the separator is used for all
parts)?
Bye
Sven
diff -ru ../z.old/Completion/Base/_combination Completion/Base/_combination
--- ../z.old/Completion/Base/_combination Fri Feb 25 11:15:31 2000
+++ Completion/Base/_combination Fri Feb 25 14:07:16 2000
@@ -55,6 +55,9 @@
if [[ "$1" = -s ]]; then
sep="$2"
shift 2
+elif [[ "$1" = -s* ]]; then
+ sep="${1[3,-1]}"
+ shift
else
sep=:
fi
@@ -81,9 +84,9 @@
if zstyle -a ":completion:${curcontext}:$tag" "$style" tmp; then
eval "tmp=( \"\${(@M)tmp:#\${(j($sep))~pats}}\" )"
if (( keys[(in:num:)$key] != 1 )); then
- eval "tmp=( \${tmp#\${(j(${sep}))~\${(@)\${(@)keys[2,(rn:num:)\$key]}/*/*}}$sep} )"
+ eval "tmp=( \${tmp#\${(j(${sep}))~\${(@)\${(@)keys[2,(rn:num:)\$key]}/*/*}}${~sep}} )"
fi
- tmp=( ${tmp%%$sep*} )
+ tmp=( ${tmp%%${~sep}*} )
compadd "$@" - $tmp || { (( $+functions[_$key] )) && "_$key" "$@" }
else
diff -ru ../z.old/Completion/User/_rlogin Completion/User/_rlogin
--- ../z.old/Completion/User/_rlogin Fri Feb 25 11:15:51 2000
+++ Completion/User/_rlogin Fri Feb 25 14:07:49 2000
@@ -54,21 +54,21 @@
}
_rlogin_users () {
- _tags users && _combination my-accounts users-hosts users "$@"
+ _tags users && _combination -s '[:@]' my-accounts users-hosts users "$@"
}
_rlogin_hosts () {
_tags hosts &&
if [[ "$IPREFIX" == *@ ]]; then
- _combination my-accounts users-hosts "users=${IPREFIX/@}" hosts "$@"
+ _combination -s '[:@]' my-accounts users-hosts "users=${IPREFIX/@}" hosts "$@"
else
- _combination my-accounts users-hosts \
+ _combination -s '[:@]' my-accounts users-hosts \
${opt_args[-l]:+"users=${opt_args[-l]:q}"} hosts "$@"
fi
}
_rlogin_all_hosts () {
- _tags hosts && _combination my-accounts users-hosts hosts "$@"
+ _tags hosts && _combination -s '[:@]' my-accounts users-hosts hosts "$@"
}
_rlogin "$@"
diff -ru ../z.old/Completion/User/_ssh Completion/User/_ssh
--- ../z.old/Completion/User/_ssh Fri Feb 25 11:15:51 2000
+++ Completion/User/_ssh Fri Feb 25 14:09:23 2000
@@ -223,14 +223,14 @@
}
_ssh_users () {
- _combination my-accounts users-hosts users "$@"
+ _combination -s '[:@]' my-accounts users-hosts users "$@"
}
_ssh_hosts () {
if [[ "$IPREFIX" == *@ ]]; then
- _combination my-accounts users-hosts "users=${IPREFIX/@}" hosts "$@"
+ _combination -s '[:@]' my-accounts users-hosts "users=${IPREFIX/@}" hosts "$@"
else
- _combination my-accounts users-hosts \
+ _combination -s '[:@]' my-accounts users-hosts \
${opt_args[-l]:+"users=${opt_args[-l]:q}"} hosts "$@"
fi
}
diff -ru ../z.old/Completion/User/_user_at_host Completion/User/_user_at_host
--- ../z.old/Completion/User/_user_at_host Fri Feb 25 11:15:52 2000
+++ Completion/User/_user_at_host Fri Feb 25 14:09:55 2000
@@ -23,8 +23,8 @@
compset -P 1 '*@'
_wanted -C user-at hosts expl "host for $user" &&
- _combination "${tag}" users-hosts users="$user" hosts "$expl[@]" "$@"
+ _combination -s '[:@]' "${tag}" users-hosts users="$user" hosts "$expl[@]" "$@"
else
_wanted users expl "user" &&
- _combination "${tag}" users-hosts users -S@ -q "$expl[@]" "$@"
+ _combination -s '[:@]' "${tag}" users-hosts users -S@ -q "$expl[@]" "$@"
fi
diff -ru ../z.old/Doc/Zsh/compsys.yo Doc/Zsh/compsys.yo
--- ../z.old/Doc/Zsh/compsys.yo Fri Feb 25 11:15:16 2000
+++ Doc/Zsh/compsys.yo Fri Feb 25 14:12:59 2000
@@ -1456,7 +1456,8 @@
)
item(tt(users-hosts))(
The values of this style should be of the form
-`var(user)tt(:)var(host)'. It is used for commands that need pairs of
+`var(user)tt(@)var(host)' or `var(user)tt(:)var(host)'. It is used for
+commands that need pairs of
user- and hostnames. For such commands, only the pairs from this style
are used and if, for example, the username is already typed, then only
the hostnames for which there is a pair with that username is defined.
@@ -2637,7 +2638,7 @@
enditem()
)
findex(_combination)
-item(tt(_combination) [ tt(-s) var(spec) ] var(tag) var(style) var(specs) ... var(field) var(opts) ...)(
+item(tt(_combination) [ tt(-s) var(pattern) ] var(tag) var(style) var(specs) ... var(field) var(opts) ...)(
This function is used to complete combinations of values such as pairs
of hostnames and usernames. The possible values will be taken from the
var(style) whose name is given as the second argument. The first argument
@@ -2652,8 +2653,10 @@
The matches generated will be taken from the value of the style. These
values should contain the possible values for the combinations where
-the values for the different fields are separated by colons or the
-character given after the tt(-s) option to tt(_combination).
+the values for the different fields are separated by colons or
+characters matching the pattern given after the tt(-s) option to
+tt(_combination) (normally this is used to define character classes
+like the `tt(-s "[:@]")' used for the tt(users-hosts) style).
Only the values for the requested fields for which the patterns given
in the `var(field)tt(=)var(pattern)' match the respective fields in
--
Sven Wischnowsky wischnow@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author