Re: [code] [textadept] Key module and Menu module

From: Qwerky <mr.qwerky.att.gmail.com>
Date: Wed, 3 Jul 2019 17:02:15 -0600

On 2019-07-03 16:43, Mitchell wrote:
> Hi,
>
> On Wed, 3 Jul 2019, Qwerky wrote:
>
>> Thanks.  Presently, menu.lua calls functions directly, and keys.lua
>> (besides
>> already calling some functions directly) calls menu entries which
>> then call
>> functions.  What if those keys.lua functions simply called the same
>> functions
>> which the menu entries call, so that neither keys.lua or menu.lua
>> would call
>> the other?
>
> This isn't exactly true. *keys.lua* and *menu.lua* both call the same
> functions. It's something like:
>
>   menu = {'foo', function() print('foo') end}
>   key = menu[2]
>
> Both `menu` and `key` use the same exact function value. It's just
> that `key` references `menu` to get it. From my understanding, you are
> proposing something like:
>
>   function foo() print('foo') end
>   menu = {'foo', foo}
>   key = foo
>
> The two examples are equivalent, minus a global `foo()` function. I
> wouldn't know the best place to define `foo()` outside of *menu.lua*
> in order for *keys.lua* not to need it. (It certainly cannot be a
> global function.)
>
> Sorry if I'm misunderstanding you.
>
> Cheers,
> Mitchell

This is probably due to my insufficient knowledge of Lua!  :-) But I
will try to explain what I was thinking.

Presently, keys.lua has a line similar to:

   keys[(GUI and 'c~' or 'f1') or 'mf2'] = textadept.bookmarks.toggle

while menu.lua has the line:

       {_L['_Toggle Bookmark'], textadept.bookmarks.toggle},

so they both call textadept.bookmarks.toggle.

menu.lua also has:

       {_L['_Next Bookmark'], function()
         textadept.bookmarks.goto_mark(true)
       end},

(Ah, so that's what you meant be defining a function?)

and keys.lua has a line similar to:

   keys.cadown = m_bookmark[_L['_Next Bookmark']][2]    <-- what does
[2] signify?

so I was wondering whether that line in keys.lua could be changed to:

   keys.cadown = function() textadept.bookmarks.goto_mark(true) end

So I see now that the function would be defined twice--would that be a
problem?  At least then keys.lua and menu.lua could be edited
independently, if one is only changing the keys and/or the menu
structure--not the content of the function.

Also, I don't understand why that line in keys.lua, or the similar line
in menu.lua require "function() ... end" around
"textadept.bookmarks.goto_mark(true)", while the similar lines above in
menu.lua and keys.lua, do not require "function() ... end" around
"textadept.bookmarks.toggle"?

Thanks for your patience.  :-)

qwerky

-- 
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 Wed 03 Jul 2019 - 19:02:15 EDT

This archive was generated by hypermail 2.2.0 : Thu 04 Jul 2019 - 06:31:09 EDT