Subject: Re: bug#24755: 25.1; Selection continues with no mouse button pressed
From: Stefan Monnier <[email-masked]>
To: Eli Zaretskii <[email-masked]>
Cc: [email-masked], Mats Palmgren <[email-masked]>
Date: Wed, 26 Oct 2016 15:29:55 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

> Stefan, could you please fix this?  It seems to be due to changes in
> how mouse-drag-track handles mouse events: in Emacs 24.5, the code
> handled mouse clicks as well, whereas now it doesn't seem to.  So
> releasing the mouse button while Ctrl or Shift is pressed signals an
> error now, instead of finishing the drag event.

> The fix should go to the emacs-25 branch.

I pushed the patch below to emacs-25, which should fix it.

        Stefan

diff --git a/lisp/subr.el b/lisp/subr.el
index 573f238..07909b8 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -4507,8 +4507,10 @@ set-transient-map
                         ;; exit C-u.
                         t)
                        ((eq t keep-pred)
-                        (eq this-command
-                            (lookup-key map (this-command-keys-vector))))
+                        (let ((mc (lookup-key map (this-command-keys-vector))))
+                          ;; If the key is unbound `this-command` is
+                          ;; nil and so is `mc`.
+                          (and mc (eq this-command mc))))
                        (t (funcall keep-pred)))
                 (funcall exitfun)))))
     (add-hook 'pre-command-hook clearfun)