Re: [code] [textadept] On contextmenu

From: Mitchell <m.att.foicica.com>
Date: Mon, 20 May 2013 14:52:59 -0400 (EDT)

Hi Richard,

On Wed, 15 May 2013, Richard Philips wrote:

> In Textadept release 6.6, _M.textadept.menu.contextmenu is taken out of the
> API.
> It is now possible to specify a language specific contextmenu.
> This is accomplished by the following code in modules/textadept/menu.lua:
>
> ...
>
> 339 if not CURSES then
> 362 -- Set a language-specific context menu or the default one.
> 363 local function set_language_contextmenu()
> 364 local lang = _G.buffer:get_lexer(true)
> 365 M.set_contextmenu(_M[lang] and _M[lang].context_menu or
> context_menu)
> 366 end
> 367 events.connect(events.LANGUAGE_MODULE_LOADED,
> set_language_contextmenu)
> 368 events.connect(events.BUFFER_AFTER_SWITCH, set_language_contextmenu)
> 369 events.connect(events.VIEW_AFTER_SWITCH, set_language_contextmenu)
> 370 events.connect(events.BUFFER_NEW, set_lang_contextmenu)
> 371 end
> 372
> 373 return M
>
> I propose the following change to line 365:
>
> 365 M.set_contextmenu(_M[lang] and _M[lang].context_menu or _M['default']
> and _M['default'].context_menu or context_menu)
>
> This change allows for a default context menu which can be (optionally)
> specified in
> .textadept/init.lua
>
>
> But perhaps there is a better way to get the same result.|

I may as well just expose `_M.textadept.menu.context_menu` again instead
of checking for `_M['default'].context_menu`, but I prefer not to do that.
You can connect to those four events from your *~/.textadept/init.lua* to
set your own default context menu when necessary. I agree it's a bit more
involved, but it would give you the same result.

Cheers,
Mitchell

-- 
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 Mon 20 May 2013 - 14:52:59 EDT

This archive was generated by hypermail 2.2.0 : Tue 21 May 2013 - 06:42:33 EDT