From e26815c37e16b15af699bd186c1271081c46346c Mon Sep 17 00:00:00 2001 From: Karl Heuer Date: Mon, 17 Jul 1995 22:47:19 +0000 Subject: [PATCH] (mouse-major-mode-menu): Catch quit in read-key-sequence. (mouse-major-mode-menu): Don't call command-execute if lookup-key gives nil. --- lisp/mouse.el | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/lisp/mouse.el b/lisp/mouse.el index 84daf4b4a91..a52d0d14213 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -55,13 +55,19 @@ (and (current-local-map) (lookup-key (current-local-map) [menu-bar]))))) (mouse-major-mode-menu-compute-equiv-keys newmap) - (command-execute - ;; Make NEWMAP override the usual definition - ;; of the mouse button that got us here. - ;; Then read the user's menu choice. - (let ((minor-mode-map-alist - (cons (cons t newmap) minor-mode-map-alist))) - (lookup-key newmap (read-key-sequence "")))))) + ;; Make NEWMAP override the usual definition + ;; of the mouse button that got us here. + ;; Then read the user's menu choice. + (let* ((minor-mode-map-alist + (cons (cons t newmap) minor-mode-map-alist)) + ;; read-key-sequence quits if the user aborts the menu. + ;; If that happens, do nothing silently. + (keyseq (condition-case nil + (read-key-sequence "") + (quit nil))) + (command (if keyseq (lookup-key newmap keyseq)))) + (if command + (command-execute command))))) ;; Compute and cache the equivalent keys in MENU and all its submenus. (defun mouse-major-mode-menu-compute-equiv-keys (menu) -- 2.39.2