Subject: bug#23906: 25.0.95; Undo boundary after process output is not consistent

From: Markus Triska <[email-masked]>
Date: Wed, 06 Jul 2016 19:56:30 +0200

To reproduce this issue with emacs-25 git and cherry-picked commit
36e69bd82a0294b1f51d99a5eaf8e2c7661f7a16 from master, please do:

1) Download ediprolog.el from:

   https://www.metalevel.at/ediprolog/ediprolog.el

2) Download ceiled.pl from:

   https://www.metalevel.at/ei/ceiled.pl

3) Download simulans2.sh from:

   https://www.metalevel.at/ei/simulans2.sh

   and make it executable with:

   $ chmod +x simulans2.sh

4) Invoke Emacs with:

    emacs -Q ceiled.pl -fn "Bitstream Vera Sans Mono 15" \
         --eval "(load \"$PWD/ediprolog.el\")" \
         --eval "(setq ediprolog-program \"$PWD/simulans2.sh\")" \
         --eval "(global-set-key [f9] 'ediprolog-dwim)"

5) To move point to the start of line 15, press:

   M-g M-g 15 RET

6) We are now ready for the recipe, showing that undo after process
   output is not consistent. The issue I want to show occurs about 1 out
   of 7 times on average. The steps we now repeat are two key presses:

   F9 C-/

   In words, this is: "ediprolog-dwim, directly followed by undo".

   We repeat this over and over: F9 C-/ F9 C-/ F9 C-/ ...

7) Now the point: *Most* of the time, after undo, the buffer is exactly
   as it was before. But sometimes, about 1 out of 7 times, after undo
   is pressed, the characters "%@ " remain at the end of the buffer:

   %?- time(ceiled_square_root(2^10000, R)).
   %@ 

   These three characters ("%@ ") are inserted by ediprolog before
   receiving process output, and in most cases removed after the undo.

The issue in this case is not so much that the %@ appears in the buffer,
but that it is not handled consistently. Most often (and preferably), a
single undo removes both the process output _and_ the %@, but sometimes
a single undo removes *only* the process output, and the %@ remains. The
behaviour I desire is that C-/ consistently removes everything that was
inserted in direct sequence, both the "%@ " _and_ the process output.

Thank you for looking into this!

All the best,
Markus

In GNU Emacs 25.0.95.4 (x86_64-apple-darwin15.5.0, X toolkit, Xaw scroll bars)
 of 2016-07-05 built on mt-imac
Repository revision: e3b039d1a0e611d6619ed3ce67d125160d644ebc
Windowing system distributor 'The X.Org Foundation', version 11.0.11502000
Configured using:
 'configure --without-ns CFLAGS=-I/opt/local/include
 LDFLAGS=-L/opt/local/lib'

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK GSETTINGS NOTIFY ACL GNUTLS
LIBXML2 FREETYPE XFT ZLIB TOOLKIT_SCROLL_BARS LUCID X11

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix