Subject: bug#29672: 26.0.90 Can't move cursor above prompt in evil-mode

From: Noam Postavsky <[email-masked]>
Date: Tue, 12 Dec 2017 09:08:03 -0500

James Nguyen <[email-masked]> writes:

> This is in char-mode.
>
> It works in emacs 25.
>
> ——————————————————
> emacs-major-version ;; 25
> (add-to-list 'load-path "/Users/james/.emacs.d/elpa/25/evil-20171129.651")
> (require 'evil)
> (evil-mode)
> M-x term
> "/bin/zsh"
> Press ESC to go into 'normal state'.
> Press k to move cursor above prompt. --> cursor moves above prompt
> ——————————————————
>
> ——————————————————
> emacs-major-version ;; 26
> (add-to-list 'load-path "/Users/james/.emacs.d/elpa/26/evil-20171129.651")
> (require 'evil)
> (evil-mode)
> M-x term
> "/bin/zsh"
> Press ESC to go into 'normal state'.
> Press k to move cursor above prompt. --> cursor won't move outside of prompt
> ——————————————————

A similar recipe without evil:

M-x term
"/bin/bash" ;; I happen not to have zsh installed at the moment
Hit RET a few times so there is somewhere to move.
C-c M-x eval-expression RET (previous-line) RET
See cursort move up, and then move back to the prompt.

Seems to be on purpose, caused by this code, introduced in [1: 0d8e4f45d6]:

    ;; Don't allow changes to the buffer or to point which are not
    ;; caused by the process filter.
    (when term-char-mode-buffer-read-only
      (setq buffer-read-only t))
    (add-hook 'pre-command-hook #'term-set-goto-process-mark nil t)
    (add-hook 'post-command-hook #'term-goto-process-mark-maybe nil t)

[1: 0d8e4f45d6]: 2017-10-21 11:17:56 +0300
  Avoid creating inconsistent buffer states in term-char-mode
  https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=0d8e4f45d612ecd77f4997fae30e4d1591f9b8a6