Re: [code] Recursive fold_all

From: Mitchell <m.att.foicica.com>
Date: Wed, 4 Mar 2015 09:09:06 -0500 (EST)

Hi Carlos,

On Wed, 4 Mar 2015, Carlos Pita wrote:

> Mhh, this snippet seems to do the trick:
>
> for line = 0, buffer.line_count do
> if bit32.band(line, buffer.FOLDLEVELHEADERFLAG) and
> bit32.band(line, buffer.FOLDLEVELBASE) then
> buffer:fold_children(line, buffer.FOLDACTION_CONTRACT)
> end
> end
>
> or as a toggle:
>
> local folds_expanded = true
> keys['a*'] = function()
> local action = folds_expanded
> and buffer.FOLDACTION_CONTRACT
> or buffer.FOLDACTION_EXPAND
> folds_expanded = not folds_expanded
> for line = 0, buffer.line_count do
> if bit32.band(line, buffer.FOLDLEVELHEADERFLAG) and
> bit32.band(line, buffer.FOLDLEVELBASE) then
> buffer:fold_children(line, action)
> end
> end
> end
>
> I think it captures the idea you suggested. As I'm pretty new to both
> lua and ta, any correction would be welcomed.

That looks good to me. I think this is wiki material :)

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 04 Mar 2015 - 09:09:06 EST

This archive was generated by hypermail 2.2.0 : Thu 05 Mar 2015 - 06:38:41 EST