Subject: bug#6256: 24.0.50; read-event in `repeat' command

From: Stefan Monnier <[email-masked]>
Date: Wed, 20 Oct 2010 11:47:49 -0400

> I tried debugging it that way.  I added this just after the (let ((evt
> (read-key))), that is BEFORE the `and' test of the `while':
> (message "EVT: %S, R-R-CHAR: %S" evt repeat-repeat-char)

That sounds right.

> And because it exits immediately _no_ debug message appears in *Messages*.

That's very odd.

> That tells me that it exited during `read-key', not
> because the event/key tested did not match (`while' test = nil).

That's one possibility, indeed, tho maybe the code never gets to
read-key at all.

> Apparently `read-key' itself exits out to the `unwind-protect'
> protection code in this scenario.

That's only if it signals an error, which you should then see somewhere.

> In emacs -Q, however, with just the Bookmark+ files loaded, I do not
> see the problem.  That is presumably what you are seeing.

Indeed.  So it does work for you in Emacs-23, tho only for the case of
"emacs -Q"?  If so, you may want to try and do the binary-search dance
on your .emacs to see what's interfering.

> Perhaps you can suggest something I can do to determine what is
> happening that causes it (presumably) to exit the `while' during the
> `read-key', jumping out to the `unwind-protect'.  Is there some debug
> message I can put at the beginning of the the `unwind-protect'
> protection code to see what happened?  Can I put some debug stuff into
> `read-key'?

You can start by adding various `message' calls around the while, inside
the while, around the read-key call, etc...
Using edebug in this code is sadly problematic, so we're left with
print-debugging.

> You still have not said anything about what's wrong with that solution.

It does not work for me (i.e. for X11 mouse wheel events).

> Again (coming back to my question), this is what I suggested:

> (while (let ((evt  (read-event)))
>          (and (equal (event-basic-type evt)
>                      (event-basic-type repeat-repeat-char))
>               (equal (event-modifiers evt)
>                      (event-modifiers repeat-repeat-char))))
>   (repeat repeat-arg))

You could also try

 (while (let ((evt  (read-event)))
          (message "EVT: %S, R-R-CHAR: %S" evt repeat-repeat-char)
          (and (equal (event-basic-type evt)
                      (event-basic-type repeat-repeat-char))
               (equal (event-modifiers evt)
                      (event-modifiers repeat-repeat-char))))
   (repeat repeat-arg))

> It's pretty simple.  It also seems logical, and it says just what we
> want to be done: if the event's components are all the same as before
> then repeat.  Dunno why you have a problem with this.  What problems
> do you see with this approach?

That on X11, the second event is *not* the same as the first because
mouse wheel send first a down and then an up event.

        Stefan