Re: [code] [textadept] Removing language-specific context menus

From: Mitchell <m.att.foicica.com>
Date: Thu, 22 Jan 2015 20:08:03 -0500 (EST)

Hi Ryan,

On Thu, 22 Jan 2015, Ryan Pusztai wrote:

> Hi Mitchell,
>
> On Thu, Jan 22, 2015 at 4:23 PM, Mitchell <m.att.foicica.com> wrote:
>
>> Hi,
>>
>> Background: Textadept allows language-specific modules to define a
>> language-specific context menu:
>>
>> _M[lang] = {
>> ... menu ...
>> }
>>
>> Whenever that language is loaded, that right-click context menu is used
>> instead of Textadept's default one. This was put in place long ago because
>> there was no easy way to edit a menu without completely redefining it. For
>> a while now Textadept has allowed users to edit
>> `textadept.menu.context_menu`, etc. directly as Lua tables. In my opinion,
>> this effectively eliminates the need for the above feature. (If a
>> language-module wants to add language-specific features to the context
>> menu, it can do so without destroying any edits another language-specific
>> module has made.)
>>
>> Unless anyone has any particularly strong objections, this change will be
>> committed soon.
>
>
> I am currently a user of this and I edit 2 or more languages during a
> session with TA.
> Are you proposing to just add things to the menu for each language and grow
> the menu for each file with a different language?
>
> Here is an example of a Lua, Python, C++, Perl file all loaded at the same
> time:
>
> Undo
> Redo
> -----------
> cut
> copy
> paste
> -----------
> Select All
> -----------
> <lua custom item1>
> <lua custom item2>
> -----------
> <c custom item1>
> <c custom item2>
> -----------
> <python custom item1>
> <python custom item2>
> -----------
> <perl custom item1>
> <perl custom item2>
>
> Would it be like this?
>
> I am not familiar with the `textadept.menu.context_menu` property, does it
> know TA default menu? This way when switching buffers you can get rid of
> the other languages items and only add the language specific items.
>
> I hope this makes sense. (I was having problems describing my questions)

Thanks for your feedback. Something like this is what I had in mind:

     textadept.menu.context_menu[#textadept.menu.context_menu + 1] = {
       title = 'Lua',
       {'Autocomplete "end"', M.try_to_autocomplete_end}
     }

This would display a menu like:

     Undo
     Redo
     ----
     ...
     ----
     Lua -> Autocomplete "end"

Language modules would put something similar in their init.lua files.

As you point out, the context menu would "grow" with each addition, so the
example I gave would help "separate" functionality for each language. If
you or anyone else think this is a terrible idea, please let me know. I
honestly do not use this so I don't have a strong opinion. I'm flexible.

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 Thu 22 Jan 2015 - 20:08:03 EST

This archive was generated by hypermail 2.2.0 : Fri 23 Jan 2015 - 06:31:49 EST