From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: "Basil L. Contovounesios" Newsgroups: gmane.emacs.bugs Subject: bug#35238: 27.0.50; Clarify eventp behaviour with booleans Date: Tue, 23 Apr 2019 00:19:45 +0100 Message-ID: <87a7gh39wu.fsf@tcd.ie> References: <87pnpsp3jd.fsf@tcd.ie> <87y34fscl6.fsf@tcd.ie> <83bm1bmmml.fsf@gnu.org> <87zhothjw7.fsf@tcd.ie> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="145876"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 35238@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Apr 23 01:24:37 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hIiIb-000beZ-Fa for geb-bug-gnu-emacs@m.gmane.org; Tue, 23 Apr 2019 01:24:33 +0200 Original-Received: from localhost ([127.0.0.1]:45512 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIiIa-0000AK-Dg for geb-bug-gnu-emacs@m.gmane.org; Mon, 22 Apr 2019 19:24:32 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:40475) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIiIN-00009i-NA for bug-gnu-emacs@gnu.org; Mon, 22 Apr 2019 19:24:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hIiFC-000124-KA for bug-gnu-emacs@gnu.org; Mon, 22 Apr 2019 19:21:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:38332) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hIiFC-00011z-GR for bug-gnu-emacs@gnu.org; Mon, 22 Apr 2019 19:21:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hIiFC-0003Jr-BW for bug-gnu-emacs@gnu.org; Mon, 22 Apr 2019 19:21:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Basil L. Contovounesios" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 22 Apr 2019 23:21:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35238 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 35238-submit@debbugs.gnu.org id=B35238.155597520312680 (code B ref 35238); Mon, 22 Apr 2019 23:21:02 +0000 Original-Received: (at 35238) by debbugs.gnu.org; 22 Apr 2019 23:20:03 +0000 Original-Received: from localhost ([127.0.0.1]:51876 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hIiED-0003IE-V0 for submit@debbugs.gnu.org; Mon, 22 Apr 2019 19:20:02 -0400 Original-Received: from mail-ed1-f42.google.com ([209.85.208.42]:33898) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hIiEB-0003Hq-GU for 35238@debbugs.gnu.org; Mon, 22 Apr 2019 19:20:00 -0400 Original-Received: by mail-ed1-f42.google.com with SMTP id a6so10943976edv.1 for <35238@debbugs.gnu.org>; Mon, 22 Apr 2019 16:19:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=sjjJV9iC1U1d1RiYs5kAn+h3hFBmCMnlHTXqhShNdP0=; b=1kA1XHkCjRctiN+xXmTcRyzphCaET9OSpeN/jdKjn+nRE/p2IsBgvJpdzkvcEePbOf DKnTgYWsQRmsvY9G+AcNHTwSN5+Fr5BoxjPa1ymQ4e53rodrsdjdxbMqv4uii9uQzDIN 96p0Lx/OWgueOYYQrSrTqZ3XVNFarPjphQEPoBzyx2BFcv5T7liRQA50WkaMB8+uflBg 770HCztJ1NQWwgMHfWEqjJfvnVAU0abGA+mSAwuvfQyMXvGLcz93Hlv9d8mU5sfAInIf EzrNdibFnyWlx3obD/k5Co0tpzmCk27YP+xZAHJkRc/4VSnnQDtfR5m2ilETXDXaoxVZ 5CNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=sjjJV9iC1U1d1RiYs5kAn+h3hFBmCMnlHTXqhShNdP0=; b=tXa5ztkI+3atOL76TMxsqYlF3Uueqj881RyolOm7oiVknvHbZzuTTQASV9TbMBLxDG I0oKLp/EhH5wXhJHEdqSSEnmFoAI6H/DnEMDcmwW4wpUz3UURjwm2hQgL/7ckHvKD3II fvwnsPoEBfRN7G+iteOC0nxPeLyHXkGbJaciSV8wRa/r70+npXrqGRIP3DDKaVY2vUHH +3LNuiiqxfAgsAMJozO31YUnSzuolmRoIMwQjHOEHDTxafdKa+1BFb9yc0uEY+y1qPei Z37+Wz5PHxwTSti0T0MncCSpnk/mxnoBOtbuZrIx5gODkNiI9F1RxMEEoQMWIkTccxkr C6gQ== X-Gm-Message-State: APjAAAWsPNlACprAKRXn0r7RvoNdCJiXKsKwtwIUwWXAUG+xR+pyGvHL sIvcNiCwgTWrKyDbJgm657iYUiypE8k8KQ== X-Google-Smtp-Source: APXvYqwlNtG2BkCt6qYtXeGXHKWU2jrIja4/7pmR8xFZuPhRXXAhr1ZnSBtNE8ucmMMFpotmP5v6pw== X-Received: by 2002:a50:ac72:: with SMTP id w47mr13811238edc.127.1555975193776; Mon, 22 Apr 2019 16:19:53 -0700 (PDT) Original-Received: from localhost ([2a02:8084:20e2:c380:8f5:8e00:4345:7c72]) by smtp.gmail.com with ESMTPSA id p7sm3953383eds.81.2019.04.22.16.19.51 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 22 Apr 2019 16:19:52 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Sat, 13 Apr 2019 23:13:19 -0400") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:158089 Archived-At: --=-=-= Content-Type: text/plain Stefan Monnier 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? --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Clarify-what-constitutes-an-event-bug-35238.patch >From 62f82c31406b9ea3ca59258bba9663184b8d5734 Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" 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. + * 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 --=-=-= Content-Type: text/plain Thanks, -- Basil --=-=-=--