[TxMt] How to implement auto-completion for TeX with alt-esc?

Mojca Miklavec mojca.miklavec.lists at gmail.com
Wed Jun 4 14:14:00 UTC 2008


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:
where I would like to be able to type
        [{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:
     \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"}, ],

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,

More information about the textmate mailing list