From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.devel Subject: RE: Dynamically modifying menu entries Date: Sun, 18 Jul 2010 23:18:23 -0700 Message-ID: <5D3A23BEC36D4A9BAD2545BFFC457B17@us.oracle.com> References: <407470.62599.qm@web62502.mail.re1.yahoo.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1279520401 23866 80.91.229.12 (19 Jul 2010 06:20:01 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 19 Jul 2010 06:20:01 +0000 (UTC) To: "'Michael Mauger'" , "'Emacs Devel'" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jul 19 08:19:54 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Oajhh-00009q-Md for ged-emacs-devel@m.gmane.org; Mon, 19 Jul 2010 08:19:53 +0200 Original-Received: from localhost ([127.0.0.1]:57871 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oajhg-0000Jx-Oy for ged-emacs-devel@m.gmane.org; Mon, 19 Jul 2010 02:19:52 -0400 Original-Received: from [140.186.70.92] (port=38479 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OajhZ-0000Js-3u for emacs-devel@gnu.org; Mon, 19 Jul 2010 02:19:46 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OajhY-0001ts-2d for emacs-devel@gnu.org; Mon, 19 Jul 2010 02:19:45 -0400 Original-Received: from rcsinet10.oracle.com ([148.87.113.121]:56023) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OajhX-0001th-Pf for emacs-devel@gnu.org; Mon, 19 Jul 2010 02:19:44 -0400 Original-Received: from acsinet15.oracle.com (acsinet15.oracle.com [141.146.126.227]) by rcsinet10.oracle.com (Switch-3.4.2/Switch-3.4.2) with ESMTP id o6J6JetB018305 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 19 Jul 2010 06:19:42 GMT Original-Received: from acsmt353.oracle.com (acsmt353.oracle.com [141.146.40.153]) by acsinet15.oracle.com (Switch-3.4.2/Switch-3.4.1) with ESMTP id o6ILLUsU000885; Mon, 19 Jul 2010 06:19:38 GMT Original-Received: from abhmt001.oracle.com by acsmt353.oracle.com with ESMTP id 415349691279520293; Sun, 18 Jul 2010 23:18:13 -0700 Original-Received: from dradamslap1 (/141.144.168.9) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 18 Jul 2010 23:18:13 -0700 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: <407470.62599.qm@web62502.mail.re1.yahoo.com> Thread-Index: AcsnAXwPApMwNPqbT2mXlpk3XX5RPgABEHtA X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5931 X-Source-IP: acsmt353.oracle.com [141.146.40.153] X-Auth-Type: Internal IP X-CT-RefId: str=0001.0A090206.4C43EE7A.0120:SCFMA4539814,ss=1,fgs=0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:127570 Archived-At: > 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.