From: Stefan Monnier Date: Fri, 10 May 2019 12:49:03 +0000 (-0400) Subject: * lisp/help.el (help--read-key-sequence): Handle `switch-frame' events X-Git-Tag: emacs-27.0.90~2926 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=655634808ad3b324ab844c53006e648b45713364;p=emacs.git * lisp/help.el (help--read-key-sequence): Handle `switch-frame' events If you do `C-h k ... mouse-1 in other frame` (at least if you have a focus that follows the mouse), then additionally to the down-mouse-1 and mouse-1 events, a `switch-frame` event (and `select-window` event as well sometimes) is generated. When `read-key-sequence` is called with nil for `can-return-switch-frame`, this event is not returned but kept for later, which causes a subsequent `sit-for` to return nil immediately. This interfered without our "wait for double-click" which in turn prevented us from stopping after the mouse-1 click, getting stuck waiting for something else instead. (help--read-key-sequence): Pass a non-nil `can-return-switch-frame`, so the subsequent `sit-for` returns more trustworthy information. --- diff --git a/lisp/help.el b/lisp/help.el index 2b7eca9363e..42ff3755650 100644 --- a/lisp/help.el +++ b/lisp/help.el @@ -745,6 +745,7 @@ If NO-MOUSE-MOVEMENT is non-nil, ignore key sequences starting with `mouse-movement' events." (let ((enable-disabled-menus-and-buttons t) (cursor-in-echo-area t) + (side-event nil) saved-yank-menu) (unwind-protect (let (last-modifiers key-list) @@ -763,7 +764,8 @@ with `mouse-movement' events." (and (memq 'click last-modifiers) (not (sit-for (/ double-click-time 1000.0) t)))) (let* ((seq (read-key-sequence "\ -Describe the following key, mouse click, or menu item: ")) +Describe the following key, mouse click, or menu item: " + nil nil 'can-return-switch-frame)) (raw-seq (this-single-command-raw-keys)) (keyn (when (> (length seq) 0) (aref seq (1- (length seq))))) @@ -772,11 +774,18 @@ Describe the following key, mouse click, or menu item: ")) (cond ((zerop (length seq))) ;FIXME: Can this happen? ((and no-mouse-movement (eq base 'mouse-movement)) nil) + ((memq base '(mouse-movement switch-frame select-window)) + ;; Mostly ignore these events since it's sometimes difficult to + ;; generate the event you care about without also generating + ;; these side-events along the way. + (setq side-event (cons seq raw-seq))) ((eq base 'help-echo) nil) (t (setq last-modifiers modifiers) (push (cons seq raw-seq) key-list))))) - (nreverse key-list)) + (if side-event + (cons side-event (nreverse key-list)) + (nreverse key-list))) ;; Put yank-menu back as it was, if we changed it. (when saved-yank-menu (setq yank-menu (copy-sequence saved-yank-menu))