Re: [code] Still wrestling with oddball folds.

From: Mitchell <m.att.foicica.com>
Date: Wed, 8 Jan 2014 08:11:56 -0500 (Eastern Standard Time)

Michael,

On Wed, 8 Jan 2014, Michael Richter wrote:

> On 8 January 2014 02:40, Mitchell <m.att.foicica.com> wrote:
>
>> You should be using a function to determine the end of the fold point
>> because I don't see a good pattern rule. This seems to work for me:
>>
>>
>> M._foldsymbols = {
>> _patterns = { '%:%-', '%.', },
>> [l.OPERATOR] = {
>> [':-'] = 1,
>> ['.'] = function(text, pos, line, s, match)
>> return line:find('%.%f[%s]', s) and -1 or 0
>> end,
>> },
>> }
>>
>> It checks to see if the next character after '.' (if it exists) is a
>> whitespace character. Documentation on such functions is here[1].
>>
>
> I looked at that documentation, but I couldn't work out what the five
> parameters were and which ones applied where. Any chance of having that
> described a bit more thoroughly somewhere?

How would you suggest the existing documentation to be improved?

"The lexer calls these functions with the following arguments: the text to
identify fold points in, the beginning position of the current line in the
text to fold, the current line’s text, the position in the current line
the matched text starts at, and the matched text itself."

> That being said, your solution (as modified by the anchor you later
> suggested) works unless the "." appears at the end of a line like these:
>
> :- import_module io.
>
> :- type token_list
> ---> token_cons(token, token_context, token_list)
> ; token_nil.
>
> Are line feeds not matched as whitespace in Lua patterns or is the line
> feed truncated when passed to that function?

That's strange, I thought the %f took care of string endings... I saw in a
follow up that you can use '\0' so thanks for letting me know.

Cheers,
Mitchell

-- 
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 Jan 2014 - 08:11:56 EST

This archive was generated by hypermail 2.2.0 : Thu 09 Jan 2014 - 06:49:10 EST