Re: [code] [Textadept] menu suggestion

From: Mitchell <m.att.foicica.com>
Date: Fri, 6 Jan 2017 08:49:16 -0500 (EST)

Hi Gabriel,

On Thu, 5 Jan 2017, Gabriel Dubatti wrote:

> Hi Mitchell,
>
> I tried to replace the menu module with my own version in
> ~/modules/textadept/menu.lua
> and found that this module is tightly coupled with the keys module, so
> this module should also be replaced if you want to roll your own menu.
>
> I'm referring to code like this:
>
> menu.lua:
> {_L['Select to _Matching Brace'], function()
> textadept.editing.match_brace('select') end},
>
> keys.lua:
> local m_sel = m_edit[_L['_Select']]
> keys[GUI and 'cM' or 'mM'] = m_sel[_L['Select to _Matching
> Brace']][2]
>
> Using their own functions, like in:
> {_L['_Highlight Word'], textadept.editing.highlight_word},
> keys[not OSX and 'caH' or 'mH'] = textadept.editing.highlight_word
>
> Is much cleaner, decoupled and easy to call this commands from scripts
> (after all, they have a menu and an accelerator, so they are really useful
> commands).
>
> There are near 70 functions in this situation....
>
> Just my two cents.

Yes, if you want to totally replace the menu and have your keybindings
accurately reflected in the menu accelerators, you'll have to update some
of your keybindings to reference the same functions that the menus do
(anonymous functions in particular). Note that the menu accelerators are
for informative purposes only -- even if there is no accelerator shown, a
keybinding will still work.

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 Fri 06 Jan 2017 - 08:49:16 EST

This archive was generated by hypermail 2.2.0 : Sat 07 Jan 2017 - 06:44:37 EST