[Top][All Lists]

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

Re: easy-menu / remove dividers from menu -> fails...

From: Stefan Monnier
Subject: Re: easy-menu / remove dividers from menu -> fails...
Date: Thu, 26 May 2005 13:29:37 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

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


--- 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)
      ((stringp (car-safe item))

reply via email to

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