]> git.eshelyaron.com Git - emacs.git/commitdiff
(mouse-major-mode-menu): Catch quit in read-key-sequence.
authorKarl Heuer <kwzh@gnu.org>
Mon, 17 Jul 1995 22:47:19 +0000 (22:47 +0000)
committerKarl Heuer <kwzh@gnu.org>
Mon, 17 Jul 1995 22:47:19 +0000 (22:47 +0000)
(mouse-major-mode-menu): Don't call command-execute
if lookup-key gives nil.

lisp/mouse.el

index 84daf4b4a91744386857384f32afab4c6fdc2323..a52d0d14213ebebb46596031c6fec139fc07cd4d 100644 (file)
              (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)