From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [elpa] externals/exwm 0b8a373: Fix a `unread-command-events' issue for Emacs 24 Date: Thu, 14 Jul 2016 20:31:54 -0400 Message-ID: References: <20160715001351.14660.27588@vcs.savannah.gnu.org> <20160715001351.9FD2C22014B@vcs.savannah.gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1468542774 31595 80.91.229.3 (15 Jul 2016 00:32:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 15 Jul 2016 00:32:54 +0000 (UTC) Cc: Chris Feng To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jul 15 02:32:43 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bNr3b-0005jn-06 for ged-emacs-devel@m.gmane.org; Fri, 15 Jul 2016 02:32:43 +0200 Original-Received: from localhost ([::1]:57612 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNr3W-0007zK-HP for ged-emacs-devel@m.gmane.org; Thu, 14 Jul 2016 20:32:38 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35110) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNr2t-0007zD-Ft for emacs-devel@gnu.org; Thu, 14 Jul 2016 20:32:00 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bNr2p-0005He-Ew for emacs-devel@gnu.org; Thu, 14 Jul 2016 20:31:58 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:29276) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNr2p-0005HX-AM for emacs-devel@gnu.org; Thu, 14 Jul 2016 20:31:55 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0A1FgA731xV/3mcpUVcgxCEAoVVwwsEAgKBPDwRAQEBAQEBAYEKQQWDXQEBBFYjEAs0EhQYDYhjzyMBAQEHAQEBAR6LOoUFBxaEFwEEmW2ZUoFFI4I7gVkigngBAQE X-IPAS-Result: A0A1FgA731xV/3mcpUVcgxCEAoVVwwsEAgKBPDwRAQEBAQEBAYEKQQWDXQEBBFYjEAs0EhQYDYhjzyMBAQEHAQEBAR6LOoUFBxaEFwEEmW2ZUoFFI4I7gVkigngBAQE X-IronPort-AV: E=Sophos;i="5.13,465,1427774400"; d="scan'208";a="248002594" Original-Received: from 69-165-156-121.dsl.teksavvy.com (HELO fmsmemgm.homelinux.net) ([69.165.156.121]) by ironport2-out.teksavvy.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 14 Jul 2016 20:31:54 -0400 Original-Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 31A1CAE0F4; Thu, 14 Jul 2016 20:31:54 -0400 (EDT) In-Reply-To: <20160715001351.9FD2C22014B@vcs.savannah.gnu.org> (Chris Feng's message of "Fri, 15 Jul 2016 00:13:51 +0000 (UTC)") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.181 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:205692 Archived-At: > +(eval-and-compile > + (if (< emacs-major-version 25) > + (defsubst exwm-input--unread-event (event) > + (setq unread-command-events > + (append unread-command-events (list event)))) > + (defsubst exwm-input--unread-event (event) > + (setq unread-command-events > + (append unread-command-events `((t . ,event))))))) This ends up choosing the version of the code at the time it's compiled rather than at the time it's executed (since this is a defsubst and the version chosen at compile time will end up being inlined everywhere). I'd advise against using defsubst here (performance is probably of no importance compared to the time it will take to process the event). If you don't use defsubst, then you also don't need eval-and-compile, so I'd recommend: (defalias 'exwm-input--unread-event (if (< emacs-major-version 25) (lambda (event) (setq unread-command-events (append unread-command-events (list event)))) (lambda (event) (setq unread-command-events (append unread-command-events `((t . ,event))))))) and while I'm here, I wonder why you use `append` instead of `push`, i.e. why you add the event to the end rather than to the beginning of the queue. The content of the queue is "the event we haven't processed yet", so in order to do something akin to rerunning the current event, you usually want to put at the beginning of the queue. Stefan