zsh-workers
 help / color / mirror / code / Atom feed
* Generating completion functions from XML
@ 2001-07-19  1:52 Felix Rosencrantz
  2001-07-19  8:56 ` Sven Wischnowsky
  0 siblings, 1 reply; 9+ messages in thread
From: Felix Rosencrantz @ 2001-07-19  1:52 UTC (permalink / raw)
  To: zsh-workers

Recently there was discussion about how it is harder to create new      
completion functions under the new completion system than the old.      
The new system is easier to use as installed, since there are so many   
great completion functions available, and those do a much better job at 
completion than anything before.                                        

Part of the problem is the new system provides much more functionality. 
To do a good job, it takes more than just listing the flags to          
_arguments, now there is help to provide for the each flag, and then    
help for the flag value.  There are more options on what flags are      
exclusive and equivalent, and many times this information has to be     
repeated.                                                               

It still has been bothering me that it is not easier to create new      
completions.  I've thought about writing shell/perl/python/* scripts    
that could attempt to make good guesses based on usage information or   
man pages, and generate the appropriate _arguments call. (_arguments    
can already do this at runtime with GNU getopts like output.)           

But I suspect any scripts would still hit some sort of 90/10 rule.      
It'll get you 90% of the way but there will still be the final 10%      
which will have to be done manually.                                    

So I feared having to look at partially wrong _arguments calls.  That   
command has a lot of syntactic sugar and there is more on the way (e.g. 
recent changes).  It's not easy for me to remember what each special    
character and grouping does.                                            

It occurred to me that having an intermediate file format would be a    
good idea.  Possibly something that would be a little more descriptive, 
maybe even interspersed with comments and documentation (both from      
zsh & the command).  Also it should be easier to edit.  Also, it        
should make it easier to specify commands that have subcommands (e.g.   
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.  Also, as the syntax to   
_arguments changed it would be possible to change this generation tool, 
and then regenerate the completion function.  Maybe even _arguments     
could even take this intermediate format file as input.                 

To me it seemed like XML would be a good format to use for this         
intermediate format.  The XML format could be designed with the idea    
that is it meant more for a person to understand, and edit.             

Some things that would then be possible.  It would be possible to write 
code that inserts standard documentation describing how zsh works (e.g. 
how does it handle exclusive flags or equivalent flags) right next to   
the place where the command specific information is being provided.     
Command specific help (such as pulled from the man page) could be       
embedded in the XML.  It would also be possible to embed zsh source     
code for flags that use $state in the XML.                              

It would be possible to provide zstyle information (e.g. default        
values, values to look up) for particular arguments.  Also, editing     
this file would provide another point of customization.                 

I don't think the XML format devised would necessarily have to be able  
to generate completion functions for every possible command.  Just have 
to be good enough to work for a good portion of commands.               

So I've gone on long enough about this.  Does this sound like something 
that could provide an additional easier to use interface to the         
completion system?                                                     

-FR.


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/


^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: Generating completion functions from XML
@ 2001-07-21  1:16 Felix Rosencrantz
  2001-07-21 13:54 ` Oliver Kiddle
  0 siblings, 1 reply; 9+ messages in thread
From: Felix Rosencrantz @ 2001-07-21  1:16 UTC (permalink / raw)
  To: zsh-workers

>Btw. have you noticed Bart's _arg_compile function?

I hadn't looked at Bart's _arg_compile function.  It does look
interesting.  It covers things that I would like to see in an
intermediate file format.

XML is sort of interesting to me for the intermediate format for all the
reasons that people are hyping it these days.  It might not be the way
to go, but it's worth a try.  I do agree that XML is not overly easy to
edit (I haven't looked at psgml.el).  Though, I like the possibility of
actually placing documentation in appropriate points in the descriptive
file, and the ability for it to be modified more programmatically.

Also, I don't really expect XML to represent all completion functions.
Though for many simple ones, I think XML could be a good format.

I'll take a first stab at coming up with some sort of grammar.  I've
only created a couple small grammars for some small projects.  I know
though that it can take some effort to design a good schema.

I'd like to see an XML format that can represent any _arguments call.
So that it would be possible to have some sort of equivalent version in
XML.

I'd also like to be able to represent/generate a function that contains
multiple _argument calls based on $service, and then can also handle
$state (e.g. the _zip function).

>But it's not simple to define, really.  Especially if you think about
>commands like _cvs which does *a lot* besides calling _arguments,
>things that are best described with the shell code needed to do them, I
>think.

With a _cvs-like command I'd like to be able to represent in XML what
amounts to the hierarchical call to _arguments.  I realize there is a
lot of specialized code to handle actions.  I don't really see a way
to automate action generation or to represent actions other than in
zsh script.  (Though there is an XML version of java code, javaml...)
I think if the XML format made it simple to share flags between the
various sub-commands, since it is common for the same flag to be shared
among sub-commands, it would help with the creation of such completion
functions.  

>I'll try to make helpful comments when you start describing the
>language you have in mind.

That would be very much appreciated.  I'll try to come up with something
over the next week.

-FR


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/


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

end of thread, other threads:[~2001-07-23 10:57 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-19  1:52 Generating completion functions from XML Felix Rosencrantz
2001-07-19  8:56 ` Sven Wischnowsky
2001-07-19 15:48   ` Bart Schaefer
2001-07-19 18:42     ` Adam Spiers
2001-07-21  1:16 Felix Rosencrantz
2001-07-21 13:54 ` Oliver Kiddle
2001-07-22 20:34   ` Felix Rosencrantz
2001-07-23  4:25     ` Andrej Borsenkow
2001-07-23 10:56       ` Sven Wischnowsky

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