[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debbugs-tracker] bug#10190: closed (eventp can give incorrect results (

From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#10190: closed (eventp can give incorrect results (subr.el), Emacs 23 and 24)
Date: Thu, 19 Jul 2012 06:32:01 +0000

Your message dated Thu, 19 Jul 2012 02:25:19 -0400
with message-id <address@hidden>
and subject line Re: bug#10190: eventp can give incorrect results (subr.el), 
Emacs 23 and 24
has caused the debbugs.gnu.org bug report #10190,
regarding eventp can give incorrect results (subr.el), Emacs 23 and 24
to be marked as done.

(If you believe you have received this mail in error, please contact

10190: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=10190
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: eventp can give incorrect results (subr.el), Emacs 23 and 24 Date: Fri, 2 Dec 2011 00:55:11 -0500 This is not a major problem, but it did come up for me in a real program.
In Emacs 23 and 24, the function eventp in subr.el can give incorrect results
for symbolic events, depending on the timing of the call.  This seems to
occurs because event symbol elements (mask, modifiers, basic type) are stored in a plist
associated with symbolic events, but the list is set in the function
internal-event-symbol-parse-modifiers, which is only called in the function
event-modifiers not in the inline function eventp.  Hence, code that tests for
an event before checking the modifiers can give the wrong results, e.g.,

           (cond  ((integerp c) ...) 
                      ((eventp )  (do-something-with (event-modfiers c)))
                          (not-what-we-want-with c)))

will fail when c is a symbolic event that has not been parsed before.

Consider the following sequence, which illustrates the error in a new Emacs 24
session with -Q (on Mac OS X 10.5.8). Although the event M-S-f5 is a rather
obscure one, it is the event used to illustrate the event- fucntions in the
Elisp Info documentation.

;; #1
(eventp 'M-S-f5)
> nil
(symbol-plist 'M-S-f5)
> nil

;; #2
(event-modifiers 'M-S-f5)
> (meta shift)

;; #3
(eventp 'M-S-f5)
> (f5 meta shift)
(symbol-plist 'M-S-f5)
> (event-symbol-element-mask (f5 167772160) event-symbol-elements (f5 meta shift))

A similar example occurs with, say, M-s-z, even if M-s-z has been defined in the global map.

This problem holds with event-basic-type too because it also just checks the symbol plist. 
In #1, for instance, (event-basic-type 'M-S-f5) would be nil, but not in #3. 
Another side of the problem(?) is that in #1  calling (event-modifier 'foobar) would make
subsequent (eventp 'foobar) calls true.

Neither of these seems like desirable behaviors.

Not a really big deal, but I thought I'd pass it along.



P.S. I haven't had a chance to look over the C code on this too closely, but the function
parse_modifiers, which is doing the work in internal-event-symbol-parse-modifiers,
is called at some points when reading key sequences. Caching the events when
they are read would seem to be a good idea, although it is not happening in the
M-s-z example.

--- End Message ---
--- Begin Message --- Subject: Re: bug#10190: eventp can give incorrect results (subr.el), Emacs 23 and 24 Date: Thu, 19 Jul 2012 02:25:19 -0400 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux)
> My own impression is that the patch below would be an improvement, but
> I'd rather keep it for after 24.1.

Installed (in a slightly different form).


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]