diff options
| author | Sam Steingold | 2014-06-02 15:02:31 -0400 |
|---|---|---|
| committer | Sam Steingold | 2014-06-02 15:02:31 -0400 |
| commit | cf3c1e2344f8ce18a8bfcab3396a28887c9764aa (patch) | |
| tree | eaf8aab6fe5c121b2a115cb5e79c88d77f3672a9 | |
| parent | 2589f32c612bee1ad1a63d33f22b4781c64a23f1 (diff) | |
| download | emacs-cf3c1e2344f8ce18a8bfcab3396a28887c9764aa.tar.gz emacs-cf3c1e2344f8ce18a8bfcab3396a28887c9764aa.zip | |
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.
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/menu-bar.el | 19 |
2 files changed, 20 insertions, 6 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index d6216918843..9e1ccce988d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2014-06-02 Sam Steingold <sds@gnu.org> | ||
| 2 | |||
| 3 | * menu-bar.el (lookup-key-ignore-too-long): Extract from... | ||
| 4 | (popup-menu): ...here. | ||
| 5 | (menu-bar-open): Use it to avoid an error when `lookup-key' | ||
| 6 | returns a number. | ||
| 7 | |||
| 1 | 2014-06-02 Michael Albinus <michael.albinus@gmx.de> | 8 | 2014-06-02 Michael Albinus <michael.albinus@gmx.de> |
| 2 | 9 | ||
| 3 | * net/tramp.el (tramp-call-process): Add traces. | 10 | * net/tramp.el (tramp-call-process): Add traces. |
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." | |||
| 2140 | (declare-function x-menu-bar-open "term/x-win" (&optional frame)) | 2140 | (declare-function x-menu-bar-open "term/x-win" (&optional frame)) |
| 2141 | (declare-function w32-menu-bar-open "term/w32-win" (&optional frame)) | 2141 | (declare-function w32-menu-bar-open "term/w32-win" (&optional frame)) |
| 2142 | 2142 | ||
| 2143 | (defun lookup-key-ignore-too-long (map key) | ||
| 2144 | "Call `lookup-key' and convert numeric values to nil." | ||
| 2145 | (let ((binding (lookup-key map key))) | ||
| 2146 | (if (numberp binding) ; `too long' | ||
| 2147 | nil | ||
| 2148 | binding))) | ||
| 2149 | |||
| 2143 | (defun popup-menu (menu &optional position prefix from-menu-bar) | 2150 | (defun popup-menu (menu &optional position prefix from-menu-bar) |
| 2144 | "Popup the given menu and call the selected option. | 2151 | "Popup the given menu and call the selected option. |
| 2145 | MENU can be a keymap, an easymenu-style menu or a list of keymaps as for | 2152 | 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." | |||
| 2192 | (let ((mouse-click (apply 'vector event)) | 2199 | (let ((mouse-click (apply 'vector event)) |
| 2193 | binding) | 2200 | binding) |
| 2194 | (while (and map (null binding)) | 2201 | (while (and map (null binding)) |
| 2195 | (setq binding (lookup-key (car map) mouse-click)) | 2202 | (setq binding (lookup-key-ignore-too-long (car map) mouse-click)) |
| 2196 | (if (numberp binding) ; `too long' | ||
| 2197 | (setq binding nil)) | ||
| 2198 | (setq map (cdr map))) | 2203 | (setq map (cdr map))) |
| 2199 | binding)) | 2204 | binding)) |
| 2200 | (t | 2205 | (t |
| 2201 | ;; We were given a single keymap. | 2206 | ;; We were given a single keymap. |
| 2202 | (lookup-key map (apply 'vector event))))) | 2207 | (lookup-key map (apply 'vector event))))) |
| @@ -2270,8 +2275,10 @@ If FRAME is nil or not given, use the selected frame." | |||
| 2270 | (let* ((x tty-menu--initial-menu-x) | 2275 | (let* ((x tty-menu--initial-menu-x) |
| 2271 | (menu (menu-bar-menu-at-x-y x 0 frame))) | 2276 | (menu (menu-bar-menu-at-x-y x 0 frame))) |
| 2272 | (popup-menu (or | 2277 | (popup-menu (or |
| 2273 | (lookup-key global-map (vector 'menu-bar menu)) | 2278 | (lookup-key-ignore-too-long |
| 2274 | (lookup-key (current-local-map) (vector 'menu-bar menu)) | 2279 | global-map (vector 'menu-bar menu)) |
| 2280 | (lookup-key-ignore-too-long | ||
| 2281 | (current-local-map) (vector 'menu-bar menu)) | ||
| 2275 | (cdar (minor-mode-key-binding (vector 'menu-bar menu)))) | 2282 | (cdar (minor-mode-key-binding (vector 'menu-bar menu)))) |
| 2276 | (posn-at-x-y x 0 nil t) nil t))) | 2283 | (posn-at-x-y x 0 nil t) nil t))) |
| 2277 | (t (with-selected-frame (or frame (selected-frame)) | 2284 | (t (with-selected-frame (or frame (selected-frame)) |