Subject: bug#29272: 26.0.90; "C-h k C-mouse-3" followed by menu selection asks for more keys

From: Noam Postavsky <[email-masked]>
Date: Tue, 28 Nov 2017 19:50:28 -0500

Alan Mackenzie <[email-masked]> writes:

> The following patch attempts to catch and filter out obtrusive events.
> Could you try it out, please, even though it's not perfect (see below).
> It's based on the emacs-26 branch:
>
>
>
> diff --git a/lisp/help.el b/lisp/help.el
> index fbb9fc8cbe..d119615180 100644
> --- a/lisp/help.el
> +++ b/lisp/help.el
> @@ -728,11 +728,17 @@ help-read-key-sequence
>  Describe the following key, mouse click, or menu item: "))
>                  ((and (pred vectorp) (let `(,key0 . ,_) (aref key 0))
>                        (guard (symbolp key0)) (let keyname (symbol-name key0)))
> -                 (if no-mouse-movement
> -                     (string-match "mouse-movement" keyname)
> -                   (and (string-match "\\(mouse\\|down\\|click\\|drag\\)"
> -                                      keyname)
> -                        (not (sit-for (/ double-click-time 1000.0) t)))))))
> +                 (or
> +                  (and no-mouse-movement
> +                       (string-match "mouse-movement" keyname))
> +                  (and (string-match "\\(mouse\\|down\\|click\\|drag\\)"
> +                                     keyname)
> +                       (progn
> +                         ;; Discard events (e.g. <help-echo>) which might
> +                         ;; spuriously trigger the `sit-for'.
> +                         (sleep-for 0.001)
> +                         (while (read-event nil nil 0.001))
> +                         (not (sit-for (/ double-click-time 1000.0) t))))))))

I've tested this after it was applied to emacs-26 [1: 22ff46e6d8]; the
bug is fixed in --with-x-toolkit=gtk build and w32 builds, but not in a
--with-x-toolkit=lucid build.

[1: 22ff46e6d8]: 2017-11-27 19:28:28 -0500
  ; Fix some comment typos
  https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=22ff46e6d85e3f023eb84ef7e8fe3de8947caf81