bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#12204: 24.1.50; Binding mouse-movement interferes with "C-h c" for m


From: npostavs
Subject: bug#12204: 24.1.50; Binding mouse-movement interferes with "C-h c" for mouse clicks
Date: Sat, 24 Jun 2017 23:18:03 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux)

tags 12204 + patch
quit

Eli Zaretskii <address@hidden> writes:

>> From: Noam Postavsky <address@hidden>
>> Date: Mon, 12 Jun 2017 13:15:24 -0400
>> Cc: address@hidden
>> 
>> > I was actually thinking seriously to not show the help message for
>> > mouse-movement bindings.  Would that break something important?
>> 
>> It should only break discovery of what's bound to <mouse-movement> I
>> guess, and we could still leave "C-h k" for that so it shouldn't be
>> much of a problem.
>
> Then I think this is what we should do, and perhaps leave some knob to
> get back the old behavior.

Here are some patches, the first deduplicates the code of describe-key
and describe-key-briefly since they had some almost-identical sections
that confused me when I started by accidentally modifying the wrong one.

The second patch just ignores mouse-movement for "C-h c", I don't think
it's worth an option to get the old behaviour, but it's easy enough to
add it if you want.

Attachment: 0001-Refactor-key-describing-commands.patch
Description: patch

>From f44c0dfe8bd29374a980848db29890c1438fe3f3 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <address@hidden>
Date: Sun, 18 Jun 2017 00:39:05 -0400
Subject: [PATCH 2/2] Ignore mouse-movement for describe-key-briefly
 (Bug#12204)

* lisp/help.el (help-read-key-sequence): Add optional argument ot
ignore `mouse-movement' events.
(describe-key-briefly): Use it.
* doc/emacs/help.texi (Key Help):
* etc/NEWS: Mention that mouse movement is ignored.
---
 doc/emacs/help.texi |  7 ++++---
 etc/NEWS            |  3 +++
 lisp/help.el        | 18 ++++++++++++------
 3 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/doc/emacs/help.texi b/doc/emacs/help.texi
index 548ca6a1b4..fd6df1c7e5 100644
--- a/doc/emacs/help.texi
+++ b/doc/emacs/help.texi
@@ -203,9 +203,10 @@ Key Help
 describes the command corresponding to @var{key}.
 
   @kbd{C-h c}, @kbd{C-h k} and @kbd{C-h K} work for any sort of key
-sequences, including function keys, menus, and mouse events.  For
-instance, after @kbd{C-h k} you can select a menu item from the menu
-bar, to view the documentation string of the command it runs.
+sequences, including function keys, menus, and mouse events (except
+that @kbd{C-h c} ignores mouse movement events).  For instance, after
address@hidden k} you can select a menu item from the menu bar, to view the
+documentation string of the command it runs.
 
 @kindex C-h w
 @findex where-is
diff --git a/etc/NEWS b/etc/NEWS
index 60c98a35c0..281bacffd0 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -373,6 +373,9 @@ use the local Emacs to edit remote files via Tramp.  See 
the node
 "emacsclient Options" in the user manual for the details.
 
 +++
+** 'describe-key-briefly' now ignores mouse movement events.
+
++++
 ** The new variable 'eval-expression-print-maximum-character' prevents
 large integers from being displayed as characters.
 
diff --git a/lisp/help.el b/lisp/help.el
index 24e07662e8..dc341b0635 100644
--- a/lisp/help.el
+++ b/lisp/help.el
@@ -636,7 +636,9 @@ (defun describe-key-briefly (&optional key insert 
untranslated)
 If KEY is a menu item or a tool-bar button that is disabled, this command
 temporarily enables it to allow getting help on disabled items and buttons."
   (interactive
-   (pcase-let ((`(,key ,_up-event) (help-read-key-sequence)))
+   ;; Ignore mouse movement events because it's too easy to miss the
+   ;; message while moving the mouse.
+   (pcase-let ((`(,key ,_up-event) (help-read-key-sequence 
'no-mouse-movement)))
      `(,key ,current-prefix-arg 1)))
   (princ (car (help--analyze-key key untranslated))
          (if insert (current-buffer) standard-output)))
@@ -704,11 +706,13 @@ (defun help--binding-locus (key position)
                (throw 'found x))))
           nil)))))
 
-(defun help-read-key-sequence ()
+(defun help-read-key-sequence (&optional no-mouse-movement)
   "Reads a key sequence from the user.
 Returns a list of the form (KEY UP-EVENT), where KEY is the key
 sequence, and UP-EVENT is the up-event that was discarded by
-reading KEY, or nil."
+reading KEY, or nil.
+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)
         saved-yank-menu)
@@ -724,9 +728,11 @@ (defun 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)))
-                 (and (string-match "\\(mouse\\|down\\|click\\|drag\\)"
-                                    keyname)
-                      (not (sit-for (/ double-click-time 1000.0) t))))))
+                 (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)))))))
           (list
            key
            ;; If KEY is a down-event, read and include the
-- 
2.11.1


reply via email to

[Prev in Thread] Current Thread [Next in Thread]