Subject: Re: bug#77658: 30.1.50; Eglot: wrong-type-argument: consp, #<marker at 1 in file> when saving

From: João Távora <[email-masked]>
Date: Sat, 26 Apr 2025 12:51:35 +0100

On Sat, Apr 26, 2025 at 12:08 PM Eli Zaretskii <[email-masked]> wrote:
>
> Ping!  João, any suggestions or comments?

I think Aaron is on the right track by identifying this as a mismatch
between before-change-functions and after-change-functions.  This seems
to happen in a (rather extreme?) edge case where the full buffer's
contents are replaced just before saving.

It looks like a bug in the b-c-fns and a-c-fns, and there are a number
of those that eglot.el already recognizes and fixes.  Stefan Monnier has
written a library to try to smooth over these bugs and provide a better
API to clients, but that some problems in itself so I recently removed
it.  I don't know if it had support for fixing this particular bug.  I
could re-add it, but I think the root problem should be clearly identified
before.  The ideal fix, in my view, is for the b-c-fns and a-c-fns to be
fixed so that they are more predictable.

In the meantime, I wonder if completely disabling the modification hooks
around the `insert-file-contents` wouldn't be a suitable workaround.
There would, of course, be no change notification Eglot -> LSPserver,
except for Eglot stating it has saved the file to disk, which most LSPs
usually interpret as a hint to go read from the disk.

João