all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
To: "'Michael Mauger'" <mmaug@yahoo.com>,
	"'Emacs Devel'" <emacs-devel@gnu.org>
Subject: RE: Dynamically modifying menu entries
Date: Sun, 18 Jul 2010 23:18:23 -0700	[thread overview]
Message-ID: <5D3A23BEC36D4A9BAD2545BFFC457B17@us.oracle.com> (raw)
In-Reply-To: <407470.62599.qm@web62502.mail.re1.yahoo.com>

> 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	other threads:[~2010-07-19  6:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-19  5:15 Dynamically modifying menu entries Michael Mauger
2010-07-19  6:18 ` Drew Adams [this message]
2010-07-20 11:18 ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5D3A23BEC36D4A9BAD2545BFFC457B17@us.oracle.com \
    --to=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    --cc=mmaug@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.