[Top][All Lists]

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

Re: Customize ‘window-state-get/put’

From: Yuan Fu
Subject: Re: Customize ‘window-state-get/put’
Date: Thu, 10 Oct 2019 21:38:09 -0400

> This is exactly what was needed for a long time.  Currently the desktop
> saves window-states with buffer names.  But after restoring the desktop,
> non-file buffers get lost, their windows are simply removed after restoring
> by window-state-put.  This has even more adverse effect now since tabs
> are saved in the desktop file and after restoring, clicking on a tab
> displays an irrelevant buffer that replaces the saved non-file buffer.
> What could be improved is to allow a non-file non-persistent mode
> to provide a hook like ‘desktop-save-buffer’ that will return
> a lambda that will be saved to the desktop like in your example above.
> Then after loading from the desktop this lambda could restore the buffer.

After thinking about your suggestion, I start to believe my experiment
isn’t the best approach (to solve the problem you mentioned above and
the problem I mentioned about gdb-mi). For your problem, since there are
tmp buffers that are not in any window, window.el clearly isn’t the
right place to handle them. I think desktop.el should handle them. And I
guess that’s what you meant. The creator of the tmp buffers could
provide a buffer local function that when called, returns a lambda form
that can be used to restore the tmp buffer. Or, if all you care about is
the missing windows resulted by missing tmp buffers, desktop.el can just
store the content of the tmp buffers (that are in a window when saving
desktop) in a cache file like other persistent mode do.

What’s more, above thought process reminded me that window-state-get/put
should probably stay away from buffer manipulation. And I think I can
achieve what I want to do without modifying window-state-get/put. To
recap, I want to save the window configuration and the type of the
function (register, breakpoint, etc) of each window, so that I can
restore that buffer later. I can do this: Before calling the state-get,
I go through each window and replace the buffers in them with
placeholder buffers and store the buffer type (breakpoint, register,
etc) in a window parameter. When later I restored the window
configuration, I go through each window and restore each buffer by the
window parameter I saved.

I think I can take back my request to modify window-state-get/put now.

A side note: Although I use “restore” in both problems, the stuff we are
trying to restore are different, your tmp buffer is just an ordinary
buffer and you want that exactly buffer back, and I’m not saving a
buffer but rather the type information. That took me a while to realize.


reply via email to

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