emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master c972da9: Clarify what constitutes an event (bug#352


From: Basil L. Contovounesios
Subject: [Emacs-diffs] master c972da9: Clarify what constitutes an event (bug#35238)
Date: Tue, 7 May 2019 13:07:45 -0400 (EDT)

branch: master
commit c972da907d494b6d5efd423aa3b5d0b23f7b7801
Author: Basil L. Contovounesios <address@hidden>
Commit: Basil L. Contovounesios <address@hidden>

    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 cd44c1c..5ea0be2 100644
--- a/doc/lispref/commands.texi
+++ b/doc/lispref/commands.texi
@@ -1047,12 +1047,9 @@ and meaning of input events in detail.
 This function returns address@hidden if @var{object} is an input event
 or event type.
 
-Note that any symbol might be used as an event or an event type.
address@hidden 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,
address@hidden returns @code{nil}.
+Note that any address@hidden 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 59cd5a8..fef954e 100644
--- a/doc/lispref/os.texi
+++ b/doc/lispref/os.texi
@@ -2197,7 +2197,7 @@ is the character Emacs currently uses for quitting, 
usually @kbd{C-g}.
 @subsection Recording Input
 @cindex recording input
 
address@hidden recent-keys
address@hidden 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 @@ they were used as parts of key sequences.  Thus, you 
always get the last
 (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 address@hidden, complete key sequences in the
+result vector are interleaved with pseudo-events of the form
address@hidden(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 5fe2e63..72f669a 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1575,6 +1575,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.
+
 
 * Lisp Changes in Emacs 27.1
 
diff --git a/lisp/subr.el b/lisp/subr.el
index f68f9dd..be21dc6 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1238,12 +1238,14 @@ The normal global definition of the character C-x 
indirects to this keymap.")
                          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 ea13c7f..5f2b7af 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -9968,7 +9968,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);



reply via email to

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