what @language setting is in effect for a given node?

44 views
Skip to first unread message

jkn

unread,
Jun 2, 2025, 5:40:15 AM6/2/25
to leo-editor
Hi all
    a simple (I think) question - how do I determine the language in effect for a given (or current) node?

I was looking for a primitive for this but there seem to be a few approaches used, I'm wondering what the recommended way might be.

    Thanks
    J^n

jkn

unread,
Jun 2, 2025, 5:56:33 AM6/2/25
to leo-editor
Hmm, perhaps this is it:

language = c.frame.body.colorizer.scanLanguageDirectives(p)
if c.hasAmbiguousLanguage(p):
    language = c.getLanguageAtCursor(p, language)

g.es("language: ", language)

Edward K. Ream

unread,
Jun 2, 2025, 7:27:33 AM6/2/25
to leo-e...@googlegroups.com
On Mon, Jun 2, 2025 at 4:40 AM jkn <jkn...@nicorp.f9.co.uk> wrote:

 how do I determine the language in effect for a given (or current) node?

Good question. Leo 6.8.4 (PR #4334) contains significant changes in this area:

-  Deprecates c.scanAllDirectives and many directives-related functions in leoGlobals.py.
-  Adds new getters, including  c.getLanguage(p).

So my recommended answer is language = c.getLanguage(p).

Replace p by c.p to get the language in effect for the current node (position).

The definition of c.getLanguage is non-trivial :-)

Edward

jkn

unread,
Jun 2, 2025, 11:55:00 AM6/2/25
to leo-editor
Thanks Edward- I did look for 'getlanguage()', but on an older version of Leo...

    Regards
    J^n

Edward K. Ream

unread,
Jun 2, 2025, 3:25:59 PM6/2/25
to leo-e...@googlegroups.com
On Mon, Jun 2, 2025 at 10:55 AM jkn <jkn...@nicorp.f9.co.uk> wrote:
Thanks Edward- I did look for 'getlanguage()', but on an older version of Leo...

You're welcome. These new 'c' getters are worth another mention.

Edward

jkn

unread,
Jun 3, 2025, 4:06:42 AM6/3/25
to leo-editor
yes - I was sort-of expecting them to be commander methods...

jkn

unread,
Jun 3, 2025, 7:45:10 AM6/3/25
to leo-editor
heh - I see that I also have to replace c.getNodeFileName() with c.getPath() as well (much better...)
Reply all
Reply to author
Forward
0 new messages