Re: [textadept] Re: I'd like to alter AutoPair's behaviour for some files

From: mitchell <c....at.caladbolg.net>
Date: Tue, 7 Dec 2010 23:04:40 -0500 (EST)

Russell,

On Tue, 7 Dec 2010, phayz wrote:

> On Dec 8, 6:29�am, mitchell <c....at.caladbolg.net> wrote:
>> Robert,
>>
>>> events.connect('buffer_after_switch',
>>> �function()
>>> � �if buffer._lexer == 'lua' then
>>> � � �_m.textadept.editing.AUTOPAIR = false
>>> � �else
>>> � � �_m.textadept.editing.AUTOPAIR = true
>>> � �end
>>> �end
>>> �)
>>
>>> Mitchell,
>>> I tried this with buffer:get_lexer(). This caused Textadept to hang
>>> when I opened a new file. Is there something that needs to be checked
>>> additionally in this "private_lexer_call", whatever that means?
>>
>> This is a bug and will be fixed in hg later today. It has to do with the
>> "buffer_after_switch" event being emitted before "buffer_new". The
>> mime-types module uses "buffer_new" to add the get_lexer function. Since
>> "buffer_after_switch" references it before it exists when a new buffer is
>> opened, an infinite recursion of errors happens.
>>
>> mitchell
>
> Robert and Mitchell,
>
> Thanks for your help. I will try this approach when Textadept is next
> released.

You can try what Robert suggested; it will work. The proper way to get the
lexer is via buffer:get_lexer(), but because it's a bug in that particular
context, buffer._lexer is the workaround.

mitchell
Received on Tue 07 Dec 2010 - 23:04:40 EST

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 11:55:20 EST