Subject: 29.1.50; process-mark sometimes does not yield the expected value
From: Markus Triska <[email-masked]>
To: [email-masked]
Date: Mon, 02 Oct 2023 22:00:05 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

To reproduce this issue, please do the following:

  1) download ediprolog.el with:

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

  2) download simulans_a.sh with:

     $ wget https://www.metalevel.at/ei/process-mark/simulans_a.sh   

     This shell file will illustrate this issue in lieu of Scryer Prolog.

  3) make simulans_a.sh executable with:

     $ chmod +x simulans_a.sh

  4) create test1.pl and test2.pl, with the following commands:

     $ echo "?- X = a." > test1.pl
     $ echo "?- X = a." > test2.pl

  5) launch Emacs with:

     $ emacs -Q -l ediprolog.el --eval "(add-to-list 'exec-path \".\")" \
         --eval '(setq ediprolog-program "simulans_a.sh")' test1.pl test2.pl

Emacs now shows two windows, test2.pl in the upper window, and
test1.pl in the lower window. Initially, test2.pl is the selected
window, and point is on the query "?- X = a.". Now do:

    M-x ediprolog-dwim RET

As expected, the buffer will now consist of the following text:

    ?- X = a.
    %@    X = a.

Now, switch to the below window (test1.pl) with:

    C-x o

And there, do:

    M-x ediprolog-dwim RET

Unexpectedly, the buffer will consist of the following text:

    ?- X = a.
    %@ 
       X = a.

The newline after %@ is unexpected! The expected buffer content is:

    ?- X = a.
    %@ X = a.

This already illustrates a difference compared to Emacs 26.1, 27.1,
and other versions, which behave as expected.

To see more differences, switch back to the above window (test2.pl):

    C-x o

And move point to the first line (the line of the query) with:

    C-p

And then do:

    M-x ediprolog-dwim RET

Unexpectedly, the buffer will consist of the following text:

    ?- X = a.
    %@ 
    %@    X = a.
       X = a.

The expected text (at this state) is:

    ?- X = a.
    %@    X = a.
    %@    X = a.

Repeat these steps to see more unexpected behaviour. It seems that
process-mark sometimes does not yield the expected position.

ediprolog.el goes to the process-mark in line 431, which reads:

         (goto-char (process-mark ediprolog-process))

In all cases above, the process-mark is expected to yield the value 14
at this point of the program, but it does not always yield this value.

If possible, could you please restore the behaviour that earlier Emacs
versions exhibit in these examples?

Thank you and all the best,
Markus

In GNU Emacs 29.1.50 (build 1, x86_64-apple-darwin18.2.0, X toolkit,
 cairo version 1.17.6, Xaw scroll bars) of 2023-09-14 built on
 mac
Repository revision: f0a89fa1d0e5b380ecadb57052c95b31110c0323
Repository branch: emacs-29
Windowing system distributor 'The X.Org Foundation', version 11.0.11804000
System Description:  Mac OS X 10.14.2

Configured using:
 'configure --with-x-toolkit=lucid --without-ns
 CFLAGS=-I/opt/local/include/ LDFLAGS=-L/opt/local/lib
 --with-xpm=ifavailable'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LCMS2 LIBXML2 MODULES NOTIFY KQUEUE PDUMPER PNG RSVG SQLITE3 THREADS
TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM XINPUT2 LUCID
ZLIB