all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* re-generating a window-configuration by program
@ 2003-12-19  8:06 Klaus Berndl
  2003-12-19 17:21 ` Kevin Rodgers
  2003-12-20 16:05 ` Eli Zaretskii
  0 siblings, 2 replies; 3+ messages in thread
From: Klaus Berndl @ 2003-12-19  8:06 UTC (permalink / raw)



Hi,

suppose you have a list of windows of a frame (got by `window-list') and for
each window its edges (got by `window-edges') - all of this stored in a
suitable manner in an alist for example. This is something similar what
`current-window-configuration' returns but not a hidden data-structure but an
"open" list-structure.

Let us say we have a frame splitted in several arbitrary windows and we have
stored such a "hand-made" window-configuration for this frame in a variable
named `my-own-window-config'.

OK, then i want to do the following:
1. Calling `delete-other-windows' so this frame contains only one window.
2. Calling an algorithm which goes through the window-config in
   `my-own-window-config' and re-generates the original window-layout the
   frame had before step 1. This re-generation has to be done by running all
   needed calls to split-window-vertically, split-window-horizontally,
   enlarge-window, shrink-window.

Does anybody know such an algorithm which goes through a list of windows and
its edge-coordinates and rebuilds only with this information the specified
window-layout?

I know there is `current-window-configuration' etc. but for my purpose this is
not applicable because i want to apply this algorithm only to a part of a
frame:

   -------------------------------------------------------
   |              |                                      |
   |              |                                      |
   |              |                                      |
   |       A      |                 E                    |
   |              |                                      |
   |              |                                      |
   |              |                                      |
   |              |                                      |
   |              |                                      |
   |--------------|                                      |
   |       B      |                                      |
   -------------------------------------------------------
   |                                                     |
   |                    C                                |
   |                                                     |
   -------------------------------------------------------


I have already a program which generates the layout above, means it splits the
frame in the windows A, B, C and E. Now suppose someone splits the window E in
arbitrary "subwindows"... Then i want to store the window-layout of the area E
as a window-config like described above. Then a special window-deleter
restores the layout above (i.e. unsplits only area E) and then i want to run
the algorithm i asked for to restore the splitted layout of area E.

Is this problem described understandable?

All hints for this algorithm (maybe already implemented something similar in
other elisp-packages) are appreciated.

Thanks a lot in advance!
Klaus


   
-- 
Klaus Berndl			mailto: klaus.berndl@sdm.de
sd&m AG				http://www.sdm.de
software design & management	
Carl-Wery-Str. 42, 81739 Muenchen, Germany
Tel +49 89 63812-392, Fax -220

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: re-generating a window-configuration by program
  2003-12-19  8:06 re-generating a window-configuration by program Klaus Berndl
@ 2003-12-19 17:21 ` Kevin Rodgers
  2003-12-20 16:05 ` Eli Zaretskii
  1 sibling, 0 replies; 3+ messages in thread
From: Kevin Rodgers @ 2003-12-19 17:21 UTC (permalink / raw)


Klaus Berndl wrote:

> Is this problem described understandable?
> 
> I have already a program which generates the layout above, means it
> splits the frame in the windows A, B, C and E. Now suppose someone
> splits the window E in arbitrary "subwindows"... Then i want to store
> the window-layout of the area E as a window-config like described
> above. Then a special window-deleter restores the layout above
> (i.e. unsplits only area E) and then i want to run the algorithm i
> asked for to restore the splitted layout of area E.

The problem is well-described, but your approach is flawed: your window
configuration data structure describes each window as a component of the
frame (at the same level as the other windows).  But you want to restore
the configuration as if the windows form a hierarchy.  The only way to
do that is to record the chain of events leading to the configuration;
e.g. window F was formed by splitting window E (horizontally or
vertically).  Because of the numerous ways windows can be created,
deleted, and modified, I don't think it is workable to advise the
split-window-*, delete-window, etc. commands; instead, try to use these
(documented in the Window Hooks node of the Emacs Lisp manual):

 - Variable: window-size-change-functions
     This variable holds a list of functions to be called if the size
     of any window changes for any reason.  The functions are called
     just once per redisplay, and just once for each frame on which
     size changes have occurred.

     Each function receives the frame as its sole argument.  There is no
     direct way to find out which windows on that frame have changed
     size, or precisely how.  However, if a size-change function
     records, at each call, the existing windows and their sizes, it
     can also compare the present sizes and the previous sizes.

     Creating or deleting windows counts as a size change, and therefore
     causes these functions to be called.  Changing the frame size also
     counts, because it changes the sizes of the existing windows.
...
 - Variable: window-configuration-change-hook
     A normal hook that is run every time you change the window
     configuration of an existing frame.  This includes splitting or
     deleting windows, changing the sizes of windows, or displaying a
     different buffer in a window.  The frame whose window
     configuration has changed is the selected frame when this hook
     runs.


-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: re-generating a window-configuration by program
  2003-12-19  8:06 re-generating a window-configuration by program Klaus Berndl
  2003-12-19 17:21 ` Kevin Rodgers
@ 2003-12-20 16:05 ` Eli Zaretskii
  1 sibling, 0 replies; 3+ messages in thread
From: Eli Zaretskii @ 2003-12-20 16:05 UTC (permalink / raw)


> From: Klaus Berndl <klaus.berndl@sdm.de>
> Newsgroups: gnu.emacs.help
> Date: 19 Dec 2003 09:06:55 +0100
> 
> OK, then i want to do the following:
> 1. Calling `delete-other-windows' so this frame contains only one window.
> 2. Calling an algorithm which goes through the window-config in
>    `my-own-window-config' and re-generates the original window-layout the
>    frame had before step 1. This re-generation has to be done by running all
>    needed calls to split-window-vertically, split-window-horizontally,
>    enlarge-window, shrink-window.
> 
> Does anybody know such an algorithm which goes through a list of windows and
> its edge-coordinates and rebuilds only with this information the specified
> window-layout?

Any reason why the winner.el package could not help you do what you
want?

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-12-20 16:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-12-19  8:06 re-generating a window-configuration by program Klaus Berndl
2003-12-19 17:21 ` Kevin Rodgers
2003-12-20 16:05 ` Eli Zaretskii

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.