zsh-workers
 help / color / mirror / code / Atom feed
* Re: PATCH: _rlogin splits up into three functions (still one file)
@ 2000-10-04  9:54 Sven Wischnowsky
  2000-10-04 16:03 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Sven Wischnowsky @ 2000-10-04  9:54 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> For consideration (i.e., not yet committed).  This makes it a little easier
> to write a wrapper, e.g. Jay's Kerberized version could become
> 
> 	#compdef krlogin krsh krcp
> 	compdef ${words[1]:t:s/k/_/} ${words[1]:t}
> 	_rlogin "$@"
> 
> Though of course that needs to become documented before he can rely on it.

Hmhm.

This gave me the idea of adding one more (probably optional, i.e. not
used everywhere) level of indirection when mapping a command name to a 
completion function. So that _rlogin could offer the `services'
`_rlogin', `_rsh' and whatnot. And users could then just do

  compdef _rsh krsh

And the completion system would know that `_rsh' is really in the file 
`_rlogin' and the case-switch in _rlogin would use the `service' `rsh' 
is mapped to.


But maybe this is just a uglier version of what Bart suggests. But I'm 
not really happy with:

> +[[ $_comps[rsh] == _rlogin ]] && compdef _rsh rsh
> +[[ $_comps[remsh] == _rlogin ]] && compdef _rsh remsh
> +[[ $_comps[rcp] == _rlogin ]] && compdef _rcp rcp

That just cries for being automated by compdef, doesn't it?

Otherwise it looks fine, I think. I'm not yet quite sure what this
does with the control flow of, e.g., _pbm (where it is combined with a 
pattern), but, yes, looks promising.

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 3+ messages in thread
* PATCH: _rlogin splits up into three functions (still one file)
@ 2000-09-19  5:10 Bart Schaefer
  0 siblings, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 2000-09-19  5:10 UTC (permalink / raw)
  To: zsh-workers

For consideration (i.e., not yet committed).  This makes it a little easier
to write a wrapper, e.g. Jay's Kerberized version could become

	#compdef krlogin krsh krcp
	compdef ${words[1]:t:s/k/_/} ${words[1]:t}
	_rlogin "$@"

Though of course that needs to become documented before he can rely on it.

Index: Completion/User/_rlogin
===================================================================
@@ -1,15 +1,18 @@
 #compdef rlogin rsh remsh rcp
 
+[[ $_comps[rsh] == _rlogin ]] && compdef _rsh rsh
+[[ $_comps[remsh] == _rlogin ]] && compdef _rsh remsh
+[[ $_comps[rcp] == _rlogin ]] && compdef _rcp rcp
+
 _rlogin () {
-  case "${words[1]:t}" in
-  rlogin)
     _arguments -s \
       '-8[allow 8-Bit data]' \
       '-e-[specify escape character]:escape character:' \
       '-l[specify login user name]:login as:_rlogin_users' \
       ':remote host name:_rlogin_hosts'
-    ;;
-  rsh|remsh)
+}
+
+_rsh() {
     local context state line ret=1
     typeset -A opt_args
 
@@ -26,8 +29,9 @@
       _normal && ret=0
     fi
     return ret
-    ;;
-  rcp)
+}
+
+_rcp () {
     local curcontext="$curcontext" state line ret=1 expl
     typeset -A opt_args
 
@@ -49,8 +53,6 @@
       fi
     fi
     return ret
-    ;;    
-  esac
 }
 
 _rlogin_users () {
@@ -71,4 +73,4 @@
   _tags hosts && _combination -s '[:@]' my-accounts users-hosts hosts "$@"
 }
 
-_rlogin "$@"
+$_comps[${words[1]:t}] "$@"

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2000-10-04 16:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-10-04  9:54 PATCH: _rlogin splits up into three functions (still one file) Sven Wischnowsky
2000-10-04 16:03 ` Bart Schaefer
  -- strict thread matches above, loose matches on Subject: below --
2000-09-19  5:10 Bart Schaefer

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).