​On Mon, Apr 13, 2015 at 2:06 PM, 'Terry Brown' via leo-editor <
[email protected]> wrote:

is there a fast way to know if you're in "source code", presumably
> from the @language definition.
>

​ Yes. The new g.getLanguageAtPosition(c,p).  It should be fast enough:

def getLanguageAtPosition(c,p):
    '''
    Return the language in effect at position p.
    This is always a lowercase language name, never None.
    '''
    aList = g.get_directives_dict_list(p)
    d = g.scanAtCommentAndAtLanguageDirectives(aList)
    language = d and d.get('language')
    if not d:
        language = g.getLanguageFromAncestorAtFileNode(p)
    if not language:
        language = c.config.getString('target_language') or 'python'
    return language.lower()

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to