unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* differentiating real and fake command events
@ 2024-12-14  9:19 Psionic K
  2024-12-14 14:14 ` Stefan Monnier via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 5+ messages in thread
From: Psionic K @ 2024-12-14  9:19 UTC (permalink / raw)
  To: help-gnu-emacs

I'm adding macro playback support to dslide.  My first pass is workable but
not literally fool proof.

The implementation sets `unread-command-events' using a recursive timer
function.  This was the first implementation I found that wouldn't eat the
events, as `sit-for' etc enjoy doing.  I would prefer a blocking
implementation to prevent any input from my playback to help save users
from screwing up.

If no blocking approach is feasible, I need ways to decide if the user
pressed a key.  I need to block this key if possible, but at least with
detection I can begin some recovery strategy.


^ permalink raw reply	[flat|nested] 5+ messages in thread
* Re: differentiating real and fake command events
@ 2024-12-15  6:00 Psionic K
  2024-12-15 23:32 ` Stefan Monnier via Users list for the GNU Emacs text editor
  2024-12-16  7:44 ` mbork
  0 siblings, 2 replies; 5+ messages in thread
From: Psionic K @ 2024-12-15  6:00 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs, Psionic K

> I don't understand enough of the context.  Could you explain in what way
> you need something different from `execute-kbd-macro`?

I'm implementing "live" demo features for dslide.  It relies on
playing back macros at human speed.  The goal is to emulate the
results of using Emacs by hand, to appear as a live demonstration, but
with reproducibility.  This frees the presenter from having to think
and type at the same time while still conveying the organic experience
to those watching.  Keyboard macros executed via `execute-kbd-macro'
replay input at inhuman speed and lose the similarity of feedback that
enables the audience to relate what they see with what they normally
do.

The first issue I ran into was simply getting `unread-command-events'
to result in input.  For my first pass solution, I accomplished this
with a function that calls itself recursively via `run-at-time'.  I
may try threads.

The recursive function currently also compares `last-input-event' to
detect incoherence caused by extra user inputs (and possibly others?).
If the last key pushed into `unread-command-events' doesn't match, it
messages and aborts.  This approach is invalid for replaying sequences
that will result in extra events.

Rather than detect potentially corrupting extra inputs, I would block
the user's inputs and allow only the synthetic events to succeed.  It
is unnatural to block the user from typing inputs while also pushing
synthetic input into `unread-command-events'.  One idea I had was to
activate a keymap in between pushing events.  However, I think this
would depend on the command loop evaluation order and wind up being
fragile.

I expect there are many paths that appear viable but only some that
are truly good and will remain so for at least a few years.



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-12-16  7:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-14  9:19 differentiating real and fake command events Psionic K
2024-12-14 14:14 ` Stefan Monnier via Users list for the GNU Emacs text editor
  -- strict thread matches above, loose matches on Subject: below --
2024-12-15  6:00 Psionic K
2024-12-15 23:32 ` Stefan Monnier via Users list for the GNU Emacs text editor
2024-12-16  7:44 ` mbork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).