GNU bug report logs -
#32850
27.0.50; window-swap-states doesn't swap window prev/next-buffers
Previous Next
Reported by: Juri Linkov <juri <at> linkov.net>
Date: Thu, 27 Sep 2018 00:06:02 UTC
Severity: minor
Found in version 27.0.50
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
>>> (save-window-excursion
>>> (set-window-configuration configuration)
>>> (window-state-get nil t))
>>
>> Is it really a good solution for serialization of tens of window configurations?
>> Is such code suitable to be placed to desktop.el?
>
> Which problems do you see in practice? I have no idea about the
> internals of desktop. If you mean that the windows' states have to be
> saved too often -
Yes, too often - according to desktop-auto-save-timeout, it should do
this juggling with window configurations and states every 30 seconds.
> maybe to a backup file and as such converted from configurations to
> states - we can, whenever desktop is active save a configuration
> immediately to a state whenever it is stored somewhere. That is, add
> some hook when a window configuration shall be saved to a register and
> that register should be considered writable and saved somewhere.
> Is it that what you mean?
In fact this means maintaining a duplicate data structure,
i.e. in parallel to keep in one list - window configurations,
but in another list - window states. The downside is data duplication.
If this is the only available solution, then it's ok.
But the problem is that window configurations can't be used
even in the same session, because they don't keep prev/next-buffers.
Please try to eval:
(defun set-buffers ()
(let* ((buffer-a (get-buffer-create "a"))
(marker-a (set-marker (make-marker) 1 buffer-a))
(buffer-b (get-buffer-create "b"))
(marker-b (set-marker (make-marker) 1 buffer-b)))
(set-window-prev-buffers nil (list (list buffer-a marker-a marker-a)
(list buffer-b marker-b marker-b)))
(set-window-next-buffers nil (list buffer-a))))
(progn (set-buffers)
(let ((window-state (window-state-get nil t)))
;; Reset prev/next-buffers
(set-window-prev-buffers nil nil)
(set-window-next-buffers nil nil)
;; Restore old state with preserved prev/next-buffers
(window-state-put window-state nil 'safe)
(list (window-prev-buffers) (window-next-buffers))))
window-state-put in the above code correctly restores the old values of
prev/next-buffers kept in window-state.
(progn (set-buffers)
;; Remember window-configuration with prev/next-buffers
(let ((window-configuration (current-window-configuration)))
;; Reset prev/next-buffers
(set-window-prev-buffers nil nil)
(set-window-next-buffers nil nil)
;; This doesn't restore remembered prev/next-buffers
(set-window-configuration window-configuration)
;; window-prev-buffers and window-next-buffers are still nil
(list (window-prev-buffers) (window-next-buffers))))
But unfortunately set-window-configuration doesn't restore
the old values of prev/next-buffers.
This bug report was last modified 6 years and 183 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.