Re: [code][textadept] Advanced use of Textadept Lexers

From: Richard Philips <>
Date: Thu, 27 Feb 2014 07:01:35 +0100

Hello Mitchell,

let us forget - for the time being - about coloring the code: it is too
much related to style and I realise that it just confounds things.

I give another application of the idea:

A few months back I wrote a spelling checker for textadept. One of
its features is scanning the text and red underlining the bad words.

I would like to use the same feature in code as well but it should be
restricted to strings and comments.

I think this problem is not so different as how textadept is styling code;
textadept associates styling information with tokens. In much the same
manner I would like to associate actions with tokens.

Transformations is one usage but others are feasable as well. In the
spelling checker example, the 'M._tokenstyles' alike structure I would use,
is loaded with functions that either do nothing or spellcheck the token.


Again I want to stress that I am not looking for the solution to a specific
problem I have: for both the coloring problem and the spelling problem I
came up with adequate solutions I am quite happy about.

It is just that I noticed that both these problems could be solved in a
more elegant way by using one of the main strengths of textadept: its
lexing capabilities.

Thank you for listening to this,


On Thursday, February 27, 2014, Mitchell <> wrote:

> Hi Richard,
> On Wed, 26 Feb 2014, Richard Philips wrote:
> Hi,
>> last week I implemented HTML-ization of source code in textadept.
>> For documentation purposes, I needed to capture code fragments together
>> with its colorization and to format it in HTML.
>> I took a short-cut :-)
>> Together with the new multiple field ui.dialogs.inputbox (thanks again,
>> Mitchell :-),
>> I brought the relevant code fragments and formatting info
>> outside textadept and worked with the phenomenal Pygments software.
>> Then I brought the result (HTML) back into textadept and put the HTML in
>> the clipboard.
>> But I think I can do better:
>> I looked into the code of lexer.load and lexer.lex and I think
>> it should be possible to populate M._tokenstyles with functions instead of
>> styles.
>> These functions could transform the tokens to text (e.g. HTML).
>> Is this something worthwhile to pursue? Any ideas about how to proceed?
> I'm not sure I follow. Do you have an example that might help me
> understand? What would an example transformation be?
> Cheers,
> Mitchell
> --
> You are subscribed to
> To change subscription settings, send an e-mail to
> To unsubscribe, send an e-mail to

You are subscribed to
To change subscription settings, send an e-mail to
To unsubscribe, send an e-mail to
Received on Thu 27 Feb 2014 - 01:01:35 EST

This archive was generated by hypermail 2.2.0 : Thu 27 Feb 2014 - 06:36:04 EST