[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#32850: 27.0.50; window-swap-states doesn't swap window prev/next-buf

From: Juri Linkov
Subject: bug#32850: 27.0.50; window-swap-states doesn't swap window prev/next-buffers
Date: Thu, 25 Oct 2018 22:19:18 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu)

>>> (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.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]