Re: [code] textadept indent to correct level

From: Mitchell <m.att.foicica.com>
Date: Mon, 9 Jun 2014 14:25:35 -0400 (Eastern Daylight Time)

Hi Joseph,

On Sat, 7 Jun 2014, Joseph McDonald wrote:

>
> trying to get my favorite emacs functionality into textadept:
>
> 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).

Cheers,
Mitchell

[1]: http://foicica.com/textadept/api/textadept.editing.html#filter_through

-- 
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 Mon 09 Jun 2014 - 14:25:35 EDT

This archive was generated by hypermail 2.2.0 : Tue 10 Jun 2014 - 06:28:51 EDT