From: "Basil L. Contovounesios" <contovob@tcd.ie>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 35238@debbugs.gnu.org
Subject: bug#35238: 27.0.50; Clarify eventp behaviour with booleans
Date: Tue, 23 Apr 2019 00:19:45 +0100 [thread overview]
Message-ID: <87a7gh39wu.fsf@tcd.ie> (raw)
In-Reply-To: <jwvmuktnuvo.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Sat, 13 Apr 2019 23:13:19 -0400")
[-- Attachment #1: Type: text/plain, Size: 398 bytes --]
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> The question is, should eventp continue returning non-nil for these
>> events of the form (nil . COMMAND)?
>
> I don't think we need to consider them as events.
> More specifically, recent-keys uses this representation for the
> execution of a command because it expects that no event would have such
> a shape.
OK, then how's the following?
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Clarify-what-constitutes-an-event-bug-35238.patch --]
[-- Type: text/x-diff, Size: 4778 bytes --]
From 62f82c31406b9ea3ca59258bba9663184b8d5734 Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <contovob@tcd.ie>
Date: Sun, 21 Apr 2019 23:02:01 +0100
Subject: [PATCH] Clarify what constitutes an event (bug#35238)
* doc/lispref/commands.texi (Input Events): Specify that events are
non-nil and remove vestiges of bug#10190.
* doc/lispref/os.texi (Recording Input): Document optional argument
of recent-keys.
* lisp/subr.el (eventp): Check that the car of conses is non-nil.
* etc/NEWS: Announce it as an incompatible change.
* src/keyboard.c (Frecent_keys): Clarify that returned "events" are
not real events.
---
doc/lispref/commands.texi | 9 +++------
doc/lispref/os.texi | 7 ++++++-
etc/NEWS | 5 +++++
lisp/subr.el | 14 ++++++++------
src/keyboard.c | 2 +-
5 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/doc/lispref/commands.texi b/doc/lispref/commands.texi
index cd44c1c87e..5ea0be2667 100644
--- a/doc/lispref/commands.texi
+++ b/doc/lispref/commands.texi
@@ -1047,12 +1047,9 @@ Input Events
This function returns non-@code{nil} if @var{object} is an input event
or event type.
-Note that any symbol might be used as an event or an event type.
-@code{eventp} cannot distinguish whether a symbol is intended by Lisp
-code to be used as an event. Instead, it distinguishes whether the
-symbol has actually been used in an event that has been read as input in
-the current Emacs session. If a symbol has not yet been so used,
-@code{eventp} returns @code{nil}.
+Note that any non-@code{nil} symbol might be used as an event or an
+event type; @code{eventp} cannot distinguish whether a symbol is
+intended by Lisp code to be used as an event.
@end defun
@menu
diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi
index 59cd5a8fe8..fef954eb7a 100644
--- a/doc/lispref/os.texi
+++ b/doc/lispref/os.texi
@@ -2197,7 +2197,7 @@ Recording Input
@subsection Recording Input
@cindex recording input
-@defun recent-keys
+@defun recent-keys &optional include-cmds
This function returns a vector containing the last 300 input events from
the keyboard or mouse. All input events are included, whether or not
they were used as parts of key sequences. Thus, you always get the last
@@ -2205,6 +2205,11 @@ Recording Input
(These are excluded because they are less interesting for debugging; it
should be enough to see the events that invoked the macros.)
+If @var{include-cmds} is non-@code{nil}, complete key sequences in the
+result vector are interleaved with pseudo-events of the form
+@code{(nil . @var{COMMAND})}, where @var{COMMAND} is the binding of
+the key sequence (@pxref{Command Overview}).
+
A call to @code{clear-this-command-keys} (@pxref{Command Loop Info})
causes this function to return an empty vector immediately afterward.
@end defun
diff --git a/etc/NEWS b/etc/NEWS
index b13ab47768..76943391bc 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1526,6 +1526,11 @@ performs (setq-local indent-line-function #'indent-relative).
** 'make-process' no longer accepts a non-nil ':stop' key. This has
never worked reliably, and now causes an error.
++++
+** 'eventp' no longer returns non-nil for lists whose car is nil.
+This is consistent with the fact that nil, though a symbol, is not a
+valid event type.
+
\f
* Lisp Changes in Emacs 27.1
diff --git a/lisp/subr.el b/lisp/subr.el
index f68f9dd419..be21dc67a0 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1238,12 +1238,14 @@ 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 (if (consp object)
+ (setq object (car object))
+ object)
+ (symbolp object)
+ (not (keywordp object)))))
(defun event-modifiers (event)
"Return a list of symbols representing the modifier keys in event EVENT.
diff --git a/src/keyboard.c b/src/keyboard.c
index dff8f6b2fc..6d3030644a 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -9966,7 +9966,7 @@ If CHECK-TIMERS is non-nil, timers that are ready to run will do so. */)
DEFUN ("recent-keys", Frecent_keys, Srecent_keys, 0, 1, 0,
doc: /* Return vector of last few events, not counting those from keyboard macros.
If INCLUDE-CMDS is non-nil, include the commands that were run,
-represented as events of the form (nil . COMMAND). */)
+represented as pseudo-events of the form (nil . COMMAND). */)
(Lisp_Object include_cmds)
{
bool cmds = !NILP (include_cmds);
--
2.20.1
[-- Attachment #3: Type: text/plain, Size: 20 bytes --]
Thanks,
--
Basil
next prev parent reply other threads:[~2019-04-22 23:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-11 22:42 bug#35238: 27.0.50; Clarify eventp behaviour with booleans Basil L. Contovounesios
2019-04-11 23:42 ` Stefan Monnier
2019-04-12 11:11 ` Basil L. Contovounesios
2019-04-12 12:25 ` Stefan Monnier
2019-04-12 12:30 ` Eli Zaretskii
2019-04-13 17:53 ` Basil L. Contovounesios
2019-04-14 3:13 ` Stefan Monnier
2019-04-22 23:19 ` Basil L. Contovounesios [this message]
2019-04-23 2:06 ` Stefan Monnier
2019-05-07 17:08 ` Basil L. Contovounesios
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=87a7gh39wu.fsf@tcd.ie \
--to=contovob@tcd.ie \
--cc=35238@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.