Subject: bug#34720: 26.1; Reverting a GPG buffer moves all markers to the end of the file

From: Eli Zaretskii <[email-masked]>
Date: Mon, 26 Aug 2019 10:59:18 +0300

> From: Lars Ingebrigtsen <[email-masked]>
> Date: Mon, 26 Aug 2019 09:20:29 +0200
> Cc: [email-masked]
> 
> Lars Ingebrigtsen <[email-masked]> writes:
> 
> >> 1. Open a GnuPG encrypted file
> >> 2. Run the following:
> >>    (setq test-marker (make-marker))
> >>    (move-marker test-marker (point-marker))
> >>    ;; test-marker points to `point'
> >> 3. Revert the buffer
> >>    ;; test-marker now points to the end of the buffer

Markers cannot be preserved in every situation, there's no way around
this basic fact.

> The third is that the interface to the new replace-buffer-contents
> function is really awkward -- it only takes a buffer as its SOURCE,
> which means that if you want to feed it something, you have to skip
> around to temporary buffers instead of feeding it a string, which would
> be natural.  You have to be a with-temp-buffer/with-current-buffer/let
> contortionist to get it to be safe.

replace-buffer-contents is a primitive, so it can legitimately rely on
Lisp programs to set up whatever preconditions it needs for it to
work.  It MUST have a buffer to work with; if you want to replace with
a string, insert that string into a buffer and call the primitive.
Why is that a problem?

> Would anybody mind if I just write a `with-saved-markers' macro in
> subr-x, which would make all these problems to away and make the
> solution a two-liner in epa itself?

What would that macro do, exactly?