>> You mean to do away with the KEEP-WINDOWS argument and keep windows iff >> `window-state-put-keep-window-functions' is non-nil? > > Yes, I meant removing the KEEP-WINDOWS argument. Patch attached. I now provide only one hook I called 'window-kept-windows-functions' which is run by both 'set-window-configuration' and 'window-state-put'. Tested with (defun foo (frame windows) (while windows (let* ((quad (car windows)) (window (car quad)) (name (buffer-file-name (nth 1 quad))) (buffer (and name (find-file-noselect name)))) (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-kept-windows-functions 'foo) (let ((window (selected-window)) (buffer (pop-to-buffer (find-file-noselect "..."))) (window-1 (split-window)) (window-2 (split-window nil nil t)) configuration) (set-window-point window-1 5000) (set-window-point window-2 10000) (setq configuration (current-window-configuration)) (y-or-n-p "Configuration saved ...") (delete-other-windows window) (kill-buffer buffer) (y-or-n-p "Configuration reset ...") (set-window-configuration configuration) (message "Configuration restored")) (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) (message "State restored")) >> This would be up to you to decide. Only some practice can tell what's >> better here. > > Otherwise users won't be able to use this hook for existing commands > that don't set the KEEP-WINDOWS argument. OK. But note that we now run this hook even if nothing in the window configuration changes, typically, when calling 'read-minibuffer'. So use it with due care (for example, have the tab code bind it exclusively around its calls of 'set-window-configuration'). martin