changeset 12553:ce881909d36a

(mouse-major-mode-menu): Catch quit in read-key-sequence. (mouse-major-mode-menu): Don't call command-execute if lookup-key gives nil.
author Karl Heuer <kwzh@gnu.org>
date Mon, 17 Jul 1995 22:47:19 +0000
parents 176c42cc7eeb
children fdc58e7e37c2
files lisp/mouse.el
diffstat 1 files changed, 13 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/mouse.el	Mon Jul 17 22:46:25 1995 +0000
+++ b/lisp/mouse.el	Mon Jul 17 22:47:19 1995 +0000
@@ -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)