emacs-devel
[Top][All Lists]
Advanced

[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: Wed, 09 Oct 2019 20:35:51 -0400

> But fortunately now we have window-states that are better suitable to build
> the feature that you are adding.  So if you will have such template based
> on exported window-state layout:
>
> (hc (vc (leaf (buffer "\\`\\*\\(locals\\|registers\\) of .*\\*\\'"))
>         (leaf (buffer "\\`\\*\\(breakpoints\\|threads\\) of .*\\*\\'")))
>     (vc (leaf (buffer "\\`\\*memory of .*\\*\\'"))
>         (leaf (buffer "\\`\\*stack frames of .*\\*\\'"))))
>
> (window-sizes are omitted in this example, but they could be expressed
> as percentage of relative window dimensions)
>
> then calling (display-buffer "*memory of emacs*") could search in
> such window-tree, find a window that matches the buffer name and
> display this buffer in it.
>
> This could be implemented by just adding a new display-buffer action.

I’m not sure what are you trying to do overall. Why don’t I just create
the buffer by the buffer configurations I saved when saving the window
configuration?

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.

WDYT?

Yuan

Attachment: 0001-window.patch
Description: Text Data


reply via email to

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