[code] How to add code folding keywords to an existing lexer?

From: cryo shock <axteffekt.att.gmail.com>
Date: Wed, 8 Mar 2017 14:01:46 +0100

Hi guys there's another thing I'd love to solve but I can't find a solution
in the manual.

I am using TA mainly for ConTeXt documents, so I bound two formats to TA's
"context.lua" lexer by adding the following lines to my user/init.lua:

textadept.file_types.extensions.tex = 'context'
textadept.file_types.extensions.cxd = 'context'

Everything works fine, except I am missing a keyword pair for code folding:

\beginTXT ... \endTXT

So how can I add this keyword pair and where should I add it?
In my user/init.lua or in TA/lexers/context.lua?

In context.lua I found the following code:

----------------------------------------------------------------
-- ConTeXt environments.
local environment = token('environment', '\\' * (P('start') + 'stop') *
l.word)

[...]

M._foldsymbols = {
  _patterns = {'\\start', '\\stop', '[{}]', '%%'},
  ['environment'] = {['\\start'] = 1, ['\\stop'] = -1},
  [l.OPERATOR] = {['{'] = 1, ['}'] = -1},
  [l.COMMENT] = {['%'] = l.fold_line_comments('%')}
}
-----------------------------------------------------------------

I tried to fiddle around by adding begin and end commands in between
somewhere but so far I didn't find a way to make them work simultanously.

Any advice that can help me? Thanks in advance.

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Wed 08 Mar 2017 - 08:01:46 EST

This archive was generated by hypermail 2.2.0 : Thu 09 Mar 2017 - 06:32:07 EST