annotate lisp/window-xemacs.el @ 1833:eed841acc858

[xemacs-hg @ 2003-12-19 14:28:45 by youngs] 2003-12-15 Steve Youngs <sryoungs@bigpond.net.au> * wid-edit.el (lazy): New. (widget-child-value-get): New. (widget-child-value-inline): New. (widget-child-validate): New. (widget-type-value-create): New. (widget-type-default-get): New. (widget-type-match): New. This adds a "lazy" widget to allow the definition of recursive datatypes for customize. The composite widgets expand their subtypes immediately, which cause obvious problems for recursive datatypes. The "lazy" will only expand them when needed, hense the name. From Per Abrahamsen <abraham@dina.kvl.dk> 2003-12-15 Steve Youngs <sryoungs@bigpond.net.au> * lispref/customize.texi (Defining New Types): New node. From Per Abrahamsen <abraham@dina.kvl.dk>
author youngs
date Fri, 19 Dec 2003 14:29:07 +0000
parents c5f86842283a
children 8e7b4a0c1a81
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 ;;; window-xemacs.el --- XEmacs window commands aside from those written in C.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 ;; Copyright (C) 1985, 1989, 1993-94, 1997 Free Software Foundation, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 ;; Copyright (C) 1995, 1996 Ben Wing.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 ;; Maintainer: XEmacs Development Team
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 ;; Keywords: frames, extensions, dumped
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 ;; This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 ;; XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 ;; under the terms of the GNU General Public License as published by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 ;; any later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful, but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 ;; General Public License for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 ;; along with XEmacs; see the file COPYING. If not, write to the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 ;; Free Software Foundation, 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 ;; Boston, MA 02111-1307, USA.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 ;;; Synched up with: Not synched.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 ;;; Commentary:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 ;; This file is dumped with XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 ;; slb - 5/29/97
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 ;; Split apart from window.el in order to keep that file better in synch
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 ;; with Emacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 ;;; Code:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 (defgroup windows nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 "Windows within a frame."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 :group 'environment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 (defun recenter (&optional n window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 "Center point in WINDOW and redisplay frame. With N, put point on line N.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 The desired position of point is always relative to the window.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 Just C-u as prefix means put point in the center of the window.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 No N (i.e., it is nil) erases the entire frame and then
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 redraws with point in the center of the window.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 If WINDOW is nil, the selected window is used."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 (interactive "_P")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 (center-to-window-line (if (consp n) nil n) window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 (when (null n)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 (redraw-frame (window-frame window) t)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
54 (defun backward-other-window (count &optional which-frames which-devices)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
55 "Select the COUNT'th different window on this frame, going backwards.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
56 This is just like calling `other-window' with COUNT negated."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 (interactive "p")
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
58 (other-window (- count) which-frames which-devices))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 (defalias 'windows-of-buffer 'get-buffer-window-list)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 (defun buffer-in-multiple-windows-p (&optional buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 "Return t if BUFFER is in multiple windows.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 If BUFFER is not specified, the current buffer will be used."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 (setq buffer (or buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 (get-buffer buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 (get-file-buffer buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 (current-buffer)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 (> (length (windows-of-buffer buffer)) 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 (defun window-list (&optional frame minibuf window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 "Return a list of windows on FRAME, beginning with WINDOW.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 FRAME and WINDOW default to the selected ones.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 Optional second arg MINIBUF t means count the minibuffer window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 even if not active. If MINIBUF is neither t nor nil it means
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 not to count the minibuffer even if it is active."
1261
465bd3c7d932 [xemacs-hg @ 2003-02-06 06:35:47 by ben]
ben
parents: 1230
diff changeset
77 (setq frame (or frame (selected-frame))
465bd3c7d932 [xemacs-hg @ 2003-02-06 06:35:47 by ben]
ben
parents: 1230
diff changeset
78 window (or window (selected-window frame)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 (if (not (eq (window-frame window) frame))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 (error "Window must be on frame."))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 (let ((current-frame (selected-frame))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 list)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 (unwind-protect
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 (save-window-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 (select-frame frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 (walk-windows
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 (function (lambda (cur-window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 (if (not (eq window cur-window))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 (setq list (cons cur-window list)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 minibuf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 (setq list (cons window list)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 (select-frame current-frame))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 ;; We used to have set-window-dedicated-p as an obsolete version
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 ;; of set-window-buffer-dedicated, but it really makes more sense
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 ;; this way.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 (make-obsolete 'set-window-buffer-dedicated 'set-window-dedicated-p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 (defun set-window-buffer-dedicated (window buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 "Make WINDOW display BUFFER and be dedicated to that buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 Then Emacs will not automatically change which buffer appears in WINDOW.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 If BUFFER is nil, make WINDOW not be dedicated (but don't change which
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 buffer appears in it currently)."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 (if (bufferp buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 (set-window-buffer window (get-buffer-create buffer)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 (set-window-dedicated-p window (not (null buffer))))
1149
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
107
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
108 ;; Window configurations
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109
1149
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
110 (defstruct saved-window
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
111 currentp minibufferp minibuffer-scrollp
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
112 buffer mark-marker
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
113 start-marker
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
114 point-marker
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
115 pixel-left pixel-top pixel-right pixel-bottom
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
116 hscroll modeline-hscroll
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
117 dedicatedp
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
118 first-hchild first-vchild next-child)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
119
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
120 (defstruct window-configuration
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
121 frame
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
122 frame-pixel-width frame-pixel-height
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
123 current-buffer
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
124 minibuffer-pixel-height
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
125 min-width min-height
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
126 saved-root-window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
127
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
128 (defun window-configuration-equal (conf-1 conf-2)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
129 "Returns a boolean indicating whether the two given configurations
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
130 are identical."
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
131 (or (eq conf-1 conf-2)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
132 (and (eq (window-configuration-frame conf-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
133 (window-configuration-frame conf-2))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
134 (= (window-configuration-frame-pixel-width conf-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
135 (window-configuration-frame-pixel-width conf-2))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
136 (= (window-configuration-frame-pixel-height conf-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
137 (window-configuration-frame-pixel-height conf-2))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
138 (eq (window-configuration-current-buffer conf-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
139 (window-configuration-current-buffer conf-2))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
140 (saved-window-equal (window-configuration-saved-root-window conf-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
141 (window-configuration-saved-root-window conf-2)))))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
142
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
143 (defun saved-window-equal (saved-1 saved-2)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
144 "Returns a boolean indicating whether the two given saved windows
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
145 are identical."
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
146 (or (eq saved-1 saved-2)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
147 (and (eq (saved-window-currentp saved-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
148 (saved-window-currentp saved-2))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
149 (eq (saved-window-minibuffer-scrollp saved-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
150 (saved-window-minibuffer-scrollp saved-2))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
151 (eq (saved-window-buffer saved-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
152 (saved-window-buffer saved-2))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
153 (equal (saved-window-mark-marker saved-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
154 (saved-window-mark-marker saved-2))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
155 (or (and (saved-window-currentp saved-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
156 (saved-window-currentp saved-2))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
157 (equal (saved-window-start-marker saved-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
158 (saved-window-start-marker saved-2)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
159 (or (and (saved-window-currentp saved-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
160 (saved-window-currentp saved-2))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
161 (equal (saved-window-point-marker saved-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
162 (saved-window-point-marker saved-2)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
163 (= (saved-window-pixel-left saved-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
164 (saved-window-pixel-left saved-2))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
165 (= (saved-window-pixel-top saved-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
166 (saved-window-pixel-top saved-2))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
167 (= (saved-window-pixel-right saved-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
168 (saved-window-pixel-right saved-2))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
169 (= (saved-window-pixel-bottom saved-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
170 (saved-window-pixel-bottom saved-2))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
171 (= (saved-window-hscroll saved-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
172 (saved-window-hscroll saved-2))
1387
e04cd2f562b7 [xemacs-hg @ 2003-03-26 15:09:51 by james]
james
parents: 1261
diff changeset
173 (equal (saved-window-modeline-hscroll saved-1)
e04cd2f562b7 [xemacs-hg @ 2003-03-26 15:09:51 by james]
james
parents: 1261
diff changeset
174 (saved-window-modeline-hscroll saved-2))
1149
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
175 (eq (saved-window-dedicatedp saved-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
176 (saved-window-dedicatedp saved-2))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
177 (maybe-saved-window-equal (saved-window-first-hchild saved-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
178 (saved-window-first-hchild saved-2))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
179 (maybe-saved-window-equal (saved-window-first-vchild saved-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
180 (saved-window-first-vchild saved-2))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
181 (maybe-saved-window-equal (saved-window-next-child saved-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
182 (saved-window-next-child saved-2)))))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
183
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
184 (defun maybe-saved-window-equal (maybe-saved-1 maybe-saved-2)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
185 "Returns a boolean indicating whether the two given saved windows
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
186 or NILs are identical."
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
187 (cond
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
188 ((and (not maybe-saved-1) (not maybe-saved-2)) t)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
189 ((not maybe-saved-1) (not maybe-saved-2))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
190 ((not maybe-saved-2) (not maybe-saved-1))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
191 (t (saved-window-equal maybe-saved-1 maybe-saved-2))))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
192
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
193 (defun current-window-configuration (&optional frame)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
194 "Return an object representing the current window configuration of FRAME.
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
195 If FRAME is nil or omitted, use the selected frame.
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
196 This describes the number of windows, their sizes and current buffers,
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
197 and for each window on FRAME the displayed buffer, where display
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
198 starts, and the positions of point and mark.
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
199 An exception is made for point in the current buffer:
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
200 its value is -not- saved."
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
201 (let ((frame (or frame (selected-frame))))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
202 ;; The original C code used complicated but still incomplete logic
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
203 ;; to decide if and how to restore the size of the minibuffer. It
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
204 ;; goes something like this:
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
205 ; (let ((real-font-height
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
206 ; (font-height (face-font 'default) frame))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
207 ; (minibuffer-height
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
208 ; (if (and (minibuffer-window frame)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
209 ; (not (frame-minibuffer-only-p frame)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
210 ; (window-pixel-height (minibuffer-window frame))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
211 ; 0)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
212 ; ...)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
213
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
214 (make-window-configuration
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
215 :frame frame
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
216 :frame-pixel-width (frame-pixel-width frame)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
217 :frame-pixel-height (frame-pixel-height frame)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
218 :current-buffer (current-buffer)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
219 :min-width window-min-width :min-height window-min-height
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
220 :minibuffer-pixel-height (window-pixel-height (minibuffer-window frame))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
221 ;; this tries to do what the old code did:
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
222 ; :minibuffer-height (if (zerop (% minibuffer-height real-font-height))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
223 ; (- (/ minibuffer-height real-font-height)) ; lines
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
224 ; minibuffer-height) ; pixels
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
225 :saved-root-window (root-window->saved-window (frame-root-window frame)))))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
226
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
227 (defun root-window->saved-window (window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
228 "Converts a root window into a tree of saved-window structures."
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
229 (let ((buffer (window-buffer window))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
230 (edges (window-pixel-edges window)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
231 (let ((left (nth 0 edges))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
232 (top (nth 1 edges))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
233 (right (nth 2 edges))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
234 (bottom (nth 3 edges)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
235 (let ((saved-window
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
236 (make-saved-window
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
237 :currentp (eq window (selected-window (window-frame window)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
238 :minibufferp (eq window (minibuffer-window (window-frame window)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
239 :minibuffer-scrollp (eq window minibuffer-scroll-window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
240 :buffer buffer
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
241 :pixel-left left :pixel-top top :pixel-right right :pixel-bottom bottom
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
242 :hscroll (window-hscroll window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
243 :modeline-hscroll (modeline-hscroll window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
244 :dedicatedp (window-dedicated-p window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
245 :first-hchild (if (window-first-hchild window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
246 (root-window->saved-window (window-first-hchild window))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
247 nil)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
248 :first-vchild (if (window-first-vchild window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
249 (root-window->saved-window (window-first-vchild window))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
250 nil)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
251 :next-child (if (window-next-child window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
252 (root-window->saved-window (window-next-child window))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
253 nil))))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
254 (if buffer
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
255 (progn
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
256 (let ((marker (make-marker)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
257 (set-marker marker (window-start window) buffer)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
258 (setf (saved-window-start-marker saved-window) marker))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
259 (let ((marker (make-marker)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
260 (if (eq window (selected-window))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
261 (set-marker marker (point buffer) buffer)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
262 (set-marker marker (window-point window) buffer))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
263 (setf (saved-window-point-marker saved-window) marker))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
264 (setf (saved-window-mark-marker saved-window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
265 (copy-marker (mark-marker t buffer)))))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
266 saved-window))))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
267
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
268 (defun set-window-configuration (configuration)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
269 "Set the configuration of windows and buffers as specified by CONFIGURATION.
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
270 CONFIGURATION must be a value previously returned
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
271 by `current-window-configuration'."
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
272 (let ((frame (window-configuration-frame configuration)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
273 (if (and (frame-live-p frame)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
274 (not (window-configuration-equal configuration
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
275 (current-window-configuration))))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
276 (really-set-window-configuration frame configuration))))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
277
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
278 (defun really-set-window-configuration (frame configuration)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
279 "Set the window configuration CONFIGURATION on live frame FRAME."
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
280 ;; avoid potential temporary problems
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
281 (setq window-min-width 0)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
282 (setq window-min-height 0)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
283 (setq minibuffer-scroll-window nil)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
284
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
285 (frame-reduce-to-one-window frame)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
286 (set-window-configuration-frame-size configuration)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
287
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
288 ;; these may have changed because of the delete
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
289 (let ((root-window (frame-root-window frame)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
290 (enlarge-window-pixels
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
291 (- (window-configuration-minibuffer-pixel-height configuration)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
292 (window-pixel-height (minibuffer-window frame)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
293 nil
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
294 (minibuffer-window frame))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
295
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
296 ;; avoid that `set-window-point' will set the buffer's point for
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
297 ;; the selected window
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
298 (select-window (minibuffer-window frame))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
299
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
300 (let ((window-configuration-current-window nil))
1261
465bd3c7d932 [xemacs-hg @ 2003-02-06 06:35:47 by ben]
ben
parents: 1230
diff changeset
301 (declare (special window-configuration-current-window))
1149
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
302 (restore-saved-window configuration
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
303 root-window
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
304 (window-configuration-saved-root-window configuration)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
305 'vertical)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
306 (if window-configuration-current-window
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
307 (select-window window-configuration-current-window))))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
308
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
309 (setq window-min-width (window-configuration-min-width configuration))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
310 (setq window-min-height (window-configuration-min-height configuration))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
311
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
312 (set-buffer (window-configuration-current-buffer configuration)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
313
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
314 (defun set-window-configuration-frame-size (configuration)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
315 "Restore the frame size of a window configuration."
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
316 (set-frame-pixel-size
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
317 (window-configuration-frame configuration)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
318 (window-configuration-frame-pixel-width configuration)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
319 (window-configuration-frame-pixel-height configuration)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
320
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
321 (defun frame-reduce-to-one-window (frame)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
322 "Delete all windows except the minibuffer and one other in FRAME."
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
323 (let* ((root-window (frame-root-window frame))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
324 (combination-start (or (window-first-hchild root-window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
325 (window-first-vchild root-window))))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
326 (if combination-start
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
327 (window-reduce-to-one combination-start))))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
328
1230
78781398fc4c [xemacs-hg @ 2003-01-23 10:09:41 by michaels]
michaels
parents: 1208
diff changeset
329 ;; Note that simply using `delete-other-windows' causes obscure
78781398fc4c [xemacs-hg @ 2003-01-23 10:09:41 by michaels]
michaels
parents: 1208
diff changeset
330 ;; breakage. --Mike
78781398fc4c [xemacs-hg @ 2003-01-23 10:09:41 by michaels]
michaels
parents: 1208
diff changeset
331
1149
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
332 (defun window-reduce-to-one (window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
333 "Make sure only one subwindow of WINDOW is left."
1230
78781398fc4c [xemacs-hg @ 2003-01-23 10:09:41 by michaels]
michaels
parents: 1208
diff changeset
334 (let ((window (window-next-child window)))
78781398fc4c [xemacs-hg @ 2003-01-23 10:09:41 by michaels]
michaels
parents: 1208
diff changeset
335 (while window
78781398fc4c [xemacs-hg @ 2003-01-23 10:09:41 by michaels]
michaels
parents: 1208
diff changeset
336 (if (window-live-p window)
78781398fc4c [xemacs-hg @ 2003-01-23 10:09:41 by michaels]
michaels
parents: 1208
diff changeset
337 (let ((next (window-next-child window)))
78781398fc4c [xemacs-hg @ 2003-01-23 10:09:41 by michaels]
michaels
parents: 1208
diff changeset
338 (delete-window window)
78781398fc4c [xemacs-hg @ 2003-01-23 10:09:41 by michaels]
michaels
parents: 1208
diff changeset
339 (setq window next)))))
78781398fc4c [xemacs-hg @ 2003-01-23 10:09:41 by michaels]
michaels
parents: 1208
diff changeset
340 (cond
78781398fc4c [xemacs-hg @ 2003-01-23 10:09:41 by michaels]
michaels
parents: 1208
diff changeset
341 ((window-first-hchild window)
78781398fc4c [xemacs-hg @ 2003-01-23 10:09:41 by michaels]
michaels
parents: 1208
diff changeset
342 (window-reduce-to-one (window-first-hchild window)))
78781398fc4c [xemacs-hg @ 2003-01-23 10:09:41 by michaels]
michaels
parents: 1208
diff changeset
343 ((window-first-vchild window)
78781398fc4c [xemacs-hg @ 2003-01-23 10:09:41 by michaels]
michaels
parents: 1208
diff changeset
344 (window-reduce-to-one (window-first-vchild window)))))
1149
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
345
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
346 (defun restore-saved-window (configuration window saved-window direction)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
347 "Within CONFIGURATION, restore WINDOW to the state of SAVED-WINDOW."
1576
bd921b813d33 [xemacs-hg @ 2003-07-17 14:41:23 by james]
james
parents: 1387
diff changeset
348 (and (saved-window-next-child saved-window)
bd921b813d33 [xemacs-hg @ 2003-07-17 14:41:23 by james]
james
parents: 1387
diff changeset
349 (not (saved-window-minibufferp (saved-window-next-child saved-window)))
bd921b813d33 [xemacs-hg @ 2003-07-17 14:41:23 by james]
james
parents: 1387
diff changeset
350 (progn
bd921b813d33 [xemacs-hg @ 2003-07-17 14:41:23 by james]
james
parents: 1387
diff changeset
351 (cond ((eq direction 'vertical)
bd921b813d33 [xemacs-hg @ 2003-07-17 14:41:23 by james]
james
parents: 1387
diff changeset
352 (split-window window nil nil))
bd921b813d33 [xemacs-hg @ 2003-07-17 14:41:23 by james]
james
parents: 1387
diff changeset
353 ((eq direction 'horizontal)
bd921b813d33 [xemacs-hg @ 2003-07-17 14:41:23 by james]
james
parents: 1387
diff changeset
354 (split-window window nil t)))
bd921b813d33 [xemacs-hg @ 2003-07-17 14:41:23 by james]
james
parents: 1387
diff changeset
355 (restore-saved-window configuration
bd921b813d33 [xemacs-hg @ 2003-07-17 14:41:23 by james]
james
parents: 1387
diff changeset
356 (window-next-child window)
bd921b813d33 [xemacs-hg @ 2003-07-17 14:41:23 by james]
james
parents: 1387
diff changeset
357 (saved-window-next-child saved-window)
bd921b813d33 [xemacs-hg @ 2003-07-17 14:41:23 by james]
james
parents: 1387
diff changeset
358 direction)))
1149
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
359
1576
bd921b813d33 [xemacs-hg @ 2003-07-17 14:41:23 by james]
james
parents: 1387
diff changeset
360 (if (saved-window-first-hchild saved-window)
bd921b813d33 [xemacs-hg @ 2003-07-17 14:41:23 by james]
james
parents: 1387
diff changeset
361 (restore-saved-window configuration
bd921b813d33 [xemacs-hg @ 2003-07-17 14:41:23 by james]
james
parents: 1387
diff changeset
362 window
bd921b813d33 [xemacs-hg @ 2003-07-17 14:41:23 by james]
james
parents: 1387
diff changeset
363 (saved-window-first-hchild saved-window)
bd921b813d33 [xemacs-hg @ 2003-07-17 14:41:23 by james]
james
parents: 1387
diff changeset
364 'horizontal))
bd921b813d33 [xemacs-hg @ 2003-07-17 14:41:23 by james]
james
parents: 1387
diff changeset
365 (if (saved-window-first-vchild saved-window)
bd921b813d33 [xemacs-hg @ 2003-07-17 14:41:23 by james]
james
parents: 1387
diff changeset
366 (restore-saved-window configuration
bd921b813d33 [xemacs-hg @ 2003-07-17 14:41:23 by james]
james
parents: 1387
diff changeset
367 window
bd921b813d33 [xemacs-hg @ 2003-07-17 14:41:23 by james]
james
parents: 1387
diff changeset
368 (saved-window-first-vchild saved-window)
bd921b813d33 [xemacs-hg @ 2003-07-17 14:41:23 by james]
james
parents: 1387
diff changeset
369 'vertical))
1149
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
370
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
371 (if (not (saved-window-minibufferp saved-window))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
372 (restore-saved-window-parameters configuration window saved-window)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
373
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
374 (defun restore-saved-window-parameters (configuration window saved-window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
375 "Restore the window parameters stored in SAVED-WINDOW on WINDOW."
1261
465bd3c7d932 [xemacs-hg @ 2003-02-06 06:35:47 by ben]
ben
parents: 1230
diff changeset
376 (declare (special window-configuration-current-window))
1149
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
377 (let ((buffer (saved-window-buffer saved-window)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
378 (if (and buffer (buffer-live-p buffer))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
379 (progn
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
380 (set-window-buffer window
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
381 (saved-window-buffer saved-window))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
382 (set-window-start window
1161
8e95979f01c6 [xemacs-hg @ 2002-12-16 02:32:47 by ben]
ben
parents: 1149
diff changeset
383 (marker-position (saved-window-start-marker saved-window))
8e95979f01c6 [xemacs-hg @ 2002-12-16 02:32:47 by ben]
ben
parents: 1149
diff changeset
384 t)
1149
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
385 (set-window-point window
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
386 (marker-position (saved-window-point-marker saved-window)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
387 (set-marker (mark-marker t buffer)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
388 (marker-position (saved-window-mark-marker saved-window))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
389 buffer)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
390 (if (not (eq buffer (window-configuration-current-buffer configuration)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
391 (goto-char (window-point window) buffer)))))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
392
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
393 (if (and (not (saved-window-first-hchild saved-window))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
394 (not (saved-window-first-vchild saved-window)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
395 ;; only set size for non-container windows
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
396 (progn
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
397 ;; If this is the root window, it may be the only window.
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
398 ;; Because of mismatches between actual and reported frame
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
399 ;; size, it may not let us actually set the size of the root
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
400 ;; window to what we want. --Mike
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
401 (if (not (eq window (frame-root-window (window-frame window))))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
402 (progn
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
403 (enlarge-window-pixels (- (saved-window-pixel-width saved-window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
404 (window-pixel-width window))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
405 t
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
406 window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
407 (enlarge-window-pixels (- (saved-window-pixel-height saved-window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
408 (window-pixel-height window))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
409 nil
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
410 window)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
411 (set-window-hscroll window (saved-window-hscroll saved-window))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
412 (set-modeline-hscroll window
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
413 (saved-window-modeline-hscroll saved-window))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
414 (set-window-dedicated-p window (saved-window-dedicatedp saved-window))))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
415
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
416 (if (saved-window-currentp saved-window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
417 (setq window-configuration-current-window window))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
418 (if (saved-window-minibuffer-scrollp saved-window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
419 (setq minibuffer-scroll-window window)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
420
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
421 (defun saved-window-pixel-width (saved-window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
422 "Compute the pixel width of SAVED-WINDOW."
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
423 (- (saved-window-pixel-right saved-window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
424 (saved-window-pixel-left saved-window)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
425
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
426 (defun saved-window-pixel-height (saved-window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
427 "Compute the pixel height of SAVED-WINDOW."
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
428 (- (saved-window-pixel-bottom saved-window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
429 (saved-window-pixel-top saved-window)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 ;; The window-config stack is stored as a list in frame property
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 ;; 'window-config-stack, with the most recent element at the front.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 ;; When you pop off an element, the popped off element gets put at the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 ;; front of frame property 'window-config-unpop-stack, so you can
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 ;; retrieve it using unpop-window-configuration.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 (defcustom window-config-stack-max 16
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 "*Maximum size of window configuration stack.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 Start discarding off end if it gets this big."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 :type 'integer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 :group 'windows)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 (defun window-config-stack (&optional frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 (or frame (setq frame (selected-frame)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 (let ((stack (frame-property frame 'window-config-stack)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 (if stack
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 (set-undoable-stack-max stack window-config-stack-max)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 (setq stack (make-undoable-stack window-config-stack-max))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 (set-frame-property frame 'window-config-stack stack)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 stack))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 (defun push-window-configuration (&optional config)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 "Push the current window configuration onto the window-config stack.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 If CONFIG is specified, push it instead of the current window configuration.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 Each frame has its own window-config stack."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 (let ((wc (or config (current-window-configuration)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 (stack (window-config-stack)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 (if (or (= 0 (undoable-stack-a-length stack))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 (not (equal (undoable-stack-a-top stack) wc)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 (undoable-stack-push stack wc))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 (defun pop-window-configuration ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 "Pop the top window configuration off the window-config stack and set it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 Before setting the new window configuration, the current window configuration
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 is pushed onto the \"unpop\" stack.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 `unpop-window-configuration' undoes what this function does.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 Each frame has its own window-config and \"unpop\" stack."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 (let ((stack (window-config-stack))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 (wc (current-window-configuration))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 popped)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 (condition-case nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 (setq popped (undoable-stack-pop stack))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 (while (equal popped wc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 (setq popped (undoable-stack-pop stack)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 (undoable-stack-push stack wc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 (undoable-stack-undo stack)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 (set-window-configuration popped)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 popped)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 (trunc-stack-bottom
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 (error "Bottom of window config stack")))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 (defun unpop-window-configuration ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 "Undo the effect of the most recent `pop-window-configuration'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 This does exactly the inverse of what `pop-window-configuration' does:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 i.e. it pops a window configuration off of the \"unpop\" stack and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 pushes the current window configuration onto the window-config stack.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 Each frame has its own window-config and \"unpop\" stack."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 (let ((stack (window-config-stack))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 (wc (current-window-configuration))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 popped)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 (condition-case nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 (setq popped
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 (undoable-stack-redo stack)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 (undoable-stack-pop stack)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 (while (equal popped wc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 (setq popped
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 (undoable-stack-redo stack)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 (undoable-stack-pop stack))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 (undoable-stack-push stack wc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 (set-window-configuration popped)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 popped)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 (trunc-stack-bottom
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 (error "Top of window config stack")))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 ;;;;;;;;;;;;; display-buffer, moved here from C. Hallelujah.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
516 (make-variable-buffer-local '__buffer-dedicated-frame)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
517
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
518 (defun buffer-dedicated-frame (&optional buffer)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
519 "Return the frame dedicated to this BUFFER, or nil if there is none.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
520 No argument or nil as argument means use current buffer as BUFFER."
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
521 (let ((buffer (decode-buffer buffer)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
522 (let ((frame (symbol-value-in-buffer '__buffer-dedicated-frame buffer)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
523 ;; XEmacs addition: if the frame is dead, silently make it go away.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
524 (when (and (framep frame) (not (frame-live-p frame)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
525 (with-current-buffer buffer
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
526 (setq __buffer-dedicated-frame nil))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
527 (setq frame nil))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
528 frame)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
529
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
530 (defun set-buffer-dedicated-frame (buffer frame)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
531 "For this BUFFER, set the FRAME dedicated to it.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
532 FRAME must be a frame or nil."
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
533 (let ((buffer (decode-buffer buffer)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
534 (and frame
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
535 (check-argument-type #'frame-live-p frame))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
536 (with-current-buffer buffer
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
537 (setq __buffer-dedicated-frame frame))))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
538
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 (defvar display-buffer-function nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 "If non-nil, function to call to handle `display-buffer'.
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 444
diff changeset
541 It will receive four args: the same as those to `display-buffer'.")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 (defvar pre-display-buffer-function nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 "If non-nil, function that will be called from `display-buffer'
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 444
diff changeset
545 as the first action. It will receive four args: the same as those
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 to `display-buffer'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 This function may be used to select an appropriate frame for the buffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 for example. See also the variable `display-buffer-function', which may
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 be used to completely replace the `display-buffer' function.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 If the return value of this function is non-nil, it should be a frame,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 and that frame will be used to display the buffer.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 (defcustom pop-up-frames nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 "*Non-nil means `display-buffer' should make a separate frame."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 :type 'boolean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 :group 'frames)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 (defvar pop-up-frame-function nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 "Function to call to handle automatic new frame creation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 It is called with no arguments and should return a newly created frame.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 A typical value might be `(lambda () (new-frame pop-up-frame-alist))'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 where `pop-up-frame-alist' would hold the default frame parameters.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 (defcustom special-display-buffer-names nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 "*List of buffer names that should have their own special frames.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 Displaying a buffer whose name is in this list makes a special frame for it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 using `special-display-function'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 An element of the list can be a cons cell instead of just a string.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 Then the car should be a buffer name, and the cdr specifies frame
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 parameters for creating the frame for that buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 More precisely, the cdr is passed as the second argument to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 the function found in `special-display-function', when making that frame.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 See also `special-display-regexps'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 :type '(repeat (choice :value ""
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 (string :tag "Name")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 (cons :menu-tag "Properties"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 :value ("" . nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 (string :tag "Name")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 (repeat :tag "Properties"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 (group :inline t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 (symbol :tag "Property")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 (sexp :tag "Value"))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 :group 'frames)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 (defcustom special-display-regexps nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 "*List of regexps saying which buffers should have their own special frames.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 If a buffer name matches one of these regexps, it gets its own frame.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 Displaying a buffer whose name is in this list makes a special frame for it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 using `special-display-function'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 An element of the list can be a cons cell instead of just a string.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 Then the car should be the regexp, and the cdr specifies frame
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 parameters for creating the frame for buffers that match.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 More precisely, the cdr is passed as the second argument to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 the function found in `special-display-function', when making that frame.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 See also `special-display-buffer-names'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 :type '(repeat (choice :value ""
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 regexp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 (cons :menu-tag "Properties"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 :value ("" . nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 regexp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 (repeat :tag "Properties"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 (group :inline t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 (symbol :tag "Property")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 (sexp :tag "Value"))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 :group 'frames)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 (defvar special-display-function nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 "Function to call to make a new frame for a special buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 It is called with two arguments, the buffer and optional buffer specific
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 data, and should return a window displaying that buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 The default value makes a separate frame for the buffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 using `special-display-frame-alist' to specify the frame parameters.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 A buffer is special if its is listed in `special-display-buffer-names'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 or matches a regexp in `special-display-regexps'.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 (defcustom same-window-buffer-names nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 "*List of buffer names that should appear in the selected window.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 Displaying one of these buffers using `display-buffer' or `pop-to-buffer'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 switches to it in the selected window, rather than making it appear
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 in some other window.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 An element of the list can be a cons cell instead of just a string.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 Then the car must be a string, which specifies the buffer name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 This is for compatibility with `special-display-buffer-names';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629 the cdr of the cons cell is ignored.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 See also `same-window-regexps'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 :type '(repeat (string :tag "Name"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 :group 'windows)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 (defcustom same-window-regexps nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 "*List of regexps saying which buffers should appear in the selected window.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 If a buffer name matches one of these regexps, then displaying it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 using `display-buffer' or `pop-to-buffer' switches to it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 in the selected window, rather than making it appear in some other window.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 An element of the list can be a cons cell instead of just a string.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 Then the car must be a string, which specifies the buffer name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 This is for compatibility with `special-display-buffer-names';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 the cdr of the cons cell is ignored.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 See also `same-window-buffer-names'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 :type '(repeat regexp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 :group 'windows)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 (defcustom pop-up-windows t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 "*Non-nil means display-buffer should make new windows."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 :type 'boolean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 :group 'windows)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 (defcustom split-height-threshold 500
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 "*display-buffer would prefer to split the largest window if this large.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 If there is only one window, it is split regardless of this value."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 :type 'integer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 :group 'windows)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 (defcustom split-width-threshold 500
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 "*display-buffer would prefer to split the largest window if this large.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 If there is only one window, it is split regardless of this value."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 :type 'integer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 :group 'windows)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 ;; Deiconify the frame containing the window WINDOW, then return WINDOW.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669 (defun display-buffer-1 (window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670 (if (frame-iconified-p (window-frame window))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 (make-frame-visible (window-frame window)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 ;; Can you believe that all of this crap was formerly in C?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 ;; Praise Jesus that it's not there any more.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 444
diff changeset
677 (defun display-buffer (buffer &optional not-this-window-p override-frame
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 444
diff changeset
678 shrink-to-fit)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 "Make BUFFER appear in some window on the current frame, but don't select it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680 BUFFER can be a buffer or a buffer name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681 If BUFFER is shown already in some window in the current frame,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 just uses that one, unless the window is the selected window and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683 NOT-THIS-WINDOW-P is non-nil (interactively, with prefix arg).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685 If BUFFER has a dedicated frame, display on that frame instead of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686 the current frame, unless OVERRIDE-FRAME is non-nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 If OVERRIDE-FRAME is non-nil, display on that frame instead of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 the current frame (or the dedicated frame).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 444
diff changeset
691 If SHRINK-TO-FIT is non-nil and splitting the window is appropriate, give
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 444
diff changeset
692 the new buffer less than half the space if it is small enough to fit.
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 444
diff changeset
693
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694 If `pop-up-windows' is non-nil, always use the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695 current frame and create a new window regardless of whether the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696 buffer has a dedicated frame, and regardless of whether
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697 OVERRIDE-FRAME was specified.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 If `pop-up-frames' is non-nil, make a new frame if no window shows BUFFER.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701 Returns the window displaying BUFFER."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702 (interactive "BDisplay buffer:\nP")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704 (let ((wconfig (current-window-configuration))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705 (result
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 ;; We just simulate a `return' in C. This function is way ugly
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 ;; and does `returns' all over the place and there's no sense
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 ;; in trying to rewrite it to be more Lispy.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709 (catch 'done
1669
c5f86842283a [xemacs-hg @ 2003-09-07 19:46:30 by adrian]
adrian
parents: 1576
diff changeset
710 (let (window old-frame target-frame explicit-frame shrink-it)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 (setq old-frame (or (last-nonminibuf-frame) (selected-frame)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 (setq buffer (get-buffer buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 (check-argument-type 'bufferp buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715 (setq explicit-frame
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 (if pre-display-buffer-function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 (funcall pre-display-buffer-function buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 not-this-window-p
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 444
diff changeset
719 override-frame
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 444
diff changeset
720 shrink-to-fit)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722 ;; Give the user the ability to completely reimplement
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 ;; this function via the `display-buffer-function'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724 (if display-buffer-function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 (throw 'done
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726 (funcall display-buffer-function buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 not-this-window-p
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 444
diff changeset
728 override-frame
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 444
diff changeset
729 shrink-to-fit)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731 ;; If the buffer has a dedicated frame, that takes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 ;; precedence over the current frame, and over what the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 ;; pre-display-buffer-function did.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734 (let ((dedi (buffer-dedicated-frame buffer)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735 (if (frame-live-p dedi) (setq explicit-frame dedi)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 ;; if override-frame is supplied, that takes precedence over
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738 ;; everything. This is gonna look bad if the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 ;; pre-display-buffer-function raised some other frame
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740 ;; already.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741 (if override-frame
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743 (check-argument-type 'frame-live-p override-frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744 (setq explicit-frame override-frame)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746 (setq target-frame
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747 (or explicit-frame
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
748 (last-nonminibuf-frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749 (selected-frame)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751 ;; If we have switched frames, then set not-this-window-p
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 ;; to false. Switching frames means that selected-window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753 ;; is no longer the same as it was on entry -- it's the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754 ;; selected-window of target_frame instead of old_frame,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755 ;; so it's a fine candidate for display.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756 (if (not (eq old-frame target-frame))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757 (setq not-this-window-p nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759 ;; if it's in the selected window, and that's ok, then we're done.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760 (if (and (not not-this-window-p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761 (eq buffer (window-buffer (selected-window))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762 (throw 'done (display-buffer-1 (selected-window))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764 ;; See if the user has specified this buffer should appear
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
765 ;; in the selected window.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767 (if not-this-window-p
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768 nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770 (if (or (member (buffer-name buffer) same-window-buffer-names)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771 (assoc (buffer-name buffer) same-window-buffer-names))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773 (switch-to-buffer buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774 (throw 'done (display-buffer-1 (selected-window)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776 (let ((tem same-window-regexps))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777 (while tem
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
778 (let ((car (car tem)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779 (if (or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780 (and (stringp car)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
781 (string-match car (buffer-name buffer)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
782 (and (consp car) (stringp (car car))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
783 (string-match (car car) (buffer-name buffer))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
784 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
785 (switch-to-buffer buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786 (throw 'done (display-buffer-1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
787 (selected-window))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
788 (setq tem (cdr tem)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790 ;; If pop-up-frames, look for a window showing BUFFER on
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791 ;; any visible or iconified frame. Otherwise search only
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
792 ;; the current frame.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
793 (if (and (not explicit-frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
794 (or pop-up-frames (not (last-nonminibuf-frame))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795 (setq target-frame 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
797 ;; Otherwise, find some window that it's already in, and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798 ;; return that, unless that window is the selected window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799 ;; and that isn't ok. What a contorted mess!
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800 (setq window (or (if (not explicit-frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801 ;; search the selected frame
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802 ;; first if the user didn't
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
803 ;; specify an explicit frame.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
804 (get-buffer-window buffer nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
805 (get-buffer-window buffer target-frame)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
806 (if (and window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
807 (or (not not-this-window-p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
808 (not (eq window (selected-window)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
809 (throw 'done (display-buffer-1 window)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
810
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
811 ;; Certain buffer names get special handling.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
812 (if special-display-function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
813 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
814 (if (member (buffer-name buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815 special-display-buffer-names)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
816 (throw 'done (funcall special-display-function buffer)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818 (let ((tem (assoc (buffer-name buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
819 special-display-buffer-names)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
820 (if tem
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
821 (throw 'done (funcall special-display-function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
822 buffer (cdr tem)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
823
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
824 (let ((tem special-display-regexps))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
825 (while tem
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
826 (let ((car (car tem)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
827 (if (and (stringp car)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
828 (string-match car (buffer-name buffer)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
829 (throw 'done
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830 (funcall special-display-function buffer)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
831 (if (and (consp car)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
832 (stringp (car car))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
833 (string-match (car car)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
834 (buffer-name buffer)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
835 (throw 'done (funcall
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
836 special-display-function buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
837 (cdr car)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
838 (setq tem (cdr tem))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
840 ;; If there are no frames open that have more than a minibuffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
841 ;; we need to create a new frame.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
842 (if (or pop-up-frames
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
843 (null (last-nonminibuf-frame)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
844 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
845 (setq window (frame-selected-window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
846 (funcall pop-up-frame-function)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847 (set-window-buffer window buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848 (throw 'done (display-buffer-1 window))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
849
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
850 ;; Otherwise, make it be in some window, splitting if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
851 ;; appropriate/possible. Do not split a window if we are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
852 ;; displaying the buffer in a different frame than that which
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
853 ;; was current when we were called. (It is already in a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854 ;; different window by virtue of being in another frame.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
855 (if (or (and pop-up-windows (eq target-frame old-frame))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
856 (eq 'only (frame-property (selected-frame) 'minibuffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
857 ;; If the current frame is a special display frame,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
858 ;; don't try to reuse its windows.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
859 (window-dedicated-p (frame-root-window (selected-frame))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
860 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
861 (if (eq 'only (frame-property (selected-frame) 'minibuffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862 (setq target-frame (last-nonminibuf-frame)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
863
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
864 ;; Don't try to create a window if would get an error with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865 ;; height.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
866 (if (< split-height-threshold (* 2 window-min-height))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
867 (setq split-height-threshold (* 2 window-min-height)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
868
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
869 ;; Same with width.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
870 (if (< split-width-threshold (* 2 window-min-width))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871 (setq split-width-threshold (* 2 window-min-width)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
872
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
873 ;; If the frame we would try to split cannot be split,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
874 ;; try other frames.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875 (if (frame-property (if (null target-frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
876 (selected-frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
877 (last-nonminibuf-frame))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
878 'unsplittable)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
879 (setq window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
880 ;; Try visible frames first.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
881 (or (get-largest-window 'visible)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
882 ;; If that didn't work, try iconified frames.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883 (get-largest-window 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
884 (get-largest-window t)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
885 (setq window (get-largest-window target-frame)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887 ;; If we got a tall enough full-width window that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
888 ;; can be split, split it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
889 (if (and window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
890 (not (frame-property (window-frame window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
891 'unsplittable))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
892 (>= (window-height window) split-height-threshold)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
893 (or (>= (window-width window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
894 split-width-threshold)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
895 (and (window-leftmost-p window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
896 (window-rightmost-p window))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
897 (setq window (split-window window))
1669
c5f86842283a [xemacs-hg @ 2003-09-07 19:46:30 by adrian]
adrian
parents: 1576
diff changeset
898 (let (upper other)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
899 (setq window (get-lru-window target-frame))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
900 ;; If the LRU window is selected, and big enough,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
901 ;; and can be split, split it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
902 (if (and window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
903 (not (frame-property (window-frame window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
904 'unsplittable))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905 (or (eq window (selected-window))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
906 (not (window-parent window)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907 (>= (window-height window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
908 (* 2 window-min-height)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909 (setq window (split-window window)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
910 ;; If get-lru-window returned nil, try other approaches.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
911 ;; Try visible frames first.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
912 (or window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913 (setq window (or (get-largest-window 'visible)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
914 ;; If that didn't work, try
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
915 ;; iconified frames.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916 (get-largest-window 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
917 ;; Try invisible frames.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
918 (get-largest-window t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919 ;; As a last resort, make
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
920 ;; a new frame.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921 (frame-selected-window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
922 (funcall
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
923 pop-up-frame-function)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
924 ;; If window appears above or below another,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
925 ;; even out their heights.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
926 (if (window-previous-child window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
927 (setq other (window-previous-child window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
928 upper other))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
929 (if (window-next-child window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
930 (setq other (window-next-child window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
931 upper window))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
932 ;; Check that OTHER and WINDOW are vertically arrayed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
933 (if (and other
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
934 (not (= (nth 1 (window-pixel-edges other))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
935 (nth 1 (window-pixel-edges window))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936 (> (window-pixel-height other)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937 (window-pixel-height window)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
938 (enlarge-window (- (/ (+ (window-height other)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
939 (window-height window))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
940 2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
941 (window-height upper))
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 444
diff changeset
942 nil upper))
1669
c5f86842283a [xemacs-hg @ 2003-09-07 19:46:30 by adrian]
adrian
parents: 1576
diff changeset
943 ;; Klaus Berndl <klaus.berndl@sdm.de>: Only in
c5f86842283a [xemacs-hg @ 2003-09-07 19:46:30 by adrian]
adrian
parents: 1576
diff changeset
944 ;; this situation we shrink-to-fit but we can do
c5f86842283a [xemacs-hg @ 2003-09-07 19:46:30 by adrian]
adrian
parents: 1576
diff changeset
945 ;; this first after we have displayed buffer in
c5f86842283a [xemacs-hg @ 2003-09-07 19:46:30 by adrian]
adrian
parents: 1576
diff changeset
946 ;; window (s.b. (set-window-buffer window buffer))
c5f86842283a [xemacs-hg @ 2003-09-07 19:46:30 by adrian]
adrian
parents: 1576
diff changeset
947 (setq shrink-it shrink-to-fit))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
948
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
949 (setq window (get-lru-window target-frame)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
950
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
951 ;; Bring the window's previous buffer to the top of the MRU chain.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
952 (if (window-buffer window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
953 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
954 (save-selected-window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
955 (select-window window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
956 (record-buffer (window-buffer window)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
957
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
958 (set-window-buffer window buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
959
1669
c5f86842283a [xemacs-hg @ 2003-09-07 19:46:30 by adrian]
adrian
parents: 1576
diff changeset
960 ;; Now window's previous buffer has been brought to the top
c5f86842283a [xemacs-hg @ 2003-09-07 19:46:30 by adrian]
adrian
parents: 1576
diff changeset
961 ;; of the MRU chain and window displays buffer - now we can
c5f86842283a [xemacs-hg @ 2003-09-07 19:46:30 by adrian]
adrian
parents: 1576
diff changeset
962 ;; shrink-to-fit if necessary
c5f86842283a [xemacs-hg @ 2003-09-07 19:46:30 by adrian]
adrian
parents: 1576
diff changeset
963 (if shrink-it
c5f86842283a [xemacs-hg @ 2003-09-07 19:46:30 by adrian]
adrian
parents: 1576
diff changeset
964 (shrink-window-if-larger-than-buffer window))
c5f86842283a [xemacs-hg @ 2003-09-07 19:46:30 by adrian]
adrian
parents: 1576
diff changeset
965
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
966 (display-buffer-1 window)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
967 (or (equal wconfig (current-window-configuration))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
968 (push-window-configuration wconfig))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
969 result))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
970
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
971 ;;; window-xemacs.el ends here