Re: [code] [textadept] Menu modification delay 2

From: Gabriel Dubatti <gdubatti.att.gmail.com>
Date: Wed, 16 Nov 2016 08:28:45 -0300

Hi Mitchell,

     It 's just a matter of operator precedence :)

http://www.lua.org/pil/3.5.html

Adding "( )" to the test solve my context menu issues!

             if not (type(v) == 'function') then update(menubar or menu)
end

     I'll undo my menubar changes and test it and I'll tell you if
something dosen't work.

     Cheers,

     Gabriel

El 15/11/2016 a las 22:08, Mitchell escribió:
> Hi Gabriel,
>
> On Mon, 14 Nov 2016, Gabriel Dubatti wrote:
>
>> Hi Mitchell,
>>
>> I downloaded and installed the nightly build. Also compared
>> menu.lua with mine and they were the same.
>>
>> ----
>>
>> I don't know why but some menubar modifications did work and some
>> did not.
>>
>> So I rewrote the code to replace the complete menu bar at
>> initialization time with just one line: textadept.menu.menubar=
>> proj_menubar, this part now works fine.
>>
>> ----
>>
>> When I try to change the tab context menu with:
>>
>> local menu= textadept.menu.tab_context_menu
>> table.insert(menu,2,{'Close Others', Proj.close_others})
>> table.insert(menu,3,{"Mark as don't close", Proj.keep_thisbuffer})
>> table.insert(menu,4,{_L['Close All'], Proj.onlykeep_projopen})
>>
>> These items don't appear.
>>
>> -----
>>
>> Also, when I try to modify the context menu (when the buffer
>> changes) with:
>>
>> 1) at init time I get the sub-menu position with:
>> Proj.cmenu_idx= #textadept.menu.context_menu +1
>>
>> 2) every time I want to change the project context submenu, I
>> set it with:
>>
>> textadept.menu.context_menu[ Proj.cmenu_idx ]= {
>> title='Project',
>> {'_End edit', Proj.change_proj_ed_mode}
>> }
>>
>> This sub-menu doesn't appear.
>>
>> ----
>
> Thanks for the additional information. Sadly, I can enter nearly
> identical commands in the command entry and I get the desired tab
> context menu and context menu changes. Are you sure you're not doing
> anything extra? (Perhaps overwriting your changes later on with
> another menu?) What happens if you start with a clean user directory
> and apply just those menu changes above? (`textadept -u /tmp` or
> similar may be of help.)
>
>> If I replace: "if not type(v) == 'function' then update(menubar or
>> menu) end" with "update(menubar or menu)", all works fine.
>
> All of the issues aside, let's just digest this change. This happens
> inside a `__newindex` metamethod (`t[k] = v` where t is a menu, k is a
> position, and v is the thing to change). v is often one of two things:
> either a table that represents a submenu or menu item, or it is a
> function assigned to a menu item. In all of your examples above, the
> "thing" being assigned (`v`) is a table, so the "not type(v) ==
> 'function'" always applies, and the menu should be updated.
>
> I'd recommend you temporarily put some `print()` statements above the
> change in menu.lua to at least print 'k', so you may be able to
> discern where things are going wrong.
>
> 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 Wed 16 Nov 2016 - 06:28:45 EST

This archive was generated by hypermail 2.2.0 : Wed 16 Nov 2016 - 06:41:16 EST