annotate lisp/prim/window-xemacs.el @ 169:15872534500d r20-3b11

Import from CVS: tag r20-3b11
author cvs
date Mon, 13 Aug 2007 09:46:53 +0200
parents 0132846995bd
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
1 ;;; window-xemacs.el --- XEmacs window commands aside from those written in C.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
2
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
3 ;; Copyright (C) 1985, 1989, 1993-94, 1997 Free Software Foundation, Inc.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
4 ;; Copyright (C) 1995, 1996 Ben Wing.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
5
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
6 ;; Maintainer: XEmacs Development Team
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
7 ;; Keywords: extensions
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
8
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
9 ;; This file is part of XEmacs.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
10
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
11 ;; XEmacs is free software; you can redistribute it and/or modify it
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
12 ;; under the terms of the GNU General Public License as published by
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
14 ;; any later version.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
15
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful, but
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
19 ;; General Public License for more details.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
20
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
22 ;; along with XEmacs; see the file COPYING. If not, write to the
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
23 ;; Free Software Foundation, 59 Temple Place - Suite 330,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
24 ;; Boston, MA 02111-1307, USA.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
25
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
26 ;;; Synched up with: Not synched.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
27
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
28 ;;; Commentary:
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
29
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
30 ;; slb - 5/29/97
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
31 ;; Split apart from window.el in order to keep that file better in synch
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
32 ;; with Emacs.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
33
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
34 ;;; Code:
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
35
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
36 (defun backward-other-window (arg &optional all-frames device)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
37 "Select the ARG'th different window on this frame, going backwards.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
38 This is just like calling `other-window' with the arg negated."
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
39 (interactive "p")
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
40 (other-window (- arg) all-frames device))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
41
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
42 (defun windows-of-buffer (&optional buffer)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
43 "Returns a list of windows that have BUFFER in them.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
44 If BUFFER is not specified, the current buffer will be used."
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
45 (or (bufferp buffer)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
46 (if (stringp buffer)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
47 (setq buffer (or (get-buffer buffer)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
48 (get-file-buffer buffer)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
49 (setq buffer (current-buffer))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
50 (let* ((firstwin (next-window nil nil t))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
51 (wind firstwin)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
52 (done nil)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
53 window-list)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
54 (while (not done)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
55 (if (eq (window-buffer wind) buffer)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
56 (setq window-list (append window-list (list wind))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
57 (setq wind (next-window wind nil t))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
58 (setq done (eq wind firstwin)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
59 window-list))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
60
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
61 (defun buffer-in-multiple-windows-p (&optional buffer)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
62 "Return t if BUFFER is in multiple windows.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
63 If BUFFER is not specified, the current buffer will be used."
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
64 (setq buffer (or buffer
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
65 (get-buffer buffer)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
66 (get-file-buffer buffer)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
67 (current-buffer)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
68 (> (length (windows-of-buffer buffer)) 1))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
69
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
70 (defun window-list (&optional frame minibuf window)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
71 "Return a list of windows on FRAME, beginning with WINDOW.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
72 FRAME and WINDOW default to the selected ones.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
73 Optional second arg MINIBUF t means count the minibuffer window
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
74 even if not active. If MINIBUF is neither t nor nil it means
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
75 not to count the minibuffer even if it is active."
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
76 (setq window (or window (selected-window))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
77 frame (or frame (selected-frame)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
78 (if (not (eq (window-frame window) frame))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
79 (error "Window must be on frame."))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
80 (let ((current-frame (selected-frame))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
81 list)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
82 (unwind-protect
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
83 (save-window-excursion
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
84 (select-frame frame)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
85 (walk-windows
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
86 (function (lambda (cur-window)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
87 (if (not (eq window cur-window))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
88 (setq list (cons cur-window list)))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
89 minibuf)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
90 (setq list (cons window list)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
91 (select-frame current-frame))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
92
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
93 ;; We used to have set-window-dedicated-p as an obsolete version
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
94 ;; of set-window-buffer-dedicated, but it really makes more sense
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
95 ;; this way.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
96
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
97 (make-obsolete 'set-window-buffer-dedicated 'set-window-dedicated-p)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
98 (defun set-window-buffer-dedicated (window buffer)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
99 "Make WINDOW display BUFFER and be dedicated to that buffer.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
100 Then Emacs will not automatically change which buffer appears in WINDOW.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
101 If BUFFER is nil, make WINDOW not be dedicated (but don't change which
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
102 buffer appears in it currently)."
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
103 (if (bufferp buffer)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
104 (set-window-buffer window (get-buffer-create buffer)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
105 (set-window-dedicated-p window (not (null buffer))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
106
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
107
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
108 ;; The window-config stack is stored as a list in frame property
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
109 ;; 'window-config-stack, with the most recent element at the front.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
110 ;; When you pop off an element, the popped off element gets put at the
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
111 ;; front of frame property 'window-config-unpop-stack, so you can
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
112 ;; retrieve it using unpop-window-configuration.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
113
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
114 (defcustom window-config-stack-max 16
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
115 "*Maximum size of window configuration stack.
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
116 Start discarding off end if it gets this big."
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
117 :type 'integer
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
118 :group 'windows)
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
119
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
120 (defun window-config-stack (&optional frame)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
121 (or frame (setq frame (selected-frame)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
122 (let ((stack (frame-property frame 'window-config-stack)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
123 (if stack
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
124 (set-undoable-stack-max stack window-config-stack-max)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
125 (progn
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
126 (setq stack (make-undoable-stack window-config-stack-max))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
127 (set-frame-property frame 'window-config-stack stack)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
128 stack))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
129
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
130 (defun push-window-configuration (&optional config)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
131 "Push the current window configuration onto the window-config stack.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
132 If CONFIG is specified, push it instead of the current window configuration.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
133 Each frame has its own window-config stack."
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
134 (interactive)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
135 (let ((wc (or config (current-window-configuration)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
136 (stack (window-config-stack)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
137 (if (or (= 0 (undoable-stack-a-length stack))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
138 (not (equal (undoable-stack-a-top stack) wc)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
139 (progn
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
140 (undoable-stack-push stack wc)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
141 ;; kludge.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
142 (if (featurep 'toolbar)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
143 (set-specifier-dirty-flag default-toolbar))))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
144
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
145 (defun pop-window-configuration ()
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
146 "Pop the top window configuration off the window-config stack and set it.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
147 Before setting the new window configuration, the current window configuration
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
148 is pushed onto the \"unpop\" stack.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
149 `unpop-window-configuration' undoes what this function does.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
150 Each frame has its own window-config and \"unpop\" stack."
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
151 (interactive)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
152 (let ((stack (window-config-stack))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
153 (wc (current-window-configuration))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
154 popped)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
155 (condition-case nil
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
156 (progn
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
157 (setq popped (undoable-stack-pop stack))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
158 (while (equal popped wc)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
159 (setq popped (undoable-stack-pop stack)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
160 (undoable-stack-push stack wc)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
161 (undoable-stack-undo stack)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
162 (set-window-configuration popped)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
163 ;; probably not necessary:
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
164 (if (featurep 'toolbar)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
165 (set-specifier-dirty-flag default-toolbar))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
166 popped)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
167 (trunc-stack-bottom
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
168 (error "Bottom of window config stack")))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
169
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
170 (defun unpop-window-configuration ()
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
171 "Undo the effect of the most recent `pop-window-configuration'.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
172 This does exactly the inverse of what `pop-window-configuration' does:
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
173 i.e. it pops a window configuration off of the \"unpop\" stack and
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
174 pushes the current window configuration onto the window-config stack.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
175 Each frame has its own window-config and \"unpop\" stack."
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
176 (interactive)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
177 (let ((stack (window-config-stack))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
178 (wc (current-window-configuration))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
179 popped)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
180 (condition-case nil
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
181 (progn
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
182 (setq popped
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
183 (progn
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
184 (undoable-stack-redo stack)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
185 (undoable-stack-pop stack)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
186 (while (equal popped wc)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
187 (setq popped
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
188 (progn
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
189 (undoable-stack-redo stack)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
190 (undoable-stack-pop stack))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
191 (undoable-stack-push stack wc)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
192 (set-window-configuration popped)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
193 ;; probably not necessary:
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
194 (if (featurep 'toolbar)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
195 (set-specifier-dirty-flag default-toolbar))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
196 popped)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
197 (trunc-stack-bottom
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
198 (error "Top of window config stack")))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
199
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
200
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
201 ;;;;;;;;;;;;; display-buffer, moved here from C. Hallelujah.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
202
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
203 (defvar display-buffer-function nil
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
204 "If non-nil, function to call to handle `display-buffer'.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
205 It will receive three args: the same as those to `display-buffer'.")
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
206
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
207 (defvar pre-display-buffer-function nil
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
208 "If non-nil, function that will be called from `display-buffer'
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
209 as the first action. It will receive three args: the same as those
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
210 to `display-buffer'.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
211 This function may be used to select an appropriate frame for the buffer,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
212 for example. See also the variable `display-buffer-function', which may
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
213 be used to completely replace the `display-buffer' function.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
214 If the return value of this function is non-nil, it should be a frame,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
215 and that frame will be used to display the buffer.")
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
216
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
217 (defcustom pop-up-frames nil
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
218 "*Non-nil means `display-buffer' should make a separate frame."
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
219 :type 'boolean
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
220 :group 'frames)
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
221
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
222 (defvar pop-up-frame-function nil
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
223 "Function to call to handle automatic new frame creation.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
224 It is called with no arguments and should return a newly created frame.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
225
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
226 A typical value might be `(lambda () (new-frame pop-up-frame-alist))'
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
227 where `pop-up-frame-alist' would hold the default frame parameters.")
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
228
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
229 (defcustom special-display-buffer-names nil
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
230 "*List of buffer names that should have their own special frames.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
231 Displaying a buffer whose name is in this list makes a special frame for it
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
232 using `special-display-function'.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
233
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
234 An element of the list can be a cons cell instead of just a string.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
235 Then the car should be a buffer name, and the cdr specifies frame
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
236 parameters for creating the frame for that buffer.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
237 More precisely, the cdr is passed as the second argument to
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
238 the function found in `special-display-function', when making that frame.
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
239 See also `special-display-regexps'."
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
240 :type '(repeat (choice :value ""
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
241 (string :tag "Name")
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
242 (cons :menu-tag "Properties"
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
243 :value ("" . nil)
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
244 (string :tag "Name")
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
245 (repeat :tag "Properties"
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
246 (group :inline t
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
247 (symbol :tag "Property")
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
248 (sexp :tag "Value"))))))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
249 :group 'frames)
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
250
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
251 (defcustom special-display-regexps nil
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
252 "*List of regexps saying which buffers should have their own special frames.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
253 If a buffer name matches one of these regexps, it gets its own frame.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
254 Displaying a buffer whose name is in this list makes a special frame for it
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
255 using `special-display-function'.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
256
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
257 An element of the list can be a cons cell instead of just a string.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
258 Then the car should be the regexp, and the cdr specifies frame
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
259 parameters for creating the frame for buffers that match.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
260 More precisely, the cdr is passed as the second argument to
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
261 the function found in `special-display-function', when making that frame.
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
262 See also `special-display-buffer-names'."
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
263 :type '(repeat (choice :value ""
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
264 regexp
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
265 (cons :menu-tag "Properties"
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
266 :value ("" . nil)
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
267 regexp
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
268 (repeat :tag "Properties"
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
269 (group :inline t
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
270 (symbol :tag "Property")
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
271 (sexp :tag "Value"))))))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
272 :group 'frames)
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
273
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
274 (defvar special-display-function nil
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
275 "Function to call to make a new frame for a special buffer.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
276 It is called with two arguments, the buffer and optional buffer specific
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
277 data, and should return a window displaying that buffer.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
278 The default value makes a separate frame for the buffer,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
279 using `special-display-frame-alist' to specify the frame parameters.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
280
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
281 A buffer is special if its is listed in `special-display-buffer-names'
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
282 or matches a regexp in `special-display-regexps'.")
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
283
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
284 (defcustom same-window-buffer-names nil
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
285 "*List of buffer names that should appear in the selected window.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
286 Displaying one of these buffers using `display-buffer' or `pop-to-buffer'
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
287 switches to it in the selected window, rather than making it appear
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
288 in some other window.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
289
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
290 An element of the list can be a cons cell instead of just a string.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
291 Then the car must be a string, which specifies the buffer name.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
292 This is for compatibility with `special-display-buffer-names';
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
293 the cdr of the cons cell is ignored.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
294
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
295 See also `same-window-regexps'."
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
296 :type '(repeat (string :tag "Name"))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
297 :group 'windows)
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
298
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
299 (defcustom same-window-regexps nil
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
300 "*List of regexps saying which buffers should appear in the selected window.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
301 If a buffer name matches one of these regexps, then displaying it
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
302 using `display-buffer' or `pop-to-buffer' switches to it
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
303 in the selected window, rather than making it appear in some other window.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
304
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
305 An element of the list can be a cons cell instead of just a string.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
306 Then the car must be a string, which specifies the buffer name.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
307 This is for compatibility with `special-display-buffer-names';
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
308 the cdr of the cons cell is ignored.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
309
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
310 See also `same-window-buffer-names'."
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
311 :type '(repeat regexp)
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
312 :group 'windows)
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
313
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
314 (defcustom pop-up-windows t
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
315 "*Non-nil means display-buffer should make new windows."
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
316 :type 'boolean
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
317 :group 'windows)
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
318
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
319 (defcustom split-height-threshold 500
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
320 "*display-buffer would prefer to split the largest window if this large.
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
321 If there is only one window, it is split regardless of this value."
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
322 :type 'integer
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
323 :group 'windows)
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
324
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
325 (defcustom split-width-threshold 500
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
326 "*display-buffer would prefer to split the largest window if this large.
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
327 If there is only one window, it is split regardless of this value."
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
328 :type 'integer
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
329 :group 'windows)
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
330
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
331 ;; Deiconify the frame containing the window WINDOW, then return WINDOW.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
332
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
333 (defun display-buffer-1 (window)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
334 (if (frame-iconified-p (window-frame window))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
335 (make-frame-visible (window-frame window)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
336 window)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
337
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
338 ;; Can you believe that all of this crap was formerly in C?
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
339 ;; Praise Jesus that it's not there any more.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
340
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
341 (defun display-buffer (buffer &optional not-this-window-p override-frame)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
342 "Make BUFFER appear in some window on the current frame, but don't select it.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
343 BUFFER can be a buffer or a buffer name.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
344 If BUFFER is shown already in some window in the current frame,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
345 just uses that one, unless the window is the selected window and
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
346 NOT-THIS-WINDOW-P is non-nil (interactively, with prefix arg).
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
347
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
348 If BUFFER has a dedicated frame, display on that frame instead of
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
349 the current frame, unless OVERRIDE-FRAME is non-nil.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
350
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
351 If OVERRIDE-FRAME is non-nil, display on that frame instead of
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
352 the current frame (or the dedicated frame).
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
353
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
354 If `pop-up-windows' is non-nil, always use the
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
355 current frame and create a new window regardless of whether the
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
356 buffer has a dedicated frame, and regardless of whether
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
357 OVERRIDE-FRAME was specified.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
358
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
359 If `pop-up-frames' is non-nil, make a new frame if no window shows BUFFER.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
360
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
361 Returns the window displaying BUFFER."
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
362 (interactive "BDisplay buffer:\nP")
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
363
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
364 (let ((wconfig (current-window-configuration))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
365 (result
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
366 ;; We just simulate a `return' in C. This function is way ugly
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
367 ;; and does `returns' all over the place and there's no sense
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
368 ;; in trying to rewrite it to be more Lispy.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
369 (catch 'done
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
370 (let (window old-frame target-frame explicit-frame)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
371 (setq old-frame (or (last-nonminibuf-frame) (selected-frame)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
372 (setq buffer (get-buffer buffer))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
373 (check-argument-type 'bufferp buffer)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
374
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
375 (setq explicit-frame
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
376 (if pre-display-buffer-function
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
377 (funcall pre-display-buffer-function buffer
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
378 not-this-window-p
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
379 override-frame)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
380
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
381 ;; Give the user the ability to completely reimplement
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
382 ;; this function via the `display-buffer-function'.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
383 (if display-buffer-function
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
384 (throw 'done
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
385 (funcall display-buffer-function buffer
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
386 not-this-window-p
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
387 override-frame)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
388
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
389 ;; If the buffer has a dedicated frame, that takes
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
390 ;; precedence over the current frame, and over what the
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
391 ;; pre-display-buffer-function did.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
392 (let ((dedi (buffer-dedicated-frame buffer)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
393 (if (frame-live-p dedi) (setq explicit-frame dedi)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
394
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
395 ;; if override-frame is supplied, that takes precedence over
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
396 ;; everything. This is gonna look bad if the
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
397 ;; pre-display-buffer-function raised some other frame
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
398 ;; already.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
399 (if override-frame
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
400 (progn
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
401 (check-argument-type 'frame-live-p override-frame)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
402 (setq explicit-frame override-frame)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
403
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
404 (setq target-frame
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
405 (or explicit-frame
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
406 (last-nonminibuf-frame)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
407 (selected-frame)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
408
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
409 ;; If we have switched frames, then set not-this-window-p
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
410 ;; to false. Switching frames means that selected-window
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
411 ;; is no longer the same as it was on entry -- it's the
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
412 ;; selected-window of target_frame instead of old_frame,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
413 ;; so it's a fine candidate for display.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
414 (if (not (eq old-frame target-frame))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
415 (setq not-this-window-p nil))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
416
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
417 ;; if it's in the selected window, and that's ok, then we're done.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
418 (if (and (not not-this-window-p)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
419 (eq buffer (window-buffer (selected-window))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
420 (throw 'done (display-buffer-1 (selected-window))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
421
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
422 ;; See if the user has specified this buffer should appear
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
423 ;; in the selected window.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
424
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
425 (if not-this-window-p
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
426 nil
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
427
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
428 (if (or (member (buffer-name buffer) same-window-buffer-names)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
429 (assoc (buffer-name buffer) same-window-buffer-names))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
430 (progn
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
431 (switch-to-buffer buffer)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
432 (throw 'done (display-buffer-1 (selected-window)))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
433
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
434 (let ((tem same-window-regexps))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
435 (while tem
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
436 (let ((car (car tem)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
437 (if (or
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
438 (and (stringp car)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
439 (string-match car (buffer-name buffer)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
440 (and (consp car) (stringp (car car))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
441 (string-match (car car) (buffer-name buffer))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
442 (progn
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
443 (switch-to-buffer buffer)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
444 (throw 'done (display-buffer-1
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
445 (selected-window))))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
446 (setq tem (cdr tem)))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
447
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
448 ;; If pop-up-frames, look for a window showing BUFFER on
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
449 ;; any visible or iconified frame. Otherwise search only
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
450 ;; the current frame.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
451 (if (and (not explicit-frame)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
452 (or pop-up-frames (not (last-nonminibuf-frame))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
453 (setq target-frame 0))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
454
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
455 ;; Otherwise, find some window that it's already in, and
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
456 ;; return that, unless that window is the selected window
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
457 ;; and that isn't ok. What a contorted mess!
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
458 (setq window (get-buffer-window buffer target-frame))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
459 (if (and window
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
460 (or (not not-this-window-p)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
461 (not (eq window (selected-window)))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
462 (throw 'done (display-buffer-1 window)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
463
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
464 ;; Certain buffer names get special handling.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
465 (if special-display-function
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
466 (progn
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
467 (if (member (buffer-name buffer)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
468 special-display-buffer-names)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
469 (throw 'done (funcall special-display-function buffer)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
470
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
471 (let ((tem (assoc (buffer-name buffer)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
472 special-display-buffer-names)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
473 (if tem
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
474 (throw 'done (funcall special-display-function
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
475 buffer (cdr tem)))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
476
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
477 (let ((tem special-display-regexps))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
478 (while tem
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
479 (let ((car (car tem)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
480 (if (and (stringp car)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
481 (string-match car (buffer-name buffer)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
482 (throw 'done
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
483 (funcall special-display-function buffer)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
484 (if (and (consp car)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
485 (stringp (car car))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
486 (string-match (car car)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
487 (buffer-name buffer)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
488 (throw 'done (funcall
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
489 special-display-function buffer
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
490 (cdr car)))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
491 (setq tem (cdr tem))))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
492
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
493 ;; If there are no frames open that have more than a minibuffer,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
494 ;; we need to create a new frame.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
495 (if (or pop-up-frames
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
496 (null (last-nonminibuf-frame)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
497 (progn
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
498 (setq window (frame-selected-window
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
499 (funcall pop-up-frame-function)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
500 (set-window-buffer window buffer)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
501 (throw 'done (display-buffer-1 window))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
502
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
503 ;; Otherwise, make it be in some window, splitting if
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
504 ;; appropriate/possible. Do not split a window if we are
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
505 ;; displaying the buffer in a different frame than that which
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
506 ;; was current when we were called. (It is already in a
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
507 ;; different window by virtue of being in another frame.)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
508 (if (or (and pop-up-windows (eq target-frame old-frame))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
509 (eq 'only (frame-property (selected-frame) 'minibuffer))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
510 ;; If the current frame is a special display frame,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
511 ;; don't try to reuse its windows.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
512 (window-dedicated-p (frame-root-window (selected-frame))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
513 (progn
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
514 (if (eq 'only (frame-property (selected-frame) 'minibuffer))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
515 (setq target-frame (last-nonminibuf-frame)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
516
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
517 ;; Don't try to create a window if would get an error with
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
518 ;; height.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
519 (if (< split-height-threshold (* 2 window-min-height))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
520 (setq split-height-threshold (* 2 window-min-height)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
521
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
522 ;; Same with width.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
523 (if (< split-width-threshold (* 2 window-min-width))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
524 (setq split-width-threshold (* 2 window-min-width)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
525
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
526 ;; If the frame we would try to split cannot be split,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
527 ;; try other frames.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
528 (if (frame-property (if (null target-frame)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
529 (selected-frame)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
530 (last-nonminibuf-frame))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
531 'unsplittable)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
532 (setq window
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
533 ;; Try visible frames first.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
534 (or (get-largest-window 'visible)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
535 ;; If that didn't work, try iconified frames.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
536 (get-largest-window 0)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
537 (get-largest-window t)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
538 (setq window (get-largest-window target-frame)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
539
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
540 ;; If we got a tall enough full-width window that
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
541 ;; can be split, split it.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
542 (if (and window
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
543 (not (frame-property (window-frame window)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
544 'unsplittable))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
545 (>= (window-height window) split-height-threshold)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
546 (or (>= (window-width window)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
547 split-width-threshold)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
548 (and (window-leftmost-p window)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
549 (window-rightmost-p window))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
550 (setq window (split-window window))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
551 (let (upper
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
552 ;; lower
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
553 other)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
554 (setq window (get-lru-window target-frame))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
555 ;; If the LRU window is selected, and big enough,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
556 ;; and can be split, split it.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
557 (if (and window
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
558 (not (frame-property (window-frame window)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
559 'unsplittable))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
560 (or (eq window (selected-window))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
561 (not (window-parent window)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
562 (>= (window-height window)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
563 (* 2 window-min-height)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
564 (setq window (split-window window)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
565 ;; If get-lru-window returned nil, try other approaches.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
566 ;; Try visible frames first.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
567 (or window
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
568 (setq window (or (get-largest-window 'visible)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
569 ;; If that didn't work, try
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
570 ;; iconified frames.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
571 (get-largest-window 0)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
572 ;; Try invisible frames.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
573 (get-largest-window t)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
574 ;; As a last resort, make
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
575 ;; a new frame.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
576 (frame-selected-window
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
577 (funcall
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
578 pop-up-frame-function)))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
579 ;; If window appears above or below another,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
580 ;; even out their heights.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
581 (if (window-previous-child window)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
582 (setq other (window-previous-child window)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
583 ;; lower window
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
584 upper other))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
585 (if (window-next-child window)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
586 (setq other (window-next-child window)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
587 ;; lower other
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
588 upper window))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
589 ;; Check that OTHER and WINDOW are vertically arrayed.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
590 (if (and other
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
591 (not (= (nth 1 (window-pixel-edges other))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
592 (nth 1 (window-pixel-edges window))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
593 (> (window-pixel-height other)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
594 (window-pixel-height window)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
595 (enlarge-window (- (/ (+ (window-height other)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
596 (window-height window))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
597 2)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
598 (window-height upper))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
599 nil upper)))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
600
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
601 (setq window (get-lru-window target-frame)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
602
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
603 ;; Bring the window's previous buffer to the top of the MRU chain.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
604 (if (window-buffer window)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
605 (save-excursion
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
606 (save-selected-window
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
607 (select-window window)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
608 (record-buffer (window-buffer window)))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
609
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
610 (set-window-buffer window buffer)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
611
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
612 (display-buffer-1 window)))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
613 (or (equal wconfig (current-window-configuration))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
614 (push-window-configuration wconfig))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
615 result))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
616
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
617 ;;; window-xemacs.el ends here