Re: [code] [textadept] C style display/conversion?

From: Mitchell <m.att.foicica.com>
Date: Mon, 20 Feb 2017 09:09:41 -0500 (EST)

Hi Ardi,

On Mon, 20 Feb 2017, ardi wrote:

> Hi,
>
> I was taking a look at the "Artistic Style" program, which
> automatically converts across different C styles, and I was wondering
> if it is possible to do something like that from within TextAdept, and
> with a more "on the fly" approach.
>
> In particular, I'd find it a quite powerful feature to see and edit
> files in a different style from the version saved in disk. For
> example, I tend to prefer the Whitesmiths style (about 20 years using
> that style), but however I'd prefer to share my code formatted as
> either K&R or Allman, because these are the most popular styles.
>
> I know the Artistic Style program can convert all files in a tree,
> recursively, but that looks like throwing an atomic bomb in your
> source tree...
>
> I believe it would be better to have an editor that changes the code
> display without modifying the file, depending on the user preference.
> For example, a source file would be stored as K&R on disk, but you'd
> see it formatted as Allman if that's your preference. If you edit the
> file, then I'm not sure what would be best: having another preference
> for saving, or saving it in your view style.
>
> Given that TextAdept knows about code blocks, maybe these features
> could be achieved without modifying the source files... it's just a
> matter of how blocks are displayed.

Sorry, this is not possible. Textadept displays text as it is on disk --
it will not display it with additional newlines or shifted brace
characters, etc. The closest you could get is using a C-style program to
transform text in a buffer immediately after Textadept loads a file (via
`events.FILE_OPENED`), transforming it back right before a save (via
`events.FILE_BEFORE_SAVE`), and then "undoing" that save-transformation
after the save (via `events.FILE_AFTER_SAVE`) and continue editing in your
preferred style. While you are editing, the buffer contents would be
different than the file on disk though.

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 Mon 20 Feb 2017 - 09:09:41 EST

This archive was generated by hypermail 2.2.0 : Tue 21 Feb 2017 - 06:28:11 EST