Re: [code] Tabs and Indentation by file type

From: Robert Gieseke <rob.g.att.web.de>
Date: Sun, 18 Aug 2013 12:34:37 +0200

Am 8/18/13 12:16 PM, schrieb Michael Richter:
> I'm running 6.6. The problem is that there *IS* no language module for
> makefiles. There's just a lexer. Instrumenting the events.connect call
> and it doesn't even run for Makefiles. It runs for Lua, though.
>

You're right, sorry. This commit [1] (after the 6.6 release) changed the
emitting of the event to happen always:

"Always emit `events.LANGUAGE_MODULE_LOADED`;
modules/textadept/mime_types.lua
Creates an empty language-specific module if none exists. This enables
users to
add keys and snippets for any lexer without an existing language-specific
module. It also allows themes to override styles for any lexer."

> When else can the type of a file be automatically determined?
>

You could switch to Textadept 7 (I use it all the time … and just tested
the snippet with a clean init.lua), create a language module or maybe
hook into the file_opened event,
along the lines of:
events.connect(events.FILE_OPENED, function()
   if buffer.filename == 'Makefile' then
     -- ... set tab properties
   end
end)

Mitchell, maybe the 'LANGUAGE_MODULE_LOADED' should be renamed to
'LEXER_LOADED' or 'LANGUAGE_DETECTED'?

Robert

[1] http://foicica.com/hg/textadept/rev/ba3e6601f3a7

>
> On 18 August 2013 17:39, Robert Gieseke <rob.g.att.web.de> wrote:
>
>> Am 8/18/13 11:32 AM, schrieb Michael Richter:
>>
>>> I'd tried that already. No dice. Cutting and pasting exactly the code
>>> you
>>> typed above still gives me Makefiles with spaces: 2.
>>>
>>>
>>>>> try this in your init.lua:
>>>>
>>>> events.connect(events.****LANGUAGE_MODULE_LOADED, function(lang)
>>>>
>>>> if lang == 'makefile' then
>>>> buffer.use_tabs = true
>>>> buffer.tab_width = 8
>>>> end
>>>> end)
>>>>
>>>
>> Ok, the '**' don't belong there, but that's probably not the problem.
>> Can you try with a clean init.lua?
>> You can create a temporary one with, textadept -u ~/tmp/test
>> (if you are on Linux, similarly on other platforms) and edit the init.lua
>> in this directory.
>> Maybe you already have a 'makefile' module from an earlier attempt?
>>
>> Also, which version are you using?
>> events.LANGUAGE_MODULE_LOADED was introduced in 6.6.
>> I use the latest 7 beta.
>>
>> Robert
>>
>>
>> --
>> You are subscribed to code.att.foicica.com.
>> To change subscription settings, send an e-mail to code+help.att.foicica.com.
>> To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
>>
>>
>
>

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Sun 18 Aug 2013 - 06:34:37 EDT

This archive was generated by hypermail 2.2.0 : Sun 18 Aug 2013 - 06:37:36 EDT