Subject: bug#24837: 26.0.50; term.el: In char mode, displayed and executed commands can differ

From: Phil Sainty <[email-masked]>
Date: Mon, 25 Sep 2017 16:09:22 +1300

On 2017-09-25 13:48, Phil Sainty wrote:
> So keyboard events cannot leave point in the wrong position; and while
> mouse events can do so, as soon as the keyboard is involved again we
> jump to where we're supposed to be.

Thinking on this further, it might be even better to use 
pre-command-hook
to establish whether the pre-command position of point is equal to the
process mark, and then act conditionally on that in post-command-hook,
so that if the pre-command point did not already match the process mark,
we do *not* forcibly move it to the process mark afterwards.

The intention being that in term-char-mode:

1. Unless mouse activity takes place, a command cannot leave point in
    an inconsistent position.

2. The user *can* still use the mouse in char mode (e.g. to move point
    and/or select a region).

3. Once the user has used the mouse to move point, they may continue
    to invoke arbitrary commands without it being forced back to the
    process mark (so exchange-point-and-mark would do what they expected,
    for example).  The buffer will still be read-only of course.

4. Upon process output, point would move back to the process mark as
    normal.  When this happens (or if the user manually moves point to
    that position) the user would need to use the mouse once more to
    move point elsewhere.

Obviously they can switch to term-line-mode at any time and do anything
to the buffer, but the above would give some ability to the mouse and
certain keybindings in char mode as well.

-Phil