zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: Re: Questions/comments on completion code that arise from PWS's zsh guide
Date: Fri, 25 Feb 2000 14:16:22 +0100 (MET)	[thread overview]
Message-ID: <200002251316.OAA22789@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: "Bart Schaefer"'s message of Wed, 23 Feb 2000 16:17:08 +0000


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@informatik.hu-berlin.de


             reply	other threads:[~2000-02-25 13:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-02-25 13:16 Sven Wischnowsky [this message]
2000-02-25 16:55 ` Bart Schaefer
  -- strict thread matches above, loose matches on Subject: below --
2000-02-28  9:36 Sven Wischnowsky
2000-02-28  9:47 ` Andrej Borsenkow
2000-02-28 10:16 ` Tanaka Akira
2000-02-24  8:51 Sven Wischnowsky
2000-02-24 17:45 ` Bart Schaefer
2000-02-23 16:17 Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200002251316.OAA22789@beta.informatik.hu-berlin.de \
    --to=wischnow@informatik.hu-berlin.de \
    --cc=zsh-workers@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).