GNU bug report logs - #32850
27.0.50; window-swap-states doesn't swap window prev/next-buffers

Previous Next

Package: emacs;

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


Message #79 received at 32850 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: martin rudalics <rudalics <at> gmx.at>
Cc: 32850 <at> debbugs.gnu.org
Subject: Re: bug#32850: 27.0.50;
 window-swap-states doesn't swap window prev/next-buffers
Date: Thu, 25 Oct 2018 02:39:45 +0300
>> Then we desperately need functions that will serialize window
>> configurations to writable window states to save them in the
>> desktop file.
>
> What's wrong with
>
> (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?

(let (window-configurations window-states current-window-configuration
      ;; Let-bind there hooks to nil to prevent them from running
      (window-configuration-change-hook nil)
      (window-size-change-functions nil))

  ;; As an example, populate a list of window configurations.
  ;; In reality, all these configurations are different.
  (dotimes (_ (+ 10 (random 10)))
    (push (current-window-configuration) window-configurations))

  ;; Preserve the current window configuration
  (setq current-window-configuration (current-window-configuration))
  ;; Serialize window configurations for saving in the desktop file
  (setq window-states
        (mapcar (lambda (window-configuration)
                  (save-window-excursion
                    (set-window-configuration window-configuration)
                    (window-state-get nil t)))
                window-configurations))
  ;; Restore the previous window-configuration
  (set-window-configuration current-window-configuration)
  ;; Now window-states can be saved to the desktop file

  ;; Restore window-states from the desktop file
  ;; First, preserve the current window configuration
  (setq current-window-configuration (current-window-configuration))
  ;; Restore the saved list from the desktop file
  (setq window-configurations
        (mapcar (lambda (window-state)
                  (save-window-excursion
                    (window-state-put window-state nil 'safe)
                    (current-window-configuration)))
                window-states))
  ;; Restore the previous window-configuration
  (set-window-configuration current-window-configuration)

  ;; Now window-configurations are available for another session
  window-configurations)

While testing without let-binding window-configuration-change-hook to nil,
window-configuration-change-hook was called 50 times, observable with:

(add-hook 'window-configuration-change-hook
          (lambda () (message "window-configuration-change-hook called")))

when let-bound to nil, these hooks are not called.

But after let-binding window-size-change-functions to nil,
and testing with

(add-hook 'window-size-change-functions
          (lambda (_) (message "window-size-change-functions called")))

window-size-change-functions is still called once.
I don't understand why.




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.