Subject: Re: bug#21867: 25.0.50; lossage's log doesn't treat characters read by read-char as separate commands

From: Stefan Monnier <[email-masked]>
Date: Fri, 02 Aug 2019 16:16:37 -0400

>   retry:
>    do
> -    val = read_char (0, Qnil, (input_method ? Qnil : Qt), 0,
> -		     NUMBERP (seconds) ? &end_time : NULL);
> +    {
> +      val = read_char (0, Qnil, (input_method ? Qnil : Qt), 0,
> +		       NUMBERP (seconds) ? &end_time : NULL);
> +      record_char (Qnon_command_character);
> +    }

Currently, the view-lossage doesn't actually say

    `a C-h l` resulted in running view-lossage

contrarily to what Lars seems to assume (and I guess, contrarily to
what the display suggests).  Instead it just says

    we saw `a` then `C-h` then `l` then view-lossage was run

I think considering this problem as specific to `read-char` is kinda wrong
(after all, `read-char` can be called as part of input-decode-map in
which case the event still very much belongs to "the events that resulted
in running a particular command"; this happens for example for
mouse-clicks in xterm-mouse-mode).

So I think maybe a better way to look at it is to add marker
pseudo-events like `end-of-command` (e.g. after running
post-command-hook), so we can discover that `a` was processed as part of
the execution of the command bound to `C-x C-e` rather than as part of
the sequence of events that triggered view-lossage.

        Stefan