GNU bug report logs - #35238
27.0.50; Clarify eventp behaviour with booleans

Previous Next

Package: emacs;

Reported by: "Basil L. Contovounesios" <contovob <at> tcd.ie>

Date: Thu, 11 Apr 2019 22:43:02 UTC

Severity: minor

Tags: fixed, patch

Found in version 27.0.50

Done: "Basil L. Contovounesios" <contovob <at> tcd.ie>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: 35238 <at> debbugs.gnu.org
Subject: bug#35238: 27.0.50; Clarify eventp behaviour with booleans
Date: Fri, 12 Apr 2019 12:11:01 +0100
[Message part 1 (text/plain, inline)]
Stefan Monnier <monnier <at> IRO.UMontreal.CA> writes:

>> As mentioned in a past commit[1], nil is not an event.
>> Since the car of a mouse click event is considered its type,
>> shouldn't (nil) also be rejected as an event?
>
> Not sure it's worth the trouble (there are already lots of other objects
> that aren't events but for which eventp returns non-nil).

Sure, but the following would at least make eventp treat nil
consistently:

[eventp.diff (text/x-diff, inline)]
diff --git a/lisp/subr.el b/lisp/subr.el
index bdf98979c4..407bd6379d 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1227,12 +1227,13 @@ listify-key-sequence
 			  c)))
 	    key)))
 
-(defun eventp (obj)
-  "True if the argument is an event object."
-  (when obj
-    (or (integerp obj)
-        (and (symbolp obj) obj (not (keywordp obj)))
-        (and (consp obj) (symbolp (car obj))))))
+(defun eventp (object)
+  "Return non-nil if OBJECT is an input event or event object."
+  (or (integerp object)
+      (and (symbolp (if (consp object)
+                        (setq object (car object))
+                      object))
+           (not (keywordp object)))))
 
 (defun event-modifiers (event)
   "Return a list of symbols representing the modifier keys in event EVENT.
[Message part 3 (text/plain, inline)]
>> Should t be counted as an event?
>>
>>   (eventp t)    ; => t
>>   (eventp '(t)) ; => t
>
> Not sure if we ever generate such an event, but what would be the
> benefit of rejecting it?

I don't know, it could even be detrimental; I was just curious.

Thanks,

-- 
Basil

This bug report was last modified 6 years and 11 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.