From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#29478: [Patch 2]: bug#29478: 26.0.90; `C-h k' followed by mouse clicks no longer shows down event Date: Sat, 23 Dec 2017 14:28:09 +0000 Message-ID: <20171223142809.GB6618@ACM> References: <1b3879d6-f14e-47b0-970f-baf09598fcfd@default> <871skjnpd8.fsf@users.sourceforge.net> <20171128221036.GC14868@ACM> <83o9ni3l3i.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1514039362 25364 195.159.176.226 (23 Dec 2017 14:29:22 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 23 Dec 2017 14:29:22 +0000 (UTC) User-Agent: Mutt/1.7.2 (2016-11-26) Cc: 29478@debbugs.gnu.org, npostavs@users.sourceforge.net To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Dec 23 15:29:17 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eSknb-0006G1-SE for geb-bug-gnu-emacs@m.gmane.org; Sat, 23 Dec 2017 15:29:16 +0100 Original-Received: from localhost ([::1]:42177 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eSkpa-0000fl-EN for geb-bug-gnu-emacs@m.gmane.org; Sat, 23 Dec 2017 09:31:18 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44087) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eSkpO-0000e8-Lo for bug-gnu-emacs@gnu.org; Sat, 23 Dec 2017 09:31:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eSkpK-0001V8-Kl for bug-gnu-emacs@gnu.org; Sat, 23 Dec 2017 09:31:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:40154) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eSkpK-0001Uj-Gz for bug-gnu-emacs@gnu.org; Sat, 23 Dec 2017 09:31:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eSkpK-0001zb-Al for bug-gnu-emacs@gnu.org; Sat, 23 Dec 2017 09:31:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 23 Dec 2017 14:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 29478 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Original-Received: via spool by 29478-submit@debbugs.gnu.org id=B29478.15140394137597 (code B ref 29478); Sat, 23 Dec 2017 14:31:02 +0000 Original-Received: (at 29478) by debbugs.gnu.org; 23 Dec 2017 14:30:13 +0000 Original-Received: from localhost ([127.0.0.1]:48835 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eSkoW-0001yR-Pn for submit@debbugs.gnu.org; Sat, 23 Dec 2017 09:30:13 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:43541 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1eSkoU-0001xQ-Ol for 29478@debbugs.gnu.org; Sat, 23 Dec 2017 09:30:11 -0500 Original-Received: (qmail 89290 invoked by uid 3782); 23 Dec 2017 14:30:07 -0000 Original-Received: from acm.muc.de (p548C7AB5.dip0.t-ipconnect.de [84.140.122.181]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 23 Dec 2017 15:30:06 +0100 Original-Received: (qmail 21804 invoked by uid 1000); 23 Dec 2017 14:28:09 -0000 Content-Disposition: inline In-Reply-To: <83o9ni3l3i.fsf@gnu.org> X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:141426 Archived-At: Hello, Eli. On Fri, Dec 01, 2017 at 10:31:45 +0200, Eli Zaretskii wrote: > > Date: Tue, 28 Nov 2017 20:33:00 -0800 (PST) > > From: Drew Adams > > Cc: 29478@debbugs.gnu.org > > > > > The down mouse-button event is no longer listed along with the up > > > > > event when you use `C-h k' with a click event. Dunno whether this > > > > > was by design or is an oversight. > > > I think if you press and hold the mouse button for (default) half a > > > second, when you finally release it, C-h k will report the down mouse > > > event. At least this is how GPM behaves for me on a Linux tty. > > Ah yes, thanks. I see that now on MS Windows too. > > > This seems to make sense, because anything bound to a down mouse > > > event is going to be something like a drag event, where the mouse > > > button is held for an extended period of time. > > Sorry, no, I don't buy that. I mean it's probably true that > > most such bindings involve dragging. But (1) a user who wants > > to check what `mouse-N' does won't necessarily use it the same > > way when checking with `C-h k' as when using it for its real > > purpose. And (2) the problem with this is that it is not > > easily discoverable. > > I've used Emacs for quite a while. OK, I expected both up and > > down to be documented. But even I would likely never have > > thought to hold the button pressed for a long time before > > releasing, just to see what `C-h k' had to tell me. > Alan, can we arrange for the doc string of mouse-N clicks (with or > without all the possible modifiers) to say something like > For documentation of the corresponding mouse-down event, click and > hold the mouse button longer than %s sec. > (where %s gets replaced by double-click-time)? Yes, we can indeed. The following patch is intended to achieve this. It's based on the emacs-26 branch. I've also corrected the bug where the possibility of double-click-time being nil or t wasn't taken into account. Should I commit this one to emacs-26, too? diff --git a/lisp/help.el b/lisp/help.el index 212e3679da..3f013e8170 100644 --- a/lisp/help.el +++ b/lisp/help.el @@ -738,7 +738,11 @@ help-read-key-sequence ;; spuriously trigger the `sit-for'. (sleep-for 0.01) (while (read-event nil nil 0.01)) - (not (sit-for (/ double-click-time 1000.0) t)))))))) + (not (sit-for + (if (numberp double-click-time) + (/ double-click-time 1000.0) + 3.0) + t)))))))) (list key ;; If KEY is a down-event, read and include the @@ -769,6 +773,28 @@ help-read-key-sequence (setq yank-menu (copy-sequence saved-yank-menu)) (fset 'yank-menu (cons 'keymap yank-menu)))))) +(defun help-downify-mouse-event-type (base) + "Add \"down-\" to BASE if it is not already there. +BASE is a symbol, a mouse event type. If the modification is done, +return the new symbol. Otherwise return nil." + (let ((base-s (symbol-name base))) + ;; Note: the order of the components in the following string is + ;; determined by `apply_modifiers_uncached' in src/keyboard.c. + (string-match "\\(A-\\)?\ +\\(C-\\)?\ +\\(H-\\)?\ +\\(M-\\)?\ +\\(S-\\)?\ +\\(s-\\)?\ +\\(double-\\)?\ +\\(triple-\\)?\ +\\(up-\\)?\ +\\(\\(down-\\)?\\)\ +\\(\\(drag-\\)?\\)" base-s) + (when (and (zerop (length (match-string 10 base-s))) ; "down-" + (zerop (length (match-string 12 base-s)))) ; "drag-" + (intern (replace-match "down-" t t base-s 10)) ))) + (defun describe-key (&optional key untranslated up-event) "Display documentation of the function invoked by KEY. KEY can be any kind of a key sequence; it can include keyboard events, @@ -828,6 +854,24 @@ describe-key (princ (format " (found in %s)" key-locus)))) (princ ", which is ") (describe-function-1 defn) + (when (vectorp key) + (let* ((last (1- (length key))) + (elt (aref key last)) + (elt-1 (copy-sequence elt)) + key-1 down-event-type) + (when (and (eventp elt) + (setq down-event-type (help-downify-mouse-event-type + (car elt)))) + (setcar elt-1 down-event-type) + (setq key-1 (vector elt-1)) + (when (key-binding key-1) + (princ (format " + +For documentation of the corresponding mouse down event <%s>, +click and hold the mouse button longer than %s second(s)." + down-event-type (if (numberp double-click-time) + (/ double-click-time 1000.0) + 3))))))) (when up-event (unless (or (null defn-up) (integerp defn-up) -- Alan Mackenzie (Nuremberg, Germany).