]> git.eshelyaron.com Git - emacs.git/commitdiff
(easy-menu-return-item): Find menu items with a nil command binding.
authorStefan Monnier <monnier@iro.umontreal.ca>
Wed, 1 Jun 2005 16:22:00 +0000 (16:22 +0000)
committerStefan Monnier <monnier@iro.umontreal.ca>
Wed, 1 Jun 2005 16:22:00 +0000 (16:22 +0000)
lisp/ChangeLog
lisp/emacs-lisp/easymenu.el

index 4ea507543e6f9120ca67ebedb34610eec2fc7604..264c627ef5499b12b6f6fa4afd90c336dc2c543f 100644 (file)
@@ -1,3 +1,8 @@
+2005-06-01  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * emacs-lisp/easymenu.el (easy-menu-return-item): Quick fix to find
+       menu items with a nil command binding.
+
 2005-06-01  Juanma Barranquero  <lekktu@gmail.com>
 
        * emacs-lisp/cl-macs.el (defsetf):
index b3160c9b7524fc611eac5667416acef247a98911..3602e7412f115f03e2673c7f4e563cd6da9b0e75 100644 (file)
@@ -1,6 +1,6 @@
 ;;; easymenu.el --- support the easymenu interface for defining a menu
 
-;; Copyright (C) 1994,96,98,1999,2000,2004  Free Software Foundation, Inc.
+;; Copyright (C) 1994,96,98,1999,2000,2004,2005  Free Software Foundation, Inc.
 
 ;; Keywords: emulations
 ;; Author: Richard Stallman <rms@gnu.org>
@@ -534,7 +534,7 @@ earlier by `easy-menu-define' or `easy-menu-create-menu'."
     (easy-menu-do-add-item map item before)))
 
 (defun easy-menu-item-present-p (map path name)
-  "In submenu of MAP with path PATH, return true iff item NAME is present.
+  "In submenu of MAP with path PATH, return non-nil iff item NAME is present.
 MAP and PATH are defined as in `easy-menu-add-item'.
 NAME should be a string, the name of the element to be looked for."
   (easy-menu-return-item (easy-menu-get-map map path) name))
@@ -552,7 +552,14 @@ NAME should be a string, the name of the element to be removed."
   "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))