Subject: Re: bug#64911: 30.0.50; switch-to-buffer-preserve-window-point not respected by switch-to-(next|prev)-buffer

From: Eli Zaretskii <[email-masked]>
Date: Fri, 28 Jul 2023 14:04:09 +0300

> Cc: Adam Porter <[email-masked]>
> Date: Fri, 28 Jul 2023 19:11:07 +1200
> From: Phil Sainty <[email-masked]>
> 
> Tangentially, I can't see any function for obtaining all the
> markers for a given buffer.  I see that this has been raised
> before as https://debbugs.gnu.org/cgi/bugreport.cgi?bug=35536
> 
> There's clearly resistance to implementing that, but... it
> would be very useful for cases like the one I'm looking at.
> 
> Specifically, the code which is erasing the buffer and then
> rebuilding it could firstly loop over the buffer markers, store
> some kind of relevant context for each one and then, after
> rebuilding the buffer, it could locate the equivalent context
> in the new buffer text and update each of those markers
> accordingly.

Why cannot you use replace-buffer-contents instead of erasing the
buffer and rebuilding it?  That function attempts to preserve the
markers.

> Without a way of querying the buffer's markers it's necessary
> to just *know* about them and how to access them; and there's
> no guarantee that new markers won't come into play behind the
> scenes in future, so it would be useful to be able to access
> the list without having to have advance information about how
> and where they were being created.

In general, when you rebuild the buffer's contents, there's no
guarantee the old buffers will be even useful.  What markers are we
talking about, besides window-point?