> Yes, it creates new windows and window local things will get broken. But
> I do not understand what you mean with "overlay relationships" here.
> Emacs overlays (if that is what you mean) is tighed to the buffer, not
> the window.
Juanma explained that already. It can be done as
(dolist (overlay (overlays-in (point-min) (point-max)))
(when (eq (overlay-get overlay 'window) old-window)
(overlay-put overlay 'window new-window)))
> Maybe, but please be more specific about what will be missing when done
> on the lisp level.
On the Lisp level it might be difficult to handle `get-lru-window',
`buffer-display-count', `buffer-display-time', and the `keep-margins'
argument of `set-window-buffer'. It should be possible to handle
`window-dedicated-p', `window-scroll-bars', `window-fringes' but I don't
remember them all.