Subject: 24.2.92; tabulated-list header buttons are broken

From: Jonas Bernoulli <[email-masked]>
Date: Sat, 26 Jan 2013 19:31:27 +0100

Starting with 24.2.92 clicking on a column button created by a
Tabulated-List mode derived mode does not sort correctly anymore.

When clicking the first time the order should not be reversed, but it
is.  Clicking some more does not change the order, it stays reversed.  I
looked into why this is so and noticed that the command the mouse event
is bound to is actually called twice.

Thinking that for some reason clicking on the button on the header-line
generates two events I modified tabulated-list-sort-button-map to only
contain a binding for [header-line mouse-1].  Then I clicked again with
the mouse button 1 and got the following warning in the echo area:

,----
| <header-line> <mouse-2> is undefined
`----

It mentions mouse-2 even though I pressed mouse-1.  Also the message did
not appear in *Messages* and I could not get a backtrace after turning
on debug-on-error.

To check whether this is specific to Tabulated-List mode I tried the
following:

,----
| (setq header-line-format
|       (propertize "button"
|                   'keymap (let ((map (make-sparse-keymap)))
|                             (define-key map [header-line mouse-1]
|                               (lambda (e)
|                                 (interactive "e")
|                                 (message "%s" e)))
|                             map)))
`----

Here everything works as expected: I don't get a warning about mouse-2
not being undefined, the command is only called once and it reports that
mouse-1 was pressed.

  Jonas