> Is 'keep-windows' doable for 'window-state-put' as well? I attach a patch that adds a fourth argument to 'window-state-put'. It and a new 'set-window-configuration' now use a new function I called 'marker-last-position' that returns the last position of a marker even after its buffer was killed. The patch also fixes a bug in 'window--state-put-2' that can be reproduced with the following simple scenario (let ((buffer (get-buffer-create "*foo*")) state) (pop-to-buffer buffer) (setq state (window-state-get)) (kill-buffer buffer) (window-state-put state)) Did you never see it? > So maybe the same option 'keep-windows' could call the same hook > 'post-set-window-configuration-functions' from 'window-state-put' too? I added a new hook called 'window-state-put-keep-window-functions' with the same arguments as 'post-set-window-configuration-functions'. Maybe people wanted to keep them apart. If you think the hook should be also run when there are no "kept" windows, we can do that as well. I tested it here with (defun foo (frame windows) (while windows (let* ((quad (car windows)) (window (car quad)) (buffer (find-file-noselect (buffer-file-name (nth 1 quad))))) (when buffer (set-window-buffer window buffer) (set-window-point window (nth 3 quad)) (set-window-start window (nth 2 quad) t))) (setq windows (cdr windows)))) (add-hook 'window-state-put-keep-window-functions 'foo) (let ((window (selected-window)) (buffer (pop-to-buffer (find-file-noselect "..."))) (window-1 (split-window)) (window-2 (split-window nil nil t)) state) (set-window-point window-1 5000) (set-window-point window-2 10000) (setq state (window-state-get)) (y-or-n-p "State saved ...") (delete-other-windows window) (kill-buffer buffer) (y-or-n-p "State reset ...") (window-state-put state nil nil t) (message "State restored")) martin