On Tuesday, April 14, 2015 at 5:45:35 AM UTC-5, Edward K. Ream wrote:
 

> ...g.getLanguageAtPosition(c,p)..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()
>
>  
 Wow.  The above is atrocious style.  Here is the new code:

```python

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') or
        g.getLanguageFromAncestorAtFileNode(p) or
        c.config.getString('target_language') or
        'python'
    )
    return language.lower()
```

-- 
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