Re: [textadept] Simple Pattern-Based Folding in Lexers

From: mitchell <c....at.caladbolg.net>
Date: Mon, 16 May 2011 09:48:04 -0400 (Eastern Daylight Time)

Robert,

On Mon, 16 May 2011, Robert wrote:

> Hi Mitchell,
>
> On Sun, May 15, 2011 at 7:49 PM, mitchell <c....at.caladbolg.net> wrote:
>> On Sun, 15 May 2011, mitchell wrote:
>>
>>> Hi everyone,
>>>
>>> I have commited code to Scintillua (http://scintillua.googlecode.com) that
>>> allows for simple pattern-based code folding to be defined in lexers instead
>>> of full _fold() functions. I have implemented this folding for the lua and
>>> cpp lexers for reference. Lexer authors, please see the appropriate
>>> documentation in lexer.lua (search for "Simple Code Folding"). Here is a
>>> snippet for folding Lua:
>>
>> I forgot to mention that LexLPeg.cxx was also changed so in order to test,
>> you will have to recompile ta.
>>
>> mitchell
>> [...]
>>> Note that this is an experimental feature subject to change. Comments are
>>> welcome.
>>>
>>> mitchell
>
> I found an issue here:
> line 104 in lexer.lua
> -- `:` to `@`, `[` to `'`, `{` to `~`).
> starts a marker.

In my defense SciTE has this bug too since I based my folding on its
folding.

> I tried the example code for folding by indentation with the Python
> lexer (this seems to be exactly what I meant with "generic
> translation" - couldn't something like this be a fallback?)

I'm confused. fold.by.indentation is on unless you explicitly set it off;
therefore it works fine with python out of the box, no?

> With Python I get:
> textadept/lexers/python.lua:134: attempt to index global 'text' (a nil value).
> Lua Error: Table of folds expected from lexer.fold.

That's because I'm using a non-existant variable. Change 'text' to
'input'.

> I just copied over the example from the docs. Dmd and the earlier Lua
> version with folding seem to work fine.
>
> Another issue:
> when I switch the lexer and back to the Lua lexer, the lines aren't drawn.

What line? I'm having trouble reproducing.

mitchell
Received on Mon 16 May 2011 - 09:48:04 EDT

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 12:07:19 EST