annotate lisp/vm/tapestry.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children 859a2309aef8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; Tools to configure your GNU Emacs windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;;; Copyright (C) 1991, 1993, 1994, 1995 Kyle E. Jones
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;;; This program is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;;; the Free Software Foundation; either version 1, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;;; This program is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;; A copy of the GNU General Public License can be obtained from this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;; program's author (send electronic mail to kyle@uunet.uu.net) or from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;; the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;;; 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;;; Send bug reports to kyle@uunet.uu.net.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 (provide 'tapestry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 (defvar tapestry-version "1.07")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 (defun tapestry (&optional frame-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 "Returns a list containing complete information about the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 configuration of Emacs frames, windows, buffers and cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 positions. Call the function set-tapestry with the list that this function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 returns to restore the configuration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 Optional first arg FRAME-LIST should be a list of frames; only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 configuration information about these frames will be returned.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 The configuration information is returned in a form that can be saved and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 restored across multiple Emacs sessions."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (let ((frames (or frame-list (tapestry-frame-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (frame-map (tapestry-frame-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (sf (tapestry-selected-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (other-maps nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (while frames
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (tapestry-select-frame (car frames))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (setq other-maps (cons (list (tapestry-window-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (tapestry-buffer-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (tapestry-position-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 other-maps)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 frames (cdr frames)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (tapestry-select-frame sf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (list frame-map other-maps)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (defun set-tapestry (map &optional n root-window-edges)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 "Restore the frame/window/buffer configuration described by MAP,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 which should be a list previously returned by a call to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 tapestry.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 Optional second arg N causes frame reconfiguration to be skipped
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 and the windows of the current frame will configured according to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 the window map of the Nth frame in MAP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 Optional third arg ROOT-WINDOW-EDGES non-nil should be a list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 containing the edges of a window in the current frame. This list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 should be in the same form as returned by the `window-edges'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 function. The window configuration from MAP will be restored in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 this window. If no window with these exact edges exists, a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 window that lies entirely within the edge coordinates will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 expanded until the edge coordinates match or the window bounded by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ROOT-WINDOW-EDGES is entirely contained within the expanded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 window. If no window entirely within the ROOT-WINDOW-EDGES edge
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 coordinates can be found, the window with the greatest overlap of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ROOT-WINDOW-EDGES will be used."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (let ((sf (tapestry-selected-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 frame-list frame-map other-maps other-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (setq frame-map (nth 0 map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 other-maps (nth 1 map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (if (and root-window-edges (null n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (setq n 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (if n
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (let (first-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (setq other-map (nth (1- n) other-maps))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (if (null other-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (error "No such map, %d" n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (setq first-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (tapestry-set-window-map (nth 0 other-map) root-window-edges))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (tapestry-set-buffer-map (nth 1 other-map) first-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (tapestry-set-position-map (nth 2 other-map) first-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (tapestry-set-frame-map frame-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;; frame list is reversed relative to the map order because
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;; created frames are added to the head of the list instead
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;; of the tail.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (setq frame-list (nreverse (tapestry-frame-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (while other-maps
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (tapestry-select-frame (car frame-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (tapestry-set-window-map (nth 0 (car other-maps)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (tapestry-set-buffer-map (nth 1 (car other-maps)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (tapestry-set-position-map (nth 2 (car other-maps)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (setq other-maps (cdr other-maps)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 frame-list (cdr frame-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (and (tapestry-frame-live-p sf) (tapestry-select-frame sf))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (defun tapestry-frame-map ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (let ((map (mapcar 'tapestry-frame-parameters (tapestry-frame-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 list cell frame-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (setq list map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 frame-list (tapestry-frame-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (while list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (setq cell (assq 'minibuffer (car list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (if (and cell (windowp (cdr cell)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (if (eq (tapestry-window-frame (cdr cell)) (car frame-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (setcdr cell t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (setcdr cell 'none)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (setq list (cdr list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 frame-list (cdr frame-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 map ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (defun tapestry-set-frame-map (map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 ;; some parameters can only be set only at frame creation time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ;; so all existing frames must die.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (let ((doomed-frames (tapestry-frame-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (while map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (tapestry-make-frame (car map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (setq map (cdr map)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (while doomed-frames
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (tapestry-delete-frame (car doomed-frames))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (setq doomed-frames (cdr doomed-frames)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (defun tapestry-window-map ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (let (maps map0 map1 map0-edges map1-edges x-unchanged y-unchanged)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (setq maps (mapcar 'tapestry-window-edges (tapestry-window-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (while (cdr maps)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (setq map0 maps)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (while (cdr map0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (setq map1 (cdr map0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 map0-edges (tapestry-find-window-map-edges (car map0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 map1-edges (tapestry-find-window-map-edges (car map1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 x-unchanged (and (= (car map0-edges) (car map1-edges))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (= (nth 2 map0-edges) (nth 2 map1-edges)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 y-unchanged (and (= (nth 1 map0-edges) (nth 1 map1-edges))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (= (nth 3 map0-edges) (nth 3 map1-edges))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (cond ((and (not x-unchanged) (not y-unchanged))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (setq map0 (cdr map0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 ((or (and x-unchanged (eq (car (car map0)) '-))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (and y-unchanged (eq (car (car map0)) '|)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (nconc (car map0) (list (car map1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (setcdr map0 (cdr map1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (setcar map0 (list (if x-unchanged '- '|)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (car map0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (car map1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (setcdr map0 (cdr map1))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (car maps)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (defun tapestry-set-window-map (map &optional root-window-edges)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (let ((map-width (tapestry-compute-map-width map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (map-height (tapestry-compute-map-height map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (root-window nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (if root-window-edges
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (let (w-list w-edges w-area
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 exact-w inside-w overlap-w max-overlap overlap)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (while (null root-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (setq exact-w nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 inside-w nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 overlap-w nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 max-overlap -1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 w-list (tapestry-window-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (while w-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (setq w-edges (tapestry-window-edges (car w-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 w-area (tapestry-window-area w-edges))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (if (equal w-edges root-window-edges)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (setq exact-w (car w-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 w-list nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (setq overlap (tapestry-window-overlap w-edges
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 root-window-edges)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 overlap (if overlap (tapestry-window-area overlap) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 w-area (tapestry-window-area w-edges))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (if (< max-overlap overlap)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (setq max-overlap overlap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 overlap-w (car w-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 ;; set inside-w each time we find a window inside
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ;; the root window edges. FSF Emacs gives space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ;; to the window above or to the left if there is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 ;; such a window. therefore we want to find the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ;; inside window that is bottom-most or right-most so that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ;; when we delete it, its space will be given to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ;; what will be the root window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (if (= w-area overlap)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (setq inside-w (car w-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (setq w-list (cdr w-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (cond (exact-w (setq root-window exact-w))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (inside-w
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 ;; how could a window be inside the root window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 ;; edges and there only be one window? a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 ;; multi-line minibuffer, that's how!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (if (not (one-window-p t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (delete-window inside-w)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (t (setq root-window overlap-w))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (tapestry-apply-window-map map map-width map-height root-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 root-window )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (if (tapestry-windows-match-map map map-width map-height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (tapestry-first-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (delete-other-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (setq root-window (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (tapestry-apply-window-map map map-width map-height root-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 root-window ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (defun tapestry-buffer-map ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (let ((w-list (tapestry-window-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 b list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (while w-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (setq b (window-buffer (car w-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 list (cons (list (buffer-file-name b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (buffer-name b))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 w-list (cdr w-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (nreverse list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (defun tapestry-set-buffer-map (buffer-map &optional first-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (let ((w-list (tapestry-window-list first-window)) wb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (while (and w-list buffer-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (setq wb (car buffer-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (set-window-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (car w-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (if (car wb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (or (get-file-buffer (car wb))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (find-file-noselect (car wb)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (get-buffer-create (nth 1 wb))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (setq w-list (cdr w-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 buffer-map (cdr buffer-map)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (defun tapestry-position-map ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (let ((sw (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (w-list (tapestry-window-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (while w-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (setq list (cons (list (window-start (car w-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (window-point (car w-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (window-hscroll (car w-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (eq (car w-list) sw))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 w-list (cdr w-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (nreverse list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (defun tapestry-set-position-map (position-map &optional first-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (let ((w-list (tapestry-window-list first-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (osw (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 sw p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (while (and w-list position-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (setq p (car position-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (and (car p) (set-window-start (car w-list) (car p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (and (nth 1 p) (set-window-point (car w-list) (nth 1 p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (and (nth 2 p) (set-window-hscroll (car w-list) (nth 2 p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (and (nth 3 p) (setq sw (car w-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 ;; move this buffer up in the buffer-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (select-window (car w-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (setq w-list (cdr w-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 position-map (cdr position-map)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (select-window (or sw osw))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (defun tapestry-apply-window-map (map map-width map-height current-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 &optional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 root-window-width
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 root-window-height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (let ((window-min-height 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (window-min-width 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 horizontal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (if (null root-window-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (setq root-window-height (window-height current-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 root-window-width (window-width current-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (while map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 ((numberp (car map)) (setq map nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 ((eq (car map) '-) (setq horizontal nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 ((eq (car map) '|) (setq horizontal t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (if (cdr map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (split-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 current-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (if horizontal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (/ (* (tapestry-compute-map-width (car map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 root-window-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 map-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (/ (* (tapestry-compute-map-height (car map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 root-window-height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 map-height))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 horizontal))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (if (not (numberp (car (car map))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (setq current-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (tapestry-apply-window-map (car map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 map-width map-height
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 current-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 root-window-width
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 root-window-height)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (and (cdr map) (setq current-window (next-window current-window 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (setq map (cdr map)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 current-window ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (defun tapestry-windows-match-map (map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 &optional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 map-width map-height
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 window-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 window-map-width
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 window-map-height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (or map-width
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (setq map-width (tapestry-compute-map-width map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 map-height (tapestry-compute-map-height map)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (or window-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (setq window-map (tapestry-window-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 window-map-height (tapestry-compute-map-height window-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 window-map-width (tapestry-compute-map-width window-map)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (let ((result t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (cond ((numberp (car map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (and (numberp (car window-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (= (/ (* (nth 0 map) window-map-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 map-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (nth 0 window-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (= (/ (* (nth 1 map) window-map-height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 map-height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (nth 1 window-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (= (/ (* (nth 2 map) window-map-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 map-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (nth 2 window-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (= (/ (* (nth 3 map) window-map-height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 map-height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (nth 3 window-map))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 ((eq (car map) '-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (if (not (eq (car window-map) '-))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (setq map (cdr map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 window-map (cdr window-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (while (and result map window-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (setq result (tapestry-windows-match-map (car map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 map-width
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 map-height
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (car window-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 window-map-width
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 window-map-height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 map (cdr map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 window-map (cdr window-map)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (and result (null map) (null window-map))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 ((eq (car map) '|)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (if (not (eq (car window-map) '|))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (setq map (cdr map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 window-map (cdr window-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (while (and result map window-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (setq result (tapestry-windows-match-map (car map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 map-width
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 map-height
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (car window-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 window-map-width
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 window-map-height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 map (cdr map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 window-map (cdr window-map)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (and result (null map) (null window-map)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (defun tapestry-find-window-map-edges (map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (let (nw-edges se-edges)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (setq nw-edges map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (while (and (consp nw-edges) (not (numberp (car nw-edges))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (setq nw-edges (car (cdr nw-edges))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (setq se-edges map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (while (and (consp se-edges) (not (numberp (car se-edges))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (while (cdr se-edges)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (setq se-edges (cdr se-edges)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (setq se-edges (car se-edges)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (if (eq nw-edges se-edges)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 nw-edges
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (setq nw-edges (copy-sequence nw-edges))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (setcdr (nthcdr 1 nw-edges) (nthcdr 2 se-edges))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 nw-edges )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (defun tapestry-compute-map-width (map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (let ((edges (tapestry-find-window-map-edges map)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (- (nth 2 edges) (car edges))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (defun tapestry-compute-map-height (map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (let ((edges (tapestry-find-window-map-edges map)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (- (nth 3 edges) (nth 1 edges))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 ;; delq is to memq as delassq is to assq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (defun tapestry-delassq (elt list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (let ((prev nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (curr list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (while curr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (if (eq elt (car (car curr)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (if (null prev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (setq list (cdr list) curr list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (setcdr prev (cdr curr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (setq curr (cdr curr)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (setq prev curr curr (cdr curr))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 list ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (defun tapestry-remove-frame-parameters (map params)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (let (frame-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (while params
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (setq frame-map (nth 0 map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (while frame-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (setcar frame-map (tapestry-delassq (car params) (car frame-map)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (setq frame-map (cdr frame-map)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (setq params (cdr params)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (defun tapestry-nullify-tapestry-elements (map &optional buf-file-name buf-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 window-start window-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 window-hscroll selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (let (p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (setq map (nth 1 map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (while map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (setq p (nth 1 (car map)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (while p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (and buf-file-name (setcar (car p) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (and buf-name (setcar (cdr (car p)) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (setq p (cdr p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (setq p (nth 2 (car map)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (while p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (and window-start (setcar (car p) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (and window-point (setcar (cdr (car p)) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (and window-hscroll (setcar (nthcdr 2 (car p)) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (and selected-window (setcar (nthcdr 3 (car p)) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (setq p (cdr p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (setq map (cdr map)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (defun tapestry-replace-tapestry-element (map what function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (let (mapi mapj p old new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (cond ((eq what 'buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (setq mapi 1 mapj 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 ((eq what 'buffer-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (setq mapi 1 mapj 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 ((eq what 'window-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (setq mapi 2 mapj 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 ((eq what 'window-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (setq mapi 2 mapj 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 ((eq what 'window-hscroll)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (setq mapi 2 mapj 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 ((eq what 'selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (setq mapi 2 mapj 3)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (setq map (nth 1 map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (while map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (setq p (nth mapi (car map)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (while p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (setq old (nth mapj (car p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 new (funcall function old))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (if (not (equal old new))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (setcar (nthcdr mapj (car p)) new))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (setq p (cdr p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (setq map (cdr map)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (defun tapestry-window-list (&optional first-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (let* ((first-window (or first-window (tapestry-first-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (windows (cons first-window nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (current-cons windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (w (next-window first-window 'nomini)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (while (not (eq w first-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (setq current-cons (setcdr current-cons (cons w nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (setq w (next-window w 'nomini)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 windows ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (defun tapestry-first-window ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (if (eq (tapestry-selected-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (tapestry-window-frame (minibuffer-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (next-window (minibuffer-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (let ((w (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (top (or (cdr (assq 'menu-bar-lines (tapestry-frame-parameters))) 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 edges)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (while (or (not (= 0 (car (setq edges (tapestry-window-edges w)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 ;; >= instead of = because in FSF Emacs 19.2x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 ;; (whenever the Lucid menubar code was added) the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 ;; menu-bar-lines frame parameter == 1 when the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 ;; Lucid menubar is enabled even though the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 ;; menubar doesn't steal the first line from the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 ;; window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (not (>= top (nth 1 edges))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (setq w (next-window w 'nomini)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 w )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (defun tapestry-window-area (edges)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (* (- (nth 3 edges) (nth 1 edges))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (- (nth 2 edges) (nth 0 edges))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (defun tapestry-window-overlap (e0 e1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (let (top left bottom right)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (cond ((and (<= (nth 0 e0) (nth 0 e1)) (< (nth 0 e1) (nth 2 e0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (setq left (nth 0 e1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 ((and (<= (nth 0 e1) (nth 0 e0)) (< (nth 0 e0) (nth 2 e1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (setq left (nth 0 e0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (cond ((and (< (nth 0 e0) (nth 2 e1)) (<= (nth 2 e1) (nth 2 e0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (setq right (nth 2 e1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 ((and (< (nth 0 e1) (nth 2 e0)) (<= (nth 2 e0) (nth 2 e1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (setq right (nth 2 e0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (cond ((and (<= (nth 1 e0) (nth 1 e1)) (< (nth 1 e1) (nth 3 e0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (setq top (nth 1 e1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 ((and (<= (nth 1 e1) (nth 1 e0)) (< (nth 1 e0) (nth 3 e1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (setq top (nth 1 e0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (cond ((and (< (nth 1 e0) (nth 3 e1)) (<= (nth 3 e1) (nth 3 e0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (setq bottom (nth 3 e1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 ((and (< (nth 1 e1) (nth 3 e0)) (<= (nth 3 e0) (nth 3 e1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (setq bottom (nth 3 e0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (and left top right bottom (list left top right bottom))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (defun tapestry-window-edges (&optional window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (if (fboundp 'window-pixel-edges)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (let ((edges (window-pixel-edges window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 tmp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (setq tmp edges)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (setcar tmp (/ (car tmp) (face-width 'default)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (setq tmp (cdr tmp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (setcar tmp (/ (car tmp) (face-height 'default)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (setq tmp (cdr tmp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (setcar tmp (/ (car tmp) (face-width 'default)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (setq tmp (cdr tmp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (setcar tmp (/ (car tmp) (face-height 'default)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 edges )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (window-edges window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 ;; We call these functions instead of calling the Emacs 19 frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 ;; functions directly to let this package work with v18 Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (defun tapestry-frame-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (if (fboundp 'frame-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (frame-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (list nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (defun tapestry-frame-parameters (&optional f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (if (fboundp 'frame-parameters)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (frame-parameters f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 nil ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (defun tapestry-window-frame (w)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (if (fboundp 'window-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (window-frame w)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 nil ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (defun tapestry-modify-frame-parameters (f alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (if (fboundp 'modify-frame-parameters)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (modify-frame-parameters f alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 nil ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (defun tapestry-select-frame (f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (if (fboundp 'select-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (select-frame f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 nil ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (defun tapestry-selected-frame ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (if (fboundp 'selected-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (selected-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 nil ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (defun tapestry-next-frame (&optional f all)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (if (fboundp 'next-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (next-frame f all)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 nil ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (defun tapestry-make-frame (&optional alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (if (fboundp 'make-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (make-frame alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 nil ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (defun tapestry-delete-frame (&optional f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (if (fboundp 'delete-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (delete-frame f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 nil ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (defun tapestry-frame-live-p (f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (if (fboundp 'frame-live-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (frame-live-p f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 t ))