cython support in @auto, @clean or @file?

57 views
Skip to first unread message

Shakeeb

unread,
Jun 19, 2020, 6:38:01 AM6/19/20
to leo-editor
Hi,

I'm using leo in a new project with c, python and cython. Of course, c and python and well supported in leo's with file directives, but cython is not (except for syntax coloring, which is great!).

Can anyone point in the right direction of the leo's code if I wanted to add such support (which be 98% equivalent to python)?

Thanks in advance for any help on this,

S

Edward K. Ream

unread,
Jun 19, 2020, 7:47:56 AM6/19/20
to leo-editor
On Fri, Jun 19, 2020 at 5:38 AM Shakeeb <shakeeb...@gmail.com> wrote:

I'm using leo in a new project with c, python and cython. Of course, c and python and well supported in leo's with file directives, but cython is not (except for syntax coloring, which is great!).

Can anyone point in the right direction of the leo's code if I wanted to add such support (which be 98% equivalent to python)?

I'm not sure what kind of support you want. As you say, Leo already supports syntax coloring for cython. Furthermore, Leo knows that cython's comments start with '#', which in turn means that @file x.pyx and @clean x.pyx will just work.

As far as compiling .pyx files, you can easily write an @button script to do that. See this FAQ entry.

Please feel free to ask more questions.

Edward

Shakeeb

unread,
Jun 19, 2020, 7:53:23 AM6/19/20
to leo-editor
Hi Edward,

Thanks for your quick reply.

By support, I meant by support is that leo would parse the file into an outline (like a regular python file). I've tested this with @clean <file>.pyx and I get a single node with '@language cython' at the top and its nicely highlighted but not in outline as desired.

I hope this is clearer. If I'm missing a setting or something, I would appreciate some pointers.

Thanks,

S

Edward K. Ream

unread,
Jun 19, 2020, 3:06:09 PM6/19/20
to leo-editor
On Fri, Jun 19, 2020 at 6:53 AM Shakeeb <shakeeb...@gmail.com> wrote:

By support, I meant by support is that leo would parse the file into an outline (like a regular python file).

I see. You want a cython importer.  I've just created #1608 for this.

Edward

Edward K. Ream

unread,
Jun 19, 2020, 3:50:46 PM6/19/20
to leo-editor
On Friday, June 19, 2020 at 2:06:09 PM UTC-5, Edward K. Ream wrote:

> I see. You want a cython importer.  I've just created #1608 for this.

Rev cc931e in devel contains a first draft. Almost all the code derives from the python importer.

Simple tests with @auto work for me. Please let me know how it works for you.

Edward

Shakeeb

unread,
Jun 19, 2020, 4:38:29 PM6/19/20
to leo-editor
Thank you so much. I really appreciate it. I'll test now.

S

Shakeeb

unread,
Jun 19, 2020, 5:10:55 PM6/19/20
to leo-editor
Just tested it. Works great. Thank you so much, Edward, that was awesome!

S

Edward K. Ream

unread,
Jun 20, 2020, 4:58:23 AM6/20/20
to leo-editor
On Fri, Jun 19, 2020 at 4:10 PM Shakeeb <shakeeb...@gmail.com> wrote:

Just tested it. Works great. Thank you so much, Edward, that was awesome!

You're welcome. Glad it works for you. As you can see, only slight mods to the python importer were needed.

There are several additional improvements that should be made:

- The ctor of the python importer (on which the cython importer is based) doesn't handle the "language" kwarg properly.
- The cython importer honors @bool put-cython-decorators-in-imported-headlines. I'll add this setting to leoSettings.leo.
- c.recursiveImport probably should be able to override this setting (and the corresponding setting in the python importer).

I may get to these today.

Edward

Edward K. Ream

unread,
Jun 20, 2020, 9:30:29 AM6/20/20
to leo-editor
On Saturday, June 20, 2020 at 3:58:23 AM UTC-5, Edward K. Ream wrote:

There are several additional improvements that should be made:

- The ctor of the python importer (on which the cython importer is based) doesn't handle the "language" kwarg properly.
- The cython importer honors @bool put-cython-decorators-in-imported-headlines. I'll add this setting to leoSettings.leo.
- c.recursiveImport probably should be able to override this setting (and the corresponding setting in the python importer).

These have all been completed. See #1605 for details.

Edward

Shakeeb

unread,
Jun 20, 2020, 9:43:34 AM6/20/20
to leo-editor
Wow. That's awesome Edward. It's just amazing how responsive you are, and leo, after all these years, is still my go to editor when I need to keep the complexity under control. Thank you.

S


On Saturday, June 20, 2020 at 4:30:29 PM UTC+3, Edward K. Ream wrote:
On Saturday, June 20, 2020 at 3:58:23 AM UTC-5, Edward K. Ream wrote:

There are several additional improvements that should be made:T

- The ctor of the python importer (on which the cython importer is based) doesn't handle the "language" kwarg properly.
- The cython importer honors @bool put-cython-decorators-in-imported-headlines. I'll add this setting to leoSettings.leo.
- c.recursiveImport probably should be able to override this setting (and the corresponding setting in the python importer).

Edward K. Ream

unread,
Jun 20, 2020, 11:59:28 AM6/20/20
to leo-editor
On Sat, Jun 20, 2020 at 8:43 AM Shakeeb <shakeeb...@gmail.com> wrote:
Wow. That's awesome Edward. It's just amazing how responsive you are, and leo, after all these years, is still my go to editor when I need to keep the complexity under control. Thank you.

You're welcome. The contributions I make could not happen without Leo's community of people doing interesting things working on interesting problems.

Edward
Reply all
Reply to author
Forward
0 new messages