1) M-x shell 2) echo foo RET 3) C-/ to undo this 'RET' The buffer now contain the shell's prompt and "echo foo". However, the process mark is located at eob after "echo foo" 4) Type bar The buffer now contain the shell's prompt and "echo foobar" 5) RET Shell will output "bar: command not found", because the process mark is located before "bar" after "foo". Similar behaviour can be observed with C-c SPC (comint-accumulate) and with eshell. My idea to solve this is to record process mark and related marker positions as `apply' entries in the undo list. Attached patch implements this for comint and eshell.