[Top][All Lists]

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

Re: [elpa] externals/exwm 0b8a373: Fix a `unread-command-events' issue f

From: Stefan Monnier
Subject: Re: [elpa] externals/exwm 0b8a373: Fix a `unread-command-events' issue for Emacs 24
Date: Thu, 14 Jul 2016 20:31:54 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

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


reply via email to

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