[Top][All Lists]

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

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

From: Juri Linkov
Subject: Re: Customize ‘window-state-get/put’
Date: Fri, 11 Oct 2019 00:54:39 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu)

> OTOH, here is an experiment I did earlier today. I optionally replace
> the buffer names and configurations with a function when saving window
> config. So instead of
>     (buffer "*scratch*"
>              (selected . t)             
>              ...
>              (dedicated)
>              (point . 290)
>              (start . 1))
> I save
>     (buffer lambda nil
>              (create-my-buffer "some useful info"))
> And when window-state-put finds out the data is not buffer name but a
> function, it simply calls the function to restore the buffer. This way
> we can store information about the buffer and how to restore it in a
> rather compact way. The change to existing code is pretty small, too.

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.

reply via email to

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