all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: emacs-devel@gnu.org
Cc: Chris Feng <chris.w.feng@gmail.com>
Subject: Re: [elpa] externals/exwm 0b8a373: Fix a `unread-command-events' issue for Emacs 24
Date: Thu, 14 Jul 2016 20:31:54 -0400	[thread overview]
Message-ID: <jwvy453zr4e.fsf-monnier+emacsdiffs@gnu.org> (raw)
In-Reply-To: <20160715001351.9FD2C22014B@vcs.savannah.gnu.org> (Chris Feng's message of "Fri, 15 Jul 2016 00:13:51 +0000 (UTC)")

> +(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



       reply	other threads:[~2016-07-15  0:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20160715001351.14660.27588@vcs.savannah.gnu.org>
     [not found] ` <20160715001351.9FD2C22014B@vcs.savannah.gnu.org>
2016-07-15  0:31   ` Stefan Monnier [this message]
2016-07-15  1:03     ` [elpa] externals/exwm 0b8a373: Fix a `unread-command-events' issue for Emacs 24 Chris Feng
2016-07-15  1:48       ` Stefan Monnier
2016-07-15  2:22         ` Chris Feng
2016-07-15 13:24           ` Stefan Monnier

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=jwvy453zr4e.fsf-monnier+emacsdiffs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=chris.w.feng@gmail.com \
    --cc=emacs-devel@gnu.org \
    /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.