Subject: bug#23858: 25.0.95; window-state-get doesn't preserve side window status

From: bmag bmag <[email-masked]>
Date: Sat, 2 Jul 2016 21:39:10 +0300

First of all, thanks for the reply. Now for the matter at hand:

> It would be a (slight) penalty for the majority of users who never use
> side windows.

Can you elaborate? AFAIU it only affects saving and loading of window
configurations, which isn't used all that much, and we're only talking
about reading and setting a window parameter. I could be mistaken, but
the penalty sounds negligible to me.

> A more stringent problem is that I wouldn't know what to
> do with other window parameters like 'quit-restore', 'window-atom',
> 'delete-window', 'other-window'?  Wouldn't it be inconsistent to add
> only these two to the list of persistent parameters?

To my understanding, these are all part of the window configuration. If
these parameters are changed, the window's behavior changes. Thus, if the
parameters aren't persistent, the loaded window configuration is
slightly different than the saved one. I'm not familiar with all the
existing window parameters, but as long as their values can persisted
I'd assume the parameters should be persistent.

> The major obstacle though is that side windows conceptually should not
> be saved by ‘window-state-get’ at all.  This was part of the IDE concept
> discussed on emacs-devel many years ago: The window states to save and
> restore are those of the interior (non-side) windows.  Normally, the
> side windows would stay arranged permanently around the major non-side
> window and only the contents of the latter would change according to
> what the user prefers to work on.

I assume you're referring to the discussions around March and April
2008. I've read some of them[1][2][3][4] and it was quite interesting. I
don't understand why only the state of the major non-side window is
supposed to be saved. 'window-state-get' seems an excellent way to get
the window configuration of both the entire frame and "just" a branch of
the frame's window tree.

First, because different (theoretical) perspectives can have different
side windows. For example, a "coding" perspective would display an
source file in the main window and an overview in a side window, while a
"debugging" perspective could display watched variables in a different
side window.

Second, because it's possible that the user will sometime want to see a
side window (for example an overview of source file) and sometimes not.
Part of the perspective's state in this case would be weather the side
window is displayed or hidden. Using 'window-state-get' is a good way of
getting the entire window configuration, including the side window's
state. I'm imagining a situation where there's a shortcut to toggle
visibility of the side window.

> Out of curiosity: Which kinds of buffers do you display on the left?

Currently I'm trying to put NeoTree[5] and imenu-list[6] on the left side,
one
beneath the other, and testing how well that works with other features
and packages that I'm using, such as Eyebrowse[7] and persp-mode[8].

> > How I modified 'window-persistent-parameters' to fix the problem:
> > (add-to-list 'window-persistent-parameters '(window-side . writable))
> > (add-to-list 'window-persistent-parameters '(window-slot . writable))
>
> This is IMO the correct way to handle this.  Does it work?  Did you ever
> test it via the ‘desktop-save’ feature?

I'm testing via 'eyebrowse-switch-to-window-config' of the Eyebrowse
package, which uses 'window-state-put' and 'window-state-get' on the
frame's root window with non-nil 'writable' argument.

[1]: patch for optional inhibit of delete-other-windows(IDE feature):
https://lists.gnu.org/archive/html/emacs-devel/2008-04/msg01867.html
[2]: What IDE features are in CEDET?:
https://lists.gnu.org/archive/html/emacs-devel/2008-04/msg01857.html
[3]: Neat features in Eclipse editor:
https://lists.gnu.org/archive/html/emacs-devel/2008-03/msg02254.html
[4]: Window configuration UI (was: Neat features in Eclipse editor):
https://lists.gnu.org/archive/html/emacs-devel/2008-03/msg02433.html
[5]: NeoTree: https://github.com/jaypei/emacs-neotree
[6]: imenu-list: https://github.com/bmag/imenu-list/ (I'm the author)
[7]: Eyebrowse: https://github.com/wasamasa/eyebrowse/
[8]: persp-mode: https://github.com/Bad-ptr/persp-mode.el