Subject: bug#14793: 23.4; Cannot bind a function to a sequence of two mouse keys

From: Stefano Lodi <[email-masked]>
Date: Thu, 4 Jul 2013 19:14:35 +0200

This bug report will be sent to the Free Software Foundation,
not to your local site managers!
Please write in English if possible, because the Emacs maintainers
usually do not have translators to read other languages for them.

Your report will be posted to the [email-masked] mailing list
and the gnu.emacs.bug news group, and at http://debbugs.gnu.org.

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug.  If you can, give
a recipe starting from `emacs -Q':

The manual states at the end of Section 48.3.10 "Rebinding Mouse Buttons"
says "You can put more than one mouse button in a key sequence, but it
isn't usual to do so."

I failed to bind a simple function to a sequence of two mouse keys.

> emacs -Q

inside the *scratch* buffer, evaluate:

(defun go-backwards ()
            "Go backward one word."
            (interactive)
            (backward-word 1))
(global-unset-key [mouse-3])
(global-set-key [mouse-3 mouse-2] 'go-backwards)

Now, pressing the right mouse button gives the message

Empty menu

at the bottom of the Emacs screen.

If I evaluate

(setq debug-on-error t)

and press the right button again I get just

Debugger entered--Lisp error: (error "Empty menu")

However, after evaluating

(global-set-key [mouse-3] 'go-backwards)

pressing the right mouse button does indeed move the point backward one
word; therefore binding a single mouse key works.

Another way to obtain the same result is the following.

Evaluate

(defun go-backwards ()
            "Go backward one word."
            (interactive)
            (backward-word 1))
(global-unset-key [mouse-3])
(defvar my-map (make-sparse-keymap))
(define-key my-map [mouse-2] 'go-backwards)

Now, C-h v my-map gives clearly

my-map's value is (keymap
 (mouse-2 . go-backwards))

Then evaluating

(define-key global-map [mouse-3] my-map)

gives

(keymap (mouse-2 . go-backwards))

at the bottom of the Emacs screen. However, again the right button gives
"Empty menu".