>> I'd like to make it customizable by using the existing customization in >> the arg WRITABLE of window-state-get and window-persistent-parameters, >> even though formally prev/next-buffers is not a window parameter (maybe >> it should be, I don't know). > > Always keep in mind that prev_buffers and next_buffers need special > treatment in mark_object to make sure that dead buffers from window > configurations stored somewhere (for example in a register) get their > entries deleted and can be eventually reclaimed. This is something I > completely disregarded when writing the original code for navigating > these buffer lists. Stefan then wrote the code to do that in > mark_object. When testing the previous patch, I noticed that killed buffers automatically disappear from prev/next-buffers lists, so there are no # remains. Is it handled by code in kill-buffer? >> Done, with a small change: even though set-marker is idempotent in regard >> to its POSITION arg (i.e. if POSITION is a marker, it creates an identical >> marker), I added a check to not create a new one. OTOH, get-buffer is >> idempotent too, but it seems window-state-put never receives a structure >> with buffer objects, and I'm not sure why window-state-get should always >> use buffer-name regardless of the value WRITABLE, i.e. why should it return >> buffer names as strings instead of buffer objects even when WRITABLE is nil? > > Maybe because I didn't care about non-writable states back then. But > you're obviously right. Buffers can be renamed at will and in that > case we might have a state with a non-existent buffer or even buffers > with names switched and therefore invalid values of start or point. What do you think about creating new functions to convert the existing states from non-writable to writable and back? Then in the same session it would be more optimal to use window states with buffer/mark objects, and states to save to the desktop could be serialized by such functions. > So yes: Please use a buffer object for non-writable states. Here is a new patch: