emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Dynamically modifying menu entries


From: Drew Adams
Subject: RE: Dynamically modifying menu entries
Date: Sun, 18 Jul 2010 23:18:23 -0700

> 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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]