* Dynamically modifying menu entries
@ 2010-07-19 5:15 Michael Mauger
2010-07-19 6:18 ` Drew Adams
2010-07-20 11:18 ` Stefan Monnier
0 siblings, 2 replies; 3+ messages in thread
From: Michael Mauger @ 2010-07-19 5:15 UTC (permalink / raw)
To: Emacs Devel
I am building a menu using `easy-menu-define' with a submenu whose entries are
dependent on the entries in a list in the package. The contents of the list may
change and based on those changes the contents of the submenu may change. This
is not as simple as enabling/disabling menu entries; it involves adding and
removing entries based on the contents of the separate list.
I have one submenu for which I have a separate API to maintain the list and
corresponding submenu contents. In another case, the API feels like overkill.
I've tried the :filter function and rather than filtering out existing menu
entries I return an augmented list of entries. It worked on Gnome but I'm not
sure that it is an appropriate way of dynamically populating a submenu. It also
does appear that the submenu doesn't get refreshed as frequently as I'd like.
Ideally, I'd like to be able to populate the submenu when it's selected rather
than having to predefine the menu contents.
What am I missing, or is using the :filter handler the way to go?
TIA
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: Dynamically modifying menu entries
2010-07-19 5:15 Dynamically modifying menu entries Michael Mauger
@ 2010-07-19 6:18 ` Drew Adams
2010-07-20 11:18 ` Stefan Monnier
1 sibling, 0 replies; 3+ messages in thread
From: Drew Adams @ 2010-07-19 6:18 UTC (permalink / raw)
To: 'Michael Mauger', 'Emacs Devel'
> I am building a menu using `easy-menu-define' with a submenu
> whose entries are dependent on the entries in a list in the
> package. The contents of the list may change and based on
> those changes the contents of the submenu may change. This
> is not as simple as enabling/disabling menu entries; it
> involves adding and removing entries based on the contents
> of the separate list.
>
> I have one submenu for which I have a separate API to
> maintain the list and corresponding submenu contents.
> In another case, the API feels like overkill.
>
> I've tried the :filter function and rather than filtering out
> existing menu entries I return an augmented list of entries.
> It worked on Gnome but I'm not sure that it is an appropriate
> way of dynamically populating a submenu. It also does appear
> that the submenu doesn't get refreshed as frequently as I'd like.
> Ideally, I'd like to be able to populate the submenu when
> it's selected rather than having to predefine the menu contents.
>
> What am I missing, or is using the :filter handler the way to go?
I don't know the answer and I'm no expert on easy-menu (or menus generally).
But I would think that you could use `:visible for this (dynamically add/remove
menu items and menus). Dunno if you can also use `:filter' for it.
My impression from reading the doc is that `:filter' is more about dynamically
calculating the particular binding(s) to use, whereas `:visible' is more about
dynamically choosing whether the item or menu appears at all. The latter seems
to be what you want to do: determine which items should appear in some given
context.
For `easy-menu', `:filter' and `:visible' apparently apply to a set of menu
items and not to a single menu item (as they do for `menu-item' with
`define-key', for example).
I use `:visible' with `menu-item' (and `define-key') a lot, but I've only used
`:filter' once or twice. And I don't recall using either of them with
`easy-menu'.
Unless someone can help you based on your description, perhaps it would help if
you gave a concrete example. It might also be that you've stumbled upon a bug.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Dynamically modifying menu entries
2010-07-19 5:15 Dynamically modifying menu entries Michael Mauger
2010-07-19 6:18 ` Drew Adams
@ 2010-07-20 11:18 ` Stefan Monnier
1 sibling, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2010-07-20 11:18 UTC (permalink / raw)
To: Michael Mauger; +Cc: Emacs Devel
> I am building a menu using `easy-menu-define' with a submenu whose
> entries are dependent on the entries in a list in the package.
> The contents of the list may change and based on those changes the
> contents of the submenu may change. This is not as simple as
> enabling/disabling menu entries; it involves adding and removing
> entries based on the contents of the separate list.
If the set of possible entries is finite (and reasonably small), then
you can use :visible, but otherwise :filter is most likely the way to go.
> It also does appear that the submenu doesn't get refreshed as
> frequently as I'd like. Ideally, I'd like to be able to populate the
> submenu when it's selected rather than having to predefine the
> menu contents.
:filter should be run often enough (or even more often than that, in my
experience), so if it's not often enough for you, please report the
precise case where it fails to be (re)run.
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-07-20 11:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-19 5:15 Dynamically modifying menu entries Michael Mauger
2010-07-19 6:18 ` Drew Adams
2010-07-20 11:18 ` Stefan Monnier
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).