summaryrefslogtreecommitdiff
path: root/lisp/menu-bar.el
diff options
context:
space:
mode:
authorSam Steingold <sds@gnu.org>2014-06-02 15:02:31 -0400
committerSam Steingold <sds@gnu.org>2014-06-02 15:02:31 -0400
commitcf3c1e2344f8ce18a8bfcab3396a28887c9764aa (patch)
treeeaf8aab6fe5c121b2a115cb5e79c88d77f3672a9 /lisp/menu-bar.el
parent2589f32c612bee1ad1a63d33f22b4781c64a23f1 (diff)
downloademacs-cf3c1e2344f8ce18a8bfcab3396a28887c9764aa.tar.gz
Avoid the type error on f10 when lookup-key returns an number.
* lisp/menu-bar.el (lookup-key-ignore-too-long): Extract from... (popup-menu): ...here. (menu-bar-open): Use it to avoid an error when `lookup-key' returns a number.
Diffstat (limited to 'lisp/menu-bar.el')
-rw-r--r--lisp/menu-bar.el19
1 files changed, 13 insertions, 6 deletions
diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el
index f9cbc62b464..efbeeb3579c 100644
--- a/lisp/menu-bar.el
+++ b/lisp/menu-bar.el
@@ -2140,6 +2140,13 @@ See `menu-bar-mode' for more information."
(declare-function x-menu-bar-open "term/x-win" (&optional frame))
(declare-function w32-menu-bar-open "term/w32-win" (&optional frame))
+(defun lookup-key-ignore-too-long (map key)
+ "Call `lookup-key' and convert numeric values to nil."
+ (let ((binding (lookup-key map key)))
+ (if (numberp binding) ; `too long'
+ nil
+ binding)))
+
(defun popup-menu (menu &optional position prefix from-menu-bar)
"Popup the given menu and call the selected option.
MENU can be a keymap, an easymenu-style menu or a list of keymaps as for
@@ -2192,11 +2199,9 @@ FROM-MENU-BAR, if non-nil, means we are dropping one of menu-bar's menus."
(let ((mouse-click (apply 'vector event))
binding)
(while (and map (null binding))
- (setq binding (lookup-key (car map) mouse-click))
- (if (numberp binding) ; `too long'
- (setq binding nil))
+ (setq binding (lookup-key-ignore-too-long (car map) mouse-click))
(setq map (cdr map)))
- binding))
+ binding))
(t
;; We were given a single keymap.
(lookup-key map (apply 'vector event)))))
@@ -2270,8 +2275,10 @@ If FRAME is nil or not given, use the selected frame."
(let* ((x tty-menu--initial-menu-x)
(menu (menu-bar-menu-at-x-y x 0 frame)))
(popup-menu (or
- (lookup-key global-map (vector 'menu-bar menu))
- (lookup-key (current-local-map) (vector 'menu-bar menu))
+ (lookup-key-ignore-too-long
+ global-map (vector 'menu-bar menu))
+ (lookup-key-ignore-too-long
+ (current-local-map) (vector 'menu-bar menu))
(cdar (minor-mode-key-binding (vector 'menu-bar menu))))
(posn-at-x-y x 0 nil t) nil t)))
(t (with-selected-frame (or frame (selected-frame))