annotate lisp/window-xemacs.el @ 939:025200a2163c

[xemacs-hg @ 2002-07-31 07:23:39 by michaels] 2002-07-17 Marcus Crestani <crestani@informatik.uni-tuebingen.de> Markus Kaltenbach <makalten@informatik.uni-tuebingen.de> Mike Sperber <mike@xemacs.org> configure flag to turn these changes on: --use-kkcc First we added a dumpable flag to lrecord_implementation. It shows, if the object is dumpable and should be processed by the dumper. * lrecord.h (struct lrecord_implementation): added dumpable flag (MAKE_LRECORD_IMPLEMENTATION): fitted the different makro definitions to the new lrecord_implementation and their calls. Then we changed mark_object, that it no longer needs a mark method for those types that have pdump descritions. * alloc.c: (mark_object): If the object has a description, the new mark algorithm is called, and the object is marked according to its description. Otherwise it uses the mark method like before. These procedures mark objects according to their descriptions. They are modeled on the corresponding pdumper procedures. (mark_with_description): (get_indirect_count): (structure_size): (mark_struct_contents): These procedures still call mark_object, this is needed while there are Lisp_Objects without descriptions left. We added pdump descriptions for many Lisp_Objects: * extents.c: extent_auxiliary_description * database.c: database_description * gui.c: gui_item_description * scrollbar.c: scrollbar_instance_description * toolbar.c: toolbar_button_description * event-stream.c: command_builder_description * mule-charset.c: charset_description * device-msw.c: devmode_description * dialog-msw.c: mswindows_dialog_id_description * eldap.c: ldap_description * postgresql.c: pgconn_description pgresult_description * tooltalk.c: tooltalk_message_description tooltalk_pattern_description * ui-gtk.c: emacs_ffi_description emacs_gtk_object_description * events.c: * events.h: * event-stream.c: * event-Xt.c: * event-gtk.c: * event-tty.c: To write a pdump description for Lisp_Event, we converted every struct in the union event to a Lisp_Object. So we created nine new Lisp_Objects: Lisp_Key_Data, Lisp_Button_Data, Lisp_Motion_Data, Lisp_Process_Data, Lisp_Timeout_Data, Lisp_Eval_Data, Lisp_Misc_User_Data, Lisp_Magic_Data, Lisp_Magic_Eval_Data. We also wrote makro selectors and mutators for the fields of the new designed Lisp_Event and added everywhere these new abstractions. We implemented XD_UNION support in (mark_with_description), so we can describe exspecially console/device specific data with XD_UNION. To describe with XD_UNION, we added a field to these objects, which holds the variant type of the object. This field is initialized in the appendant constructor. The variant is an integer, it has also to be described in an description, if XD_UNION is used. XD_UNION is used in following descriptions: * console.c: console_description (get_console_variant): returns the variant (create_console): added variant initialization * console.h (console_variant): the different console types * console-impl.h (struct console): added enum console_variant contype * device.c: device_description (Fmake_device): added variant initialization * device-impl.h (struct device): added enum console_variant devtype * objects.c: image_instance_description font_instance_description (Fmake_color_instance): added variant initialization (Fmake_font_instance): added variant initialization * objects-impl.h (struct Lisp_Color_Instance): added color_instance_type * objects-impl.h (struct Lisp_Font_Instance): added font_instance_type * process.c: process_description (make_process_internal): added variant initialization * process.h (process_variant): the different process types
author michaels
date Wed, 31 Jul 2002 07:23:39 +0000
parents 4a27df428c73
children a123f88fa975
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."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 (setq window (or window (selected-window))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 frame (or frame (selected-frame)))
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))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 ;; The window-config stack is stored as a list in frame property
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 ;; 'window-config-stack, with the most recent element at the front.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 ;; 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
112 ;; front of frame property 'window-config-unpop-stack, so you can
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 ;; retrieve it using unpop-window-configuration.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 (defcustom window-config-stack-max 16
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 "*Maximum size of window configuration stack.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 Start discarding off end if it gets this big."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 :type 'integer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 :group 'windows)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 (defun window-config-stack (&optional frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 (or frame (setq frame (selected-frame)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 (let ((stack (frame-property frame 'window-config-stack)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 (if stack
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 (set-undoable-stack-max stack window-config-stack-max)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 (setq stack (make-undoable-stack window-config-stack-max))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 (set-frame-property frame 'window-config-stack stack)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 stack))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 (defun push-window-configuration (&optional config)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 "Push the current window configuration onto the window-config stack.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 If CONFIG is specified, push it instead of the current window configuration.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 Each frame has its own window-config stack."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 (let ((wc (or config (current-window-configuration)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 (stack (window-config-stack)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 (if (or (= 0 (undoable-stack-a-length stack))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 (not (equal (undoable-stack-a-top stack) wc)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 (undoable-stack-push stack wc))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 (defun pop-window-configuration ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 "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
144 Before setting the new window configuration, the current window configuration
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 is pushed onto the \"unpop\" stack.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 `unpop-window-configuration' undoes what this function does.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 Each frame has its own window-config and \"unpop\" stack."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 (let ((stack (window-config-stack))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 (wc (current-window-configuration))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 popped)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 (condition-case nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 (setq popped (undoable-stack-pop stack))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 (while (equal popped wc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 (setq popped (undoable-stack-pop stack)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 (undoable-stack-push stack wc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 (undoable-stack-undo stack)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 (set-window-configuration popped)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 popped)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 (trunc-stack-bottom
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 (error "Bottom of window config stack")))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 (defun unpop-window-configuration ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 "Undo the effect of the most recent `pop-window-configuration'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 This does exactly the inverse of what `pop-window-configuration' does:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 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
168 pushes the current window configuration onto the window-config stack.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 Each frame has its own window-config and \"unpop\" stack."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 (let ((stack (window-config-stack))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 (wc (current-window-configuration))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 popped)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 (condition-case nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 (setq popped
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 (undoable-stack-redo stack)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 (undoable-stack-pop stack)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 (while (equal popped wc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 (setq popped
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 (undoable-stack-redo stack)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 (undoable-stack-pop stack))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 (undoable-stack-push stack wc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 (set-window-configuration popped)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 popped)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 (trunc-stack-bottom
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 (error "Top of window config stack")))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 ;;;;;;;;;;;;; display-buffer, moved here from C. Hallelujah.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
194 (make-variable-buffer-local '__buffer-dedicated-frame)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
195
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
196 (defun buffer-dedicated-frame (&optional buffer)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
197 "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
198 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
199 (let ((buffer (decode-buffer buffer)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
200 (let ((frame (symbol-value-in-buffer '__buffer-dedicated-frame buffer)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
201 ;; 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
202 (when (and (framep frame) (not (frame-live-p frame)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
203 (with-current-buffer buffer
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
204 (setq __buffer-dedicated-frame nil))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
205 (setq frame nil))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
206 frame)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
207
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
208 (defun set-buffer-dedicated-frame (buffer frame)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
209 "For this BUFFER, set the FRAME dedicated to it.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
210 FRAME must be a frame or nil."
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
211 (let ((buffer (decode-buffer buffer)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
212 (and frame
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
213 (check-argument-type #'frame-live-p frame))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
214 (with-current-buffer buffer
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
215 (setq __buffer-dedicated-frame frame))))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
216
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 (defvar display-buffer-function nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 "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
219 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
220
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 (defvar pre-display-buffer-function nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 "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
223 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
224 to `display-buffer'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 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
226 for example. See also the variable `display-buffer-function', which may
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 be used to completely replace the `display-buffer' function.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 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
229 and that frame will be used to display the buffer.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 (defcustom pop-up-frames nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 "*Non-nil means `display-buffer' should make a separate frame."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 :type 'boolean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 :group 'frames)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 (defvar pop-up-frame-function nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 "Function to call to handle automatic new frame creation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 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
239
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 A typical value might be `(lambda () (new-frame pop-up-frame-alist))'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 where `pop-up-frame-alist' would hold the default frame parameters.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 (defcustom special-display-buffer-names nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 "*List of buffer names that should have their own special frames.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 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
246 using `special-display-function'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 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
249 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
250 parameters for creating the frame for that buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 More precisely, the cdr is passed as the second argument to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 the function found in `special-display-function', when making that frame.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 See also `special-display-regexps'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 :type '(repeat (choice :value ""
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 (string :tag "Name")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 (cons :menu-tag "Properties"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 :value ("" . nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 (string :tag "Name")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 (repeat :tag "Properties"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 (group :inline t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 (symbol :tag "Property")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 (sexp :tag "Value"))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 :group 'frames)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 (defcustom special-display-regexps nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 "*List of regexps saying which buffers should have their own special frames.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 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
268 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
269 using `special-display-function'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 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
272 Then the car should be the regexp, and the cdr specifies frame
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 parameters for creating the frame for buffers that match.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 More precisely, the cdr is passed as the second argument to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 the function found in `special-display-function', when making that frame.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 See also `special-display-buffer-names'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 :type '(repeat (choice :value ""
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 regexp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 (cons :menu-tag "Properties"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 :value ("" . nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 regexp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 (repeat :tag "Properties"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 (group :inline t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 (symbol :tag "Property")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 (sexp :tag "Value"))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 :group 'frames)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 (defvar special-display-function nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 "Function to call to make a new frame for a special buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 It is called with two arguments, the buffer and optional buffer specific
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 data, and should return a window displaying that buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 The default value makes a separate frame for the buffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 using `special-display-frame-alist' to specify the frame parameters.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 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
296 or matches a regexp in `special-display-regexps'.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 (defcustom same-window-buffer-names nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 "*List of buffer names that should appear in the selected window.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 Displaying one of these buffers using `display-buffer' or `pop-to-buffer'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 switches to it in the selected window, rather than making it appear
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 in some other window.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 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
305 Then the car must be a string, which specifies the buffer name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 This is for compatibility with `special-display-buffer-names';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 the cdr of the cons cell is ignored.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 See also `same-window-regexps'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 :type '(repeat (string :tag "Name"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 :group 'windows)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 (defcustom same-window-regexps nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 "*List of regexps saying which buffers should appear in the selected window.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 If a buffer name matches one of these regexps, then displaying it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 using `display-buffer' or `pop-to-buffer' switches to it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 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
318
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 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
320 Then the car must be a string, which specifies the buffer name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 This is for compatibility with `special-display-buffer-names';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 the cdr of the cons cell is ignored.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 See also `same-window-buffer-names'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 :type '(repeat regexp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 :group 'windows)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 (defcustom pop-up-windows t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 "*Non-nil means display-buffer should make new windows."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 :type 'boolean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 :group 'windows)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 (defcustom split-height-threshold 500
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 "*display-buffer would prefer to split the largest window if this large.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 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
336 :type 'integer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 :group 'windows)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 (defcustom split-width-threshold 500
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 "*display-buffer would prefer to split the largest window if this large.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 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
342 :type 'integer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 :group 'windows)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 ;; Deiconify the frame containing the window WINDOW, then return WINDOW.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 (defun display-buffer-1 (window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 (if (frame-iconified-p (window-frame window))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 (make-frame-visible (window-frame window)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 ;; Can you believe that all of this crap was formerly in C?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 ;; Praise Jesus that it's not there any more.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 444
diff changeset
355 (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
356 shrink-to-fit)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 "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
358 BUFFER can be a buffer or a buffer name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 If BUFFER is shown already in some window in the current frame,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 just uses that one, unless the window is the selected window and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 NOT-THIS-WINDOW-P is non-nil (interactively, with prefix arg).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 If BUFFER has a dedicated frame, display on that frame instead of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 the current frame, unless OVERRIDE-FRAME is non-nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 If OVERRIDE-FRAME is non-nil, display on that frame instead of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 the current frame (or the dedicated frame).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 444
diff changeset
369 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
370 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
371
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 If `pop-up-windows' is non-nil, always use the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 current frame and create a new window regardless of whether the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 buffer has a dedicated frame, and regardless of whether
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 OVERRIDE-FRAME was specified.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 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
378
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 Returns the window displaying BUFFER."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 (interactive "BDisplay buffer:\nP")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 (let ((wconfig (current-window-configuration))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 (result
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 ;; We just simulate a `return' in C. This function is way ugly
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 ;; and does `returns' all over the place and there's no sense
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 ;; in trying to rewrite it to be more Lispy.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 (catch 'done
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 (let (window old-frame target-frame explicit-frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 (setq old-frame (or (last-nonminibuf-frame) (selected-frame)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 (setq buffer (get-buffer buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 (check-argument-type 'bufferp buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 (setq explicit-frame
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 (if pre-display-buffer-function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 (funcall pre-display-buffer-function buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 not-this-window-p
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 444
diff changeset
397 override-frame
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 444
diff changeset
398 shrink-to-fit)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 ;; Give the user the ability to completely reimplement
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 ;; this function via the `display-buffer-function'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 (if display-buffer-function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 (throw 'done
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 (funcall display-buffer-function buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 not-this-window-p
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 444
diff changeset
406 override-frame
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 444
diff changeset
407 shrink-to-fit)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 ;; If the buffer has a dedicated frame, that takes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 ;; precedence over the current frame, and over what the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 ;; pre-display-buffer-function did.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 (let ((dedi (buffer-dedicated-frame buffer)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 (if (frame-live-p dedi) (setq explicit-frame dedi)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 ;; if override-frame is supplied, that takes precedence over
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 ;; everything. This is gonna look bad if the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 ;; pre-display-buffer-function raised some other frame
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 ;; already.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 (if override-frame
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 (check-argument-type 'frame-live-p override-frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 (setq explicit-frame override-frame)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 (setq target-frame
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 (or explicit-frame
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 (last-nonminibuf-frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 (selected-frame)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 ;; If we have switched frames, then set not-this-window-p
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 ;; to false. Switching frames means that selected-window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 ;; 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
432 ;; selected-window of target_frame instead of old_frame,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 ;; so it's a fine candidate for display.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 (if (not (eq old-frame target-frame))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 (setq not-this-window-p nil))
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 ;; 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
438 (if (and (not not-this-window-p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 (eq buffer (window-buffer (selected-window))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 (throw 'done (display-buffer-1 (selected-window))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 ;; See if the user has specified this buffer should appear
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 ;; in the selected window.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 (if not-this-window-p
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 (if (or (member (buffer-name buffer) same-window-buffer-names)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 (assoc (buffer-name buffer) same-window-buffer-names))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 (switch-to-buffer buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 (throw 'done (display-buffer-1 (selected-window)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 (let ((tem same-window-regexps))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 (while tem
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 (let ((car (car tem)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 (if (or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 (and (stringp car)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 (string-match car (buffer-name buffer)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 (and (consp car) (stringp (car car))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 (string-match (car car) (buffer-name buffer))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 (switch-to-buffer buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 (throw 'done (display-buffer-1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 (selected-window))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 (setq tem (cdr tem)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 ;; If pop-up-frames, look for a window showing BUFFER on
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 ;; any visible or iconified frame. Otherwise search only
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 ;; the current frame.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 (if (and (not explicit-frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 (or pop-up-frames (not (last-nonminibuf-frame))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 (setq target-frame 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 ;; Otherwise, find some window that it's already in, and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 ;; return that, unless that window is the selected window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 ;; and that isn't ok. What a contorted mess!
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 (setq window (or (if (not explicit-frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 ;; search the selected frame
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 ;; first if the user didn't
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 ;; specify an explicit frame.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 (get-buffer-window buffer nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 (get-buffer-window buffer target-frame)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 (if (and window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 (or (not not-this-window-p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 (not (eq window (selected-window)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 (throw 'done (display-buffer-1 window)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 ;; Certain buffer names get special handling.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 (if special-display-function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 (if (member (buffer-name buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 special-display-buffer-names)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 (throw 'done (funcall special-display-function buffer)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 (let ((tem (assoc (buffer-name buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 special-display-buffer-names)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 (if tem
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 (throw 'done (funcall special-display-function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 buffer (cdr tem)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 (let ((tem special-display-regexps))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 (while tem
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 (let ((car (car tem)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 (if (and (stringp car)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 (string-match car (buffer-name buffer)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 (throw 'done
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 (funcall special-display-function buffer)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 (if (and (consp car)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 (stringp (car car))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 (string-match (car car)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 (buffer-name buffer)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 (throw 'done (funcall
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 special-display-function buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 (cdr car)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 (setq tem (cdr tem))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 ;; If there are no frames open that have more than a minibuffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 ;; we need to create a new frame.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 (if (or pop-up-frames
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 (null (last-nonminibuf-frame)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 (setq window (frame-selected-window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 (funcall pop-up-frame-function)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 (set-window-buffer window buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 (throw 'done (display-buffer-1 window))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 ;; Otherwise, make it be in some window, splitting if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 ;; appropriate/possible. Do not split a window if we are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 ;; displaying the buffer in a different frame than that which
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 ;; was current when we were called. (It is already in a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 ;; different window by virtue of being in another frame.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 (if (or (and pop-up-windows (eq target-frame old-frame))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 (eq 'only (frame-property (selected-frame) 'minibuffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 ;; If the current frame is a special display frame,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 ;; don't try to reuse its windows.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 (window-dedicated-p (frame-root-window (selected-frame))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 (if (eq 'only (frame-property (selected-frame) 'minibuffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 (setq target-frame (last-nonminibuf-frame)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 ;; 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
543 ;; height.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 (if (< split-height-threshold (* 2 window-min-height))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 (setq split-height-threshold (* 2 window-min-height)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 ;; Same with width.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 (if (< split-width-threshold (* 2 window-min-width))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 (setq split-width-threshold (* 2 window-min-width)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 ;; If the frame we would try to split cannot be split,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 ;; try other frames.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 (if (frame-property (if (null target-frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 (selected-frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 (last-nonminibuf-frame))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 'unsplittable)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 (setq window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 ;; Try visible frames first.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 (or (get-largest-window 'visible)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 ;; If that didn't work, try iconified frames.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 (get-largest-window 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 (get-largest-window t)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 (setq window (get-largest-window target-frame)))
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 ;; If we got a tall enough full-width window that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 ;; can be split, split it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 (if (and window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 (not (frame-property (window-frame window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 'unsplittable))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 (>= (window-height window) split-height-threshold)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 (or (>= (window-width window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 split-width-threshold)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 (and (window-leftmost-p window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 (window-rightmost-p window))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 (setq window (split-window window))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 (let (upper
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 ;; lower
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 other)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 (setq window (get-lru-window target-frame))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 ;; If the LRU window is selected, and big enough,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 ;; and can be split, split it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 (if (and window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 (not (frame-property (window-frame window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 'unsplittable))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 (or (eq window (selected-window))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 (not (window-parent window)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 (>= (window-height window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 (* 2 window-min-height)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 (setq window (split-window window)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 ;; If get-lru-window returned nil, try other approaches.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 ;; Try visible frames first.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 (or window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 (setq window (or (get-largest-window 'visible)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 ;; If that didn't work, try
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 ;; iconified frames.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 (get-largest-window 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 ;; Try invisible frames.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 (get-largest-window t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 ;; As a last resort, make
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 ;; a new frame.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 (frame-selected-window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 (funcall
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 pop-up-frame-function)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 ;; If window appears above or below another,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 ;; even out their heights.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 (if (window-previous-child window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 (setq other (window-previous-child window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 ;; lower window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 upper other))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 (if (window-next-child window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 (setq other (window-next-child window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 ;; lower other
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 upper window))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 ;; Check that OTHER and WINDOW are vertically arrayed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 (if (and other
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 (not (= (nth 1 (window-pixel-edges other))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 (nth 1 (window-pixel-edges window))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 (> (window-pixel-height other)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619 (window-pixel-height window)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 (enlarge-window (- (/ (+ (window-height other)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 (window-height window))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 (window-height upper))
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 444
diff changeset
624 nil upper))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 444
diff changeset
625 (if shrink-to-fit
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 444
diff changeset
626 (shrink-window-if-larger-than-buffer window)))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 (setq window (get-lru-window target-frame)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630 ;; 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
631 (if (window-buffer window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 (save-selected-window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 (select-window window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 (record-buffer (window-buffer window)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 (set-window-buffer window buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 (display-buffer-1 window)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 (or (equal wconfig (current-window-configuration))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 (push-window-configuration wconfig))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 result))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 ;;; window-xemacs.el ends here