unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: easy-menu / remove dividers from menu -> fails...
       [not found] <mailman.1868.1117094342.25862.help-gnu-emacs@gnu.org>
@ 2005-05-26 17:29 ` Stefan Monnier
  0 siblings, 0 replies; only message in thread
From: Stefan Monnier @ 2005-05-26 17:29 UTC (permalink / raw)
  Cc: emacs-devel

The following message is a courtesy copy of an article
that has been posted to gnu.emacs.help as well.

> How do I delete divider bars from a menu?
> Deleting normal items works, deleting the divider bar doesn't:

> (easy-menu-remove-item global-map '("menu-bar" "file") 'exit-emacs)    ;works
> (easy-menu-remove-item global-map '("menu-bar" "file") 'separator-exit);doesn't work

> The latter just doesn't do anything.

The problem is a bug in easy-menu.
The patch below fixes it in your case.


        Stefan


--- orig/lisp/emacs-lisp/easymenu.el
+++ mod/lisp/emacs-lisp/easymenu.el
@@ -549,7 +549,14 @@
   "In menu MENU try to look for menu item with name NAME.
 If a menu item is found, return (NAME . item), otherwise return nil.
 If item is an old format item, a new format item is returned."
-  (let ((item (lookup-key menu (vector (easy-menu-intern name))))
+  ;; The call to `lookup-key' also calls the C function `get_keyelt' which
+  ;; looks inside a menu-item to only return the actual command.  This is
+  ;; not what we want here.  We should either add an arg to lookup-key to be
+  ;; able to turn off this "feature", or else we could use map-keymap here.
+  ;; In the mean time, I just use `assq' which is an OK approximation since
+  ;; menus are rarely built from vectors or char-tables.
+  (let ((item (or (cdr (assq name menu))
+                  (lookup-key menu (vector (easy-menu-intern name)))))
 	ret enable cache label)
     (cond
      ((stringp (car-safe item))

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-05-26 17:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <mailman.1868.1117094342.25862.help-gnu-emacs@gnu.org>
2005-05-26 17:29 ` easy-menu / remove dividers from menu -> fails 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).