Hello,
I would like to implement auto-completion with alt-esc, in the same way as it works with HTML.
<a n[ALT+ESC]> --->generates---> <a name="">
but having a slightly different syntax: \commandname[options1][options2] where I would like to be able to type \commandname [{here's the caret, I press ALT-ESC}] [] and then I would get a list of options, specific for the first argument after \commandname and specific for the first bracket (second bracket has a different set of commands).
A sample usage: \definecolor[orangered][r=.9,g=.5,b=0] or \setupcolors[state=start] % could be state=stop
In the first case, I want to hit alt-esc in the second pair of bracket, and I want TextMate to offer me the options "r=", "g=", "b=", "c=", "m=", "y=", "k=" (and maybe to give me hint that a number between 0 and 1 has to follow).
In the second case I want to hit alt-esc in the first pair of brackets and I want TextMate to offer me a list of options "state=" and "conversion=", and if I choose state=, I want to hit alt-esc again and TextMate should offer me a list of two options "start" and "stop".
I know how to write a ruby script that would get command name or current line as the argument, and would return a list of available options, but I don't know what exactly my script needs to return, and I don't know how & where to plug it in.
I've seen this in html:
#!/usr/bin/env ruby require "#{ENV['TM_SUPPORT_PATH']}/lib/codecompletion" print TextmateCodeCompletion.new( #[%{class=""}, %{id=""}, %{style=""}, %{<img src="/images/"}, %{<img border="0"}, ], TextmateCompletionsText.new(ENV['TM_COMPLETIONS'],{:split=>','}).to_ary, STDIN.read, {:scope=>:html_attributes} ).to_snippet
but it's not really clear to me how to experiment with it outside of html. Moreover, the library codecompletion might not be able to handle too complex cases. (I don't really know, I only fear that.)
I'm willing to do it for plain TeX + LaTeX + ConTeXt (I'm currently extracting TeX primitives & ConTeXt commands with options, for LaTeX it would work the same way once I get some list of commands), but I need some pointers where to start first.
Thanks a lot, Mojca