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

Re: Generating completion functions from XML



Felix Rosencrantz wrote:

> There are more options on what flags are exclusive and equivalent,
> and many times this information has to be repeated.

Note that the exclusion lists are not necessarily repeated. An option
listed in the exclusion list is excluded after the option and there are
some commands where the exclusion is dependant on the ordering. I can't
think of much information repetition in the current _arguments syntax.

Another thing we could do is modify GNU gengetopts (which produces C
calls to getopt_long) to additionally output the basis of a completion
function. Whether they would include our change, I don't know with zsh
not being GNU.

> cvs).  There would need to be a tool which transform this intermediate  
> file format into the appropriate completion function, generating the    
> appropriate call to _arguments, _values, etc.

Have you used XSLT at all? I've used it for some things and it is quite
cunning. If you use XML, I'd recommend you try it with this
transformation in mind. I actually struggled to find a decent program to
do XSL transformations - most of the information on the web relates to
direct browser support yet it makes a lot of sense currently to use XSL
on the server side. libxslt (which needs libxml2) comes with a little
program called xsltproc which is what I have used (and I have a simple
completion for it so I've attached that).

Another thing you might want to think about is if your XML format can
somehow be flexible enough to include support for multiple languages.

It'll be interesting to see but to be honest I'm a bit doubtful that an
XML equivalent will be any easier to modify or understand that the
current script. A gui wizard might do more to easing things but then
that could use the XML. The completion functions may not have gained
much in ease of writing over compctls (and as you said this is largely
because of the provision greater functionality) but I think they are a
lot more readable. I could never remember all the compctl flags and
always needed the manual to write them whereas tcsh completes were easy.

Oliver

#compdef xsltproc

_arguments -C \
  -v --{verbose,timing,repeat,debug,novalid,noout,maxdepth} \
  '1:stylesheet:_files -g \*.xsl' \
  ':file:_files -g \*.xml'

_____________________________________________________________________
This message has been checked for all known viruses by the 
MessageLabs Virus Scanning Service. For further information visit
http://www.messagelabs.com/stats.asp



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