Subject: bug#33532: 26.1; set-window-configuration does not restore display start

From: Eli Zaretskii <[email-masked]>
Date: Wed, 28 Nov 2018 08:41:57 +0200

> From: Markus Triska <[email-masked]>
> Date: Tue, 27 Nov 2018 23:11:21 +0100
> 
>     (let ((buf (get-buffer-create "buf")))
>       (switch-to-buffer buf)
>       (erase-buffer)
>       (dotimes (x 10)
>         (insert (format "x is %s\n" x)))
>       (recenter 3)
>       (sit-for 1)
>       (let ((conf (current-window-configuration))
>             (ws (window-start))
>             (str (with-current-buffer buf (buffer-string))))
>         (with-current-buffer buf
>           (erase-buffer)
>           (insert str))
>         (set-window-configuration conf)
>         (sit-for 1)
>         (message "window-start: %s vs. %s" ws (window-start))))
> 
> This shows that after set-window-configuration, even though the buffer
> content is the same as at the time the configuration was obtained, the
> value of (window-start) differs from before: After the window
> configuration is set, (window-start) is 1. I expect it to be 50 (i.e.,
> the value at the time the configuration was obtained), because the
> documentation of current-window-configuration states:

The window-start point is a marker, and is saved as such.  Your code
replaces the entire text of the buffer with something new, so all the
markers are invalidated.

How important is the use case of replacing buffer text with identical
text?  Because replacing with a different text will make preserving
window-start position based on its numerical value not really a
sensible thing, would it?  It could even be impossible, e.g. if the
same position happens to be in the middle of a sequence of composed
characters.