Re: Reset languagae modules(was: API Changes)

From: Robert <ro....at.web.de>
Date: Mon, 21 Jun 2010 10:37:53 +0200

On Sat, Jun 19, 2010 at 6:26 PM, mitchell <mforal.n....at.gmail.com> wrote:
> Robert,
>
>> From: Robert <ro....at.web.de>
>> Date: Sat, Jun 19, 2010 at 8:57 AM
>>
>> Thanks - now I understand why it sometimes worked for me and sometimes not :-)
>> The refocusing doesn't seem to work, as a workaround I could edit the
>> cpp module, go back to the c-file that made me want to edit the
>> language module, and then reset the Lua state.
>> To able to do the reset in the language module file I added the
>> following to my init.lua:
>>
>> if RESETTING then
>>  events.connect('buffer_after_switch', function ()
>>    local lang = buffer._lexer or false
>>    if lang and not package.loaded[lang] then
>>      buffer:set_lexer(lang)
>>    end
>>  end)
>> end
>>
>> I added the extra check for "lang" to prevent "hanging" Textadept when
>> creating a new buffer after a reset.
>>
>> Would you consider adding this (or something similar) to
>> mime_types.lua? It would make developing language modules a lot
>> easier.
>
> Does the attached patch have the desired effect?
>
> Mitchell
>

Yes, thank for looking into it.
For having the language module lua file in one view and the language
file in another view an "view after switch"-event
should be added:

Mime_types.lua, around l 190:
events.connect('buffer_after_switch', restore_lexer)
events.connect('view_after_switch', restore_lexer) -- new

Then it works if I switch to the view with the language file.

Robert
Received on Mon 21 Jun 2010 - 04:37:53 EDT

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 11:48:25 EST