From: "Drew Adams" <drew.adams@oracle.com>
To: "'Stefan Monnier'" <monnier@iro.umontreal.ca>
Cc: 6256@debbugs.gnu.org
Subject: bug#6256: 24.0.50; read-event in `repeat' command
Date: Wed, 20 Oct 2010 13:55:35 -0700 [thread overview]
Message-ID: <08402D206B354E10BD8F86D4CD5FA9E8@us.oracle.com> (raw)
In-Reply-To: <jwv7hhcho3z.fsf-monnier+emacs@gnu.org>
> > 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.
This is what I used:
(unwind-protect
(while (let ((evt (read-key)))
(message "EVT: %S, R-R-CHAR: %S"
evt repeat-repeat-char)
(eq (or (car-safe evt) evt)
(or (car-safe repeat-repeat-char)
repeat-repeat-char)))
(repeat repeat-arg))
(setq repeat-undo-count nil))
The only time that code is not entered is if `repeat-repeat-char' is nil (since
the code is inside the (when repeat-repeat-char...)).
And if that code is entered then the only time `message' is not invoked is if
`read-key' barfs.
> > 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.
I saw no error messages in *Messages*.
Perhaps we can conclude that `repeat-repeat-char' was nil. Since I have
`repeat-on-final-keystroke'=t (the default), that in turn means that
`last-command-event' was nil. Does that help you see what went wrong?
`last-command-event' takes us into C code (and perhaps into your code for
`read-key'?). I can't help much with that. As I suggested, this might have to
do with other things such as my using a standalone minibuffer. Dunno.
> > 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.
I really don't want to try that for this, if I can avoid it.
> > 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).
Ah. I see. That's the first I heard of it.
I was thinking that that code would work because it remains abstract (in
principle). It just decomposes the event into its components and compares
those. There is (in principle) nothing platform-specific about it.
But I see from what you say below that the problem is that on X (and maybe on
some other platforms?) wheel events cannot be treated abstractly without some
massaging first. They have a different form depending on whether they are the
first of a series.
That form difference might be useful for X (?), and maybe it could sometimes be
useful for Emacs (?), but it is just an obstacle in this context. In general
(and in particular here) I don't think that Emacs has any need to distinguish
the first wheel event in a given direction from subsequent ones in the same
direction.
IOW, the problem is not that X uses different event names from Windows for its
wheel events. The problem (here) is that X uses different event names for the
_same_ wheel action (rotation in a given direction).
> 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.
I see. So it sounds like we need an abstraction to deal with that - I'd think
that would be useful anyway. After all, there is no good reason to distinguish
the first wheel rotation (in a given direction). At least there is no good
reason to _always_ do that, even if someone might find a reason why that might
be useful sometimes.
The modifiers that I wanted to compare in the `while' test are only the
`control', `meta', `shift', `double', etc. modifiers. In the case of a wheel
event we could safely abstract from any `down' or `up' modifiers (here, at
least), AFAIK - they don't mean anything here.
What about defining a function that maps X wheel events to "Emacs" wheel events
that strip the `down' and `up' modifiers? And then using that function here?
But that means being able to recognize a wheel event as such - any wheel event.
We don't want to strip `down' or `up' from any non-wheel mouse events. That
recognition should be possible using the vars `mouse-wheel-(up|down)-event'.
Can you use something like this to make the decomposing-read-event approach work
for X?
(defun wheel-event (event)
"Return EVENT, with modifiers `down' and `up' removed if a wheel event."
(if (memq (event-basic-type event)
(list mouse-wheel-up-event
mouse-wheel-down-event))
event
(event-convert-list
(delq 'down (delq 'up (event-modifiers event))))))
next prev parent reply other threads:[~2010-10-20 20:55 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-24 15:11 bug#6256: 24.0.50; read-event in `repeat' command Drew Adams
2010-05-24 16:28 ` Drew Adams
2010-05-24 23:05 ` Drew Adams
2010-05-25 0:06 ` Lennart Borgman
2010-05-25 2:41 ` Stefan Monnier
2010-07-03 21:24 ` Drew Adams
2010-07-04 22:45 ` Stefan Monnier
2010-07-07 14:43 ` Drew Adams
2010-07-21 15:54 ` Drew Adams
2010-08-28 15:19 ` Drew Adams
2010-09-11 18:25 ` Stefan Monnier
2010-09-11 22:34 ` Drew Adams
2010-09-12 16:06 ` Drew Adams
2010-09-17 3:34 ` Drew Adams
2010-09-22 14:01 ` bug#6256: [PATCH] " Drew Adams
2010-09-25 14:30 ` Drew Adams
2010-10-18 18:40 ` Stefan Monnier
2010-10-18 21:12 ` Drew Adams
2010-10-19 1:13 ` Stefan Monnier
2010-10-19 6:50 ` Jan Djärv
2010-10-19 14:03 ` Drew Adams
[not found] ` <jwv4ocjuvm1.fsf-monnier+emacs@gnu.org>
[not found] ` <0658C0CCC79D466BA9DE233F5980CAE5@us.oracle.com>
[not found] ` <jwvpqv7rp50.fsf-monnier+emacs@gnu.org>
2010-10-19 19:21 ` Drew Adams
2010-10-19 20:54 ` Stefan Monnier
2010-10-19 22:17 ` Drew Adams
2010-10-20 15:47 ` Stefan Monnier
2010-10-20 20:55 ` Drew Adams [this message]
2010-10-21 1:08 ` Stefan Monnier
2010-10-22 18:43 ` Drew Adams
2010-10-22 19:47 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=08402D206B354E10BD8F86D4CD5FA9E8@us.oracle.com \
--to=drew.adams@oracle.com \
--cc=6256@debbugs.gnu.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.