[TxMt] User defined symbols and folding

Allan Odgaard throw-away-2 at macromates.com
Sun Feb 3 11:46:50 UTC 2008


On 6 Jan 2008, at 13:06, Carsten Hoever wrote:

> I am using comments like
>
> %  
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> % Doing something...
> %  
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
>
> [...]
> to structure the code inside my MATLAB files. For easier navigation  
> I would like to use these comments as folding markers and symbols  
> (for the "Go to symbol" command). I know that I have to play around  
> with the language grammar to do so, but alas my more than limited  
> knowledge of regular expressions has prevented me from succeeding.  
> Maybe one of the language grammar/regex experts here has a quick tip  
> for me?

It is not entirely trivial. For the symbol pop-up you need the grammar  
to identify the lines, you can either do the simple pattern that just  
matched: ‘^% ([A-Z]\w+.*)$’ -- i.e. all commented lines that start  
with an uppercase letter, and then scope the text so that it can be  
selected by the symbol pop-up preference -- another approach is using  
begin/end rules to only match lines surrounded by: ‘% =+’.

As for foldings, this is likely not possible because of the current  
rule about clearly defined start and end markers and only allowing  
matches to look at one line.




More information about the textmate mailing list