On 2/7/2023 10:20 AM, miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors wrote: > You might also be interested in how comint deals with this. It can > handle the case when the user yanks something in the middle of output as > well. See function comint--mark-as-output, bug#3735 and bug#18135 for > more details. Good call. Here's a patch that (mostly) copies those comint functions over to Eshell.