> I don't know if the author of > https://www.reddit.com/r/emacs/comments/sthusa/window_xxx_is_not_a_valid_window_on_switching_tabs/ > will report the bug here, Please encourage the author again to report such bugs here. > but since it's easily reproducible, > here is the short test case, just evaluate this: > > (window-state-put > ... > nil 'safe) > > It fails with: > > Debugger entered--Lisp error: (error "# is not a valid window") > error("%s is not a valid window" #) > window-normalize-window(#) > window-deletable-p(#) > window-state-put I think the attached fixes it, please check. I have no idea whether the state is restored as intended, though. Thanks, martin