windata - Perl Development Environment
Description: Perl Development Environment

Next: tree-mode, Previous: perlapi, Up: Top

## 17 Window configuration to list

Emacs can save window configuration when it is running. The configuration can be persisted between different sessions. `windata` provide a way to save window configuration.

— Function: windata-current-winconf

> Convert window configurate to a list. The CAR part of the list describe how to restore the window, the CDR part of the list determine which window is selected.

— Function: windata-restore-winconf &optional inside-p

> Restore window configuration from `windata-current-winconf'. When INSIDE-P is non-nil, that mean the window configuration is restore in current window, that is to say don't delete other windows before restore the configuration.

— User Option: windata-data-function

> A function to extract data for future restore window. Default is save the window buffer name. Accept one parameter, the window, and should return a lisp object that has print syntax.

— User Option: windata-data-restore-function

> A function to restore window buffer from saved data. Default is set window buffer to the buffer with saved name. Accept two parameters, the window and a saved lisp object by `windata-data-function`.

— Command: windata-name-winconf name

> Save window configuration with NAME.

— Command: windata-restore-named-winconf name

> Restore saved window configuration by NAME.

— Function: windata-display-buffer buf frame-p dir size &optional delete-p

> Display buffer more precisely. FRAME-P is non-nil and not window, the displayed buffer affect the whole frame, that is to say, if DIR is right or left, the displayed buffer will show on the right or left in the frame. If it is nil, the buf will share space with current window.

> DIR can be one of member of (right left top bottom).

> SIZE is the displayed windowed size in width(if DIR is left or right) or height(DIR is top or bottom). It can be a decimal which will stand for percentage of window(frame) width(heigth)

> DELETE-P is non-nil, the other window will be deleted before display the BUF.

The behavior of `windata-display-buffer` is better show as following pictures:

         (setq buf (get-buffer "*Messages*"))
         (windata-display-buffer buf 'window 'top 0.3 nil)    ; 2
         (windata-display-buffer buf 'window 'bottom 0.3 nil) ; 3
         (windata-display-buffer buf 'window 'left 0.3 nil)   ; 4
         (windata-display-buffer buf 'window 'right 0.3 nil)  ; 5

         (windata-display-buffer buf 'frame 'top 0.3 nil)     ; 6
         (windata-display-buffer buf 'frame 'bottom 0.3 nil)  ; 7
         (windata-display-buffer buf 'frame 'left 0.3 nil)    ; 8
         (windata-display-buffer buf 'frame 'right 0.3 nil)   ; 9

         ;; when delete-p is presented, FRAME-P make no sense.
         (windata-display-buffer buf 'frame 'top 0.3 t)       ; 10
         (windata-display-buffer buf 'frame 'bottom 0.3 t)    ; 11
         (windata-display-buffer buf 'frame 'left 0.3 t)      ; 12
         (windata-display-buffer buf 'frame 'right 0.3 t)     ; 13
         (windata-display-buffer buf 'window 'top 0.3 t)      ; 10
         (windata-display-buffer buf 'window 'bottom 0.3 t)   ; 11
         (windata-display-buffer buf 'window 'left 0.3 t)     ; 12
         (windata-display-buffer buf 'window 'right 0.3 t)    ; 13

       +------+-------+    +------+-------+    +------+-------+
       |      |       |    |      | N     |    |      |       |
       |      | P     |    |      |-------+    |      | P     |
       |      |       |    |      | P     |    |      |       |
       |      |       |    |      |       |    |      +-------+
       |      |       |    |      |       |    |      | N     |
       +------+-------+    +------+-------+    +------+-------+
             (1)                 (2)                 (3)
       +------+--+----+    +------+----+--+    +--------------+
       |      |  |    |    |      |    |  |    |      N       |
       |      |N | P  |    |      | P  |N |    +------+-------+
       |      |  |    |    |      |    |  |    |      |       |
       |      |  |    |    |      |    |  |    |      | P     |
       |      |  |    |    |      |    |  |    |      |       |
       +------+--+----+    +------+----+--+    +------+-------+
            (4)                  (5)                 (6)
       +------+-------+    +---+-----+----+    +----+----+----+
       |      |       |    |   |     |    |    |    |    |    |
       |      | P     |    | N |     |    |    |    |    |    |
       |      |       |    |   |     | P  |    |    | P  | N  |
       +------+-------+    |   |     |    |    |    |    |    |
       |      N       |    |   |     |    |    |    |    |    |
       +--------------+    +---+-----+----+    +----+----+----+
            (7)                  (8)                 (9)
       +--------------+    +--------------+    +----+---------+
       |    N         |    |              |    |    |         |
       +--------------+    |     P        |    | N  | P       |
       |    P         |    |              |    |    |         |
       |              |    +--------------+    |    |         |
       |              |    |     N        |    |    |         |
       +--------------+    +--------------+    +----+---------+
            (10)                 (11)                (12)
       +----------+---+
       |          |   |
       |   P      | N |
       |          |   |
       |          |   |
       |          |   |
       +----------+---+
            (13)

The start window is as picture 1, the selected window is indicated by “P”, and new appear window indicated by “N”. The simplest sitiation is when DELETE-P is non-nil, after calling the function, there are only two window left. When FRAME-P is 'window or nil, the new window will only take the space from the selected window. When FRAME-P is non-nil except 'window, the original window still has the same configuration.