Re: [code] textadept indent to correct level

From: Joseph McDonald <joe.att.vpop.net>
Date: Tue, 10 Jun 2014 09:17:24 -0700

On 06/09/2014 11:25 AM, Mitchell wrote:

>> One of my most used functions is to hit TAB on any line, *anywhere* in
>> the line, and that line is then correctly indented. If there is a
>> syntax error above the current line, then the line is indented
>> incorrectly which alerts you to fix the code above.
>>
>> In languages with significant whitespace, hitting tab cycles between
>> valid positions for the current line (again, hitting tab anywhere in the
>> line, even in the middle of a word)
>
> First you'd have to bind a function to the Tab key (`keys['\t'] = f`).
> That function would have access the the current buffer's contents and
> either analyze it itself, or pass it to another program for analysis. At
> that point you'd know what the proper indent level is or that there is a
> syntax error. You then would use the `buffer.line_indentation[line]`
> property to set indentation as you see fit.
>
>> I also have a key bound to indent the entire buffer correctly.
>
> You'd probably want to use `textadept.editing.filter_through()`[1] with
> a code formatter (e.g. tidy).

I was thinking that the syntax highliting code (lpeg) has the info
necessary to indent correctly. Perhaps what it uses to create the
expand/collapse folds. Is there a "fold level" associated with each line?

Here's something that I think would be really neat for textadept:
"Enhanced Scope Visibility" . slightly shade the background of each
"level" of indent (scope).

some pictures:
http://hbfs.wordpress.com/2010/02/02/features-id-like-to-see-in-my-editor/
http://marketplace.eclipse.org/content/editbox

Not sure how hard that would be to implement in textadept. what do you
think?

thanks,
-joe

-- 
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 Tue 10 Jun 2014 - 12:17:24 EDT

This archive was generated by hypermail 2.2.0 : Wed 11 Jun 2014 - 06:31:57 EDT