Re: [code] Textadept Customization and Upgrades

From: Mitchell <m.att.foicica.com>
Date: Tue, 10 Mar 2020 09:09:14 -0400 (EDT)

Hi Gavin,

On Tue, 10 Mar 2020, Gavin Holt wrote:

> [snip]

I'll address your other questions later, but I can give a quick answer to the following.

> Q3 . I am struggling to reassign a menu entry to a redefined function
> - see new io.open_recent_file() in my init.lua.
>
>
> I am trying to alter the table textadept.menu.menubar[_L['_File']] but
> I can't iterate to find the right spot to make an alteration.
>
>
> Test case "for i,v in pairs(textadept.menu.menubar[_L['_File']]) do
> print(type(v)) end" returns nothing - despite
> print(#textadept.menu.menubar[_L['_File']]) returning 17!

You need to use the `for i = 1, #menubar[...]` construct to iterate over menus. (`pairs` does not work because menu handing is mostly magic in order to support instantaneous inserting and removing of items.) See this[1] for an example of inserting a "Spellcheck" menu item in alphabetical order in the "Tools" menu.

Cheers,
Mitchell

[1]: https://foicica.com/hg/textadept_modules/file/2c38a48b8649/spellcheck/init.lua#l256

-- 
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 Tue 10 Mar 2020 - 09:09:14 EDT

This archive was generated by hypermail 2.2.0 : Wed 11 Mar 2020 - 06:45:27 EDT