all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Christopher Genovese <genovese.cr@gmail.com>
Cc: 10190@debbugs.gnu.org
Subject: bug#10190: eventp can give incorrect results (subr.el), Emacs 23 and 24
Date: Fri, 02 Dec 2011 09:31:35 -0500	[thread overview]
Message-ID: <jwvzkfb831i.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <CAPum5Fjv98vhx4s1xoQi2j9EWZVwnNt3nZY6aK_CDU-UBVBcBA@mail.gmail.com> (Christopher Genovese's message of "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.

I think the assumption of the current code is that eventp is allowed to
return nil if that event has not yet occurred in the current session.
I'm not sure why it's done that way.

> 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.,

Note that (progn (event-modifiers X) (eventp X)) will return non-nil for
*any* symbol (i.e. any symbol can potentially be an event name).

> Neither of these seems like desirable behaviors.

I tend to agree.  But I'm also curious in which circumstance did you
bump into this problem.

My own impression is that the patch below would be an improvement, but
I'd rather keep it for after 24.1.


        Stefan


=== modified file 'lisp/subr.el'
--- lisp/subr.el	2011-11-23 07:03:56 +0000
+++ lisp/subr.el	2011-12-02 14:30:16 +0000
@@ -870,16 +870,10 @@
 
 (defsubst eventp (obj)
   "True if the argument is an event object."
-  (or (and (integerp obj)
-	   ;; Filter out integers too large to be events.
-	   ;; M is the biggest modifier.
-	   (zerop (logand obj (lognot (1- (lsh ?\M-\^@ 1)))))
-	   (characterp (event-basic-type obj)))
-      (and (symbolp obj)
-	   (get obj 'event-symbol-elements))
+  (or (integerp obj)
+      (symbolp obj)
       (and (consp obj)
-	   (symbolp (car obj))
-	   (get (car obj) 'event-symbol-elements))))
+	   (symbolp (car obj)))))
 
 (defun event-modifiers (event)
   "Return a list of symbols representing the modifier keys in event EVENT.






  reply	other threads:[~2011-12-02 14:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-02  5:55 bug#10190: eventp can give incorrect results (subr.el), Emacs 23 and 24 Christopher Genovese
2011-12-02 14:31 ` Stefan Monnier [this message]
2011-12-02 15:17   ` Christopher Genovese
2012-07-19  6:25   ` 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=jwvzkfb831i.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=10190@debbugs.gnu.org \
    --cc=genovese.cr@gmail.com \
    /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.