[TxMt] Improving SymbolPopup for LaTeX?

Allan Odgaard throw-away-1 at macromates.com
Sat Dec 3 11:02:20 UTC 2005


On 3/12/2005, at 1:00, Charilaos Skiadas wrote:

> 1) First of all, you need to create a new preferences item. WHY?  
> I'd really like to know that.

You don't. I made the current one: text.latex meta.section.latex and  
it works. But you have to make one edit to the document, before the  
symbol list is rebuilt, so maybe that's what threw you off.

> 2) Second, any changes you make only take effect after you closed  
> the bundle editor. Again, WHY? That's not the case for commands and  
> snippets and stuff.

I hope it will change real-time in the future, but a preference  
change affects a lot, so a lot of caches needs to be flushed, things  
needs to be re-parsed, a.s.o. -- so currently this only happens when  
you close the window.

Commands, snippets, etc. are special in that when you execute one of  
these, it “commits” the current changes in the bundle editor. But  
things like preferences, language grammars etc. are in use all the  
time, so you (currently) need to manually commit (by closing the  
window, or for the latter, using the Test button).

> 3) This is the code I used now [...] two questions on that:
> a) Why don't the spaces that $1 catches being shown? They are in  
> the python thing.

Because meta.section match “\(sub)*section…” and not “(^\s*)?\(sub) 
*section…”. I.e. the leading spaces are not included in the scope.

> b) the \subsubsection rule gives me: \subsubsection{stuff} instead  
> of just "stuff".

You rule had a (closing) ' before the last subst. This works for me:

    symbolTransformation = '
       s/^(\s*)\\section\{(.+)\}/$1 $2/;
       s/^(\s*)\\subsection\{(.+)\}/$1\t $2/;
       s/^(\s*)\\subsubsection\{(.+)\}/$1 \t \t $2/;
    ';

Of course the “^(\s*)” part has no meaning unless the language  
grammar gets changed.

> Other than that, it works well. The tabs inserted by \t get  
> interpreted, even though spaces seem not to.

As for using \t, I use the em-space in the few transformation I've  
made (e.g. Markdown headings), this looks a little better. Though  
you'll have to copy/paste it, and with a fixed width font (bundle  
editor), it looks just like a regular space -- I'll add support for \x 
{nnnn} for these things.




More information about the textmate mailing list