Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: _rlogin splits up into three functions (still one file)

On Oct 4, 11:54am, Sven Wischnowsky wrote:
} Bart Schaefer wrote:
} > 	#compdef krlogin krsh krcp
} > 	compdef ${words[1]:t:s/k/_/} ${words[1]:t}
} > 	_rlogin "$@"

I just realized that the above won't work properly unless one of the k*
forms is the first thing completed.  If _rlogin has already been auto-
loaded, call to _rlogin there is wrong.

It could be written

	[[ $functions[_rlogin] == "builtin autoload -X" ]] &&
	    _rlogin "$@" || $_comps[${words[1]:t}] "$@"

or some such, but that's pretty silly.

So ...

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

This actually sounds like a reasonable idea.  There'd have to be a way
for the #compdef tag line to register all the "services" provided by the
file in which the tag appears.  I still don't see any obvious way to
fully automate this part --

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

-- but I haven't been thinking about it for very long.

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   

Messages sorted by: Reverse Date, Date, Thread, Author