annotate lisp/window-xemacs.el @ 5634:2014ff433daf

Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion src/ChangeLog addition: 2012-01-01 Aidan Kehoe <kehoea@parhasard.net> Add #'test-completion, API from GNU. Accept hash table COLLECTIONs in it and in the other completion-oriented functions, #'try-completion, #'all-completions, and those Lisp functions implemented in terms of them. * lisp.h: Update the prototype of map_obarray(), making FN compatible with the FUNCTION argument of elisp_maphash(); * abbrev.c (abbrev_match_mapper): * abbrev.c (record_symbol): * doc.c (verify_doc_mapper): * symbols.c (mapatoms_1): * symbols.c (apropos_mapper): Update these mapper functions to reflect the new argument to map_obarray(). * symbols.c (map_obarray): Call FN with two arguments, the string name of the symbol, and the symbol itself, for API (mapper) compatibility with elisp_maphash(). * minibuf.c (map_completion): New. Map a maphash_function_t across a non function COLLECTION, as appropriate for #'try-completion and friends. * minibuf.c (map_completion_list): New. Map a maphash_function_t across a pseudo-alist, as appropriate for the completion functions. * minibuf.c (ignore_completion_p): PRED needs to be called with two args if and only if the collection is a hash table. Implement this. * minibuf.c (try_completion_mapper): New. The loop body of #'try-completion, refactored out. * minibuf.c (Ftry_completion): Use try_completion_mapper(), map_completion(). * minibuf.c (all_completions_mapper): New. The loop body of #'all-completions, refactored out. * minibuf.c (Fall_completions): Use all_completions_mapper(), map_completion(). * minibuf.c (test_completion_mapper): New. The loop body of #'test-completion. * minibuf.c (Ftest_completion): New, API from GNU. * minibuf.c (syms_of_minibuf): Make Ftest_completion available. tests/ChangeLog addition: 2012-01-01 Aidan Kehoe <kehoea@parhasard.net> * automated/completion-tests.el: New. Test #'try-completion, #'all-completion and #'test-completion with list, vector and hash-table COLLECTION arguments.
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 01 Jan 2012 15:18:52 +0000
parents ac37a5f7e5be
children 5d3bb1100832
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
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4674
diff changeset
11 ;; XEmacs is free software: you can redistribute it and/or modify it
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4674
diff changeset
12 ;; under the terms of the GNU General Public License as published by the
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4674
diff changeset
13 ;; Free Software Foundation, either version 3 of the License, or (at your
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4674
diff changeset
14 ;; option) any later version.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4674
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful, but WITHOUT
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4674
diff changeset
17 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4674
diff changeset
18 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4674
diff changeset
19 ;; for more details.
428
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
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4674
diff changeset
22 ;; along with XEmacs. If not, see <http://www.gnu.org/licenses/>.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 ;;; Synched up with: Not synched.
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 ;;; Commentary:
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 ;; This file is dumped with XEmacs.
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 ;; slb - 5/29/97
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 ;; 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
32 ;; with Emacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 ;;; Code:
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 (defgroup windows nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 "Windows within a frame."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 :group 'environment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 (defun recenter (&optional n window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 "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
42 The desired position of point is always relative to the window.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 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
44 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
45 redraws with point in the center of the window.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 If WINDOW is nil, the selected window is used."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 (interactive "_P")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 (center-to-window-line (if (consp n) nil n) window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 (when (null n)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 (redraw-frame (window-frame window) t)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
52 (defun backward-other-window (count &optional which-frames which-devices)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
53 "Select the COUNT'th different window on this frame, going backwards.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
54 This is just like calling `other-window' with COUNT negated."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 (interactive "p")
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
56 (other-window (- count) which-frames which-devices))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 (defalias 'windows-of-buffer 'get-buffer-window-list)
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 (defun buffer-in-multiple-windows-p (&optional buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 "Return t if BUFFER is in multiple windows.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 If BUFFER is not specified, the current buffer will be used."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 (setq buffer (or buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 (get-buffer buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 (get-file-buffer buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 (current-buffer)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 (> (length (windows-of-buffer buffer)) 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 (defun window-list (&optional frame minibuf window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 "Return a list of windows on FRAME, beginning with WINDOW.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 FRAME and WINDOW default to the selected ones.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 Optional second arg MINIBUF t means count the minibuffer window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 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
74 not to count the minibuffer even if it is active."
1261
465bd3c7d932 [xemacs-hg @ 2003-02-06 06:35:47 by ben]
ben
parents: 1230
diff changeset
75 (setq frame (or frame (selected-frame))
465bd3c7d932 [xemacs-hg @ 2003-02-06 06:35:47 by ben]
ben
parents: 1230
diff changeset
76 window (or window (selected-window frame)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 (if (not (eq (window-frame window) frame))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 (error "Window must be on frame."))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 (let ((current-frame (selected-frame))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 list)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 (unwind-protect
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 (save-window-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 (select-frame frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 (walk-windows
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 (function (lambda (cur-window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 (if (not (eq window cur-window))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 (setq list (cons cur-window list)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 minibuf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 (setq list (cons window list)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 (select-frame current-frame))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 ;; We used to have set-window-dedicated-p as an obsolete version
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 ;; of set-window-buffer-dedicated, but it really makes more sense
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 ;; this way.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 (make-obsolete 'set-window-buffer-dedicated 'set-window-dedicated-p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 (defun set-window-buffer-dedicated (window buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 "Make WINDOW display BUFFER and be dedicated to that buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 Then Emacs will not automatically change which buffer appears in WINDOW.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 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
101 buffer appears in it currently)."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 (if (bufferp buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 (set-window-buffer window (get-buffer-create buffer)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 (set-window-dedicated-p window (not (null buffer))))
1149
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
105
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
106 ;; Window configurations
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107
3646
b6287dbce5f0 [xemacs-hg @ 2006-10-31 09:16:27 by michaels]
michaels
parents: 2888
diff changeset
108 (defcustom window-configuration-includes-position nil
b6287dbce5f0 [xemacs-hg @ 2006-10-31 09:16:27 by michaels]
michaels
parents: 2888
diff changeset
109 "*Whether restoring window configurations will restore positions too.
b6287dbce5f0 [xemacs-hg @ 2006-10-31 09:16:27 by michaels]
michaels
parents: 2888
diff changeset
110 If nil, only the size of windows will be restored.
b6287dbce5f0 [xemacs-hg @ 2006-10-31 09:16:27 by michaels]
michaels
parents: 2888
diff changeset
111
b6287dbce5f0 [xemacs-hg @ 2006-10-31 09:16:27 by michaels]
michaels
parents: 2888
diff changeset
112 Note that setting this value to t may have counterintuitive consequences,
b6287dbce5f0 [xemacs-hg @ 2006-10-31 09:16:27 by michaels]
michaels
parents: 2888
diff changeset
113 if a window manager employing virtual desktops is in use."
b6287dbce5f0 [xemacs-hg @ 2006-10-31 09:16:27 by michaels]
michaels
parents: 2888
diff changeset
114 :type 'boolean
b6287dbce5f0 [xemacs-hg @ 2006-10-31 09:16:27 by michaels]
michaels
parents: 2888
diff changeset
115 :group 'windows)
b6287dbce5f0 [xemacs-hg @ 2006-10-31 09:16:27 by michaels]
michaels
parents: 2888
diff changeset
116
1149
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
117 (defstruct saved-window
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
118 currentp minibufferp minibuffer-scrollp
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
119 buffer mark-marker
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
120 start-marker
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
121 point-marker
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
122 pixel-left pixel-top pixel-right pixel-bottom
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
123 hscroll modeline-hscroll
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
124 dedicatedp
4445
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
125 first-hchild first-vchild next-child
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
126 window)
1149
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
127
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
128 (defstruct window-configuration
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
129 frame
2872
5bf18ccb05df [xemacs-hg @ 2005-07-24 17:53:21 by michaels]
michaels
parents: 2590
diff changeset
130 frame-top frame-left
1149
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
131 frame-pixel-width frame-pixel-height
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
132 current-buffer
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
133 minibuffer-pixel-height
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
134 min-width min-height
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
135 saved-root-window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
136
4444
715c3ced8fa8 Use `real-split-window', `real-delete-window' in window-config code.
Mike Sperber <sperber@deinprogramm.de>
parents: 4438
diff changeset
137 ; make sure we don't get affected by harmful advice
715c3ced8fa8 Use `real-split-window', `real-delete-window' in window-config code.
Mike Sperber <sperber@deinprogramm.de>
parents: 4438
diff changeset
138 (fset 'real-split-window (symbol-function 'split-window))
715c3ced8fa8 Use `real-split-window', `real-delete-window' in window-config code.
Mike Sperber <sperber@deinprogramm.de>
parents: 4438
diff changeset
139 (fset 'real-delete-window (symbol-function 'delete-window))
715c3ced8fa8 Use `real-split-window', `real-delete-window' in window-config code.
Mike Sperber <sperber@deinprogramm.de>
parents: 4438
diff changeset
140
1149
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
141 (defun window-configuration-equal (conf-1 conf-2)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
142 "Returns a boolean indicating whether the two given configurations
3646
b6287dbce5f0 [xemacs-hg @ 2006-10-31 09:16:27 by michaels]
michaels
parents: 2888
diff changeset
143 are identical.
b6287dbce5f0 [xemacs-hg @ 2006-10-31 09:16:27 by michaels]
michaels
parents: 2888
diff changeset
144
b6287dbce5f0 [xemacs-hg @ 2006-10-31 09:16:27 by michaels]
michaels
parents: 2888
diff changeset
145 Window configurations containing windows with different window
b6287dbce5f0 [xemacs-hg @ 2006-10-31 09:16:27 by michaels]
michaels
parents: 2888
diff changeset
146 positions are not identical iff `window-configuration-includes-position'
b6287dbce5f0 [xemacs-hg @ 2006-10-31 09:16:27 by michaels]
michaels
parents: 2888
diff changeset
147 is t."
1149
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
148 (or (eq conf-1 conf-2)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
149 (and (eq (window-configuration-frame conf-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
150 (window-configuration-frame conf-2))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
151 (= (window-configuration-frame-pixel-width conf-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
152 (window-configuration-frame-pixel-width conf-2))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
153 (= (window-configuration-frame-pixel-height conf-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
154 (window-configuration-frame-pixel-height conf-2))
3646
b6287dbce5f0 [xemacs-hg @ 2006-10-31 09:16:27 by michaels]
michaels
parents: 2888
diff changeset
155 (if window-configuration-includes-position
b6287dbce5f0 [xemacs-hg @ 2006-10-31 09:16:27 by michaels]
michaels
parents: 2888
diff changeset
156 (and (equal (window-configuration-frame-top conf-1)
b6287dbce5f0 [xemacs-hg @ 2006-10-31 09:16:27 by michaels]
michaels
parents: 2888
diff changeset
157 (window-configuration-frame-top conf-2))
b6287dbce5f0 [xemacs-hg @ 2006-10-31 09:16:27 by michaels]
michaels
parents: 2888
diff changeset
158 (equal (window-configuration-frame-left conf-1)
b6287dbce5f0 [xemacs-hg @ 2006-10-31 09:16:27 by michaels]
michaels
parents: 2888
diff changeset
159 (window-configuration-frame-left conf-2)))
b6287dbce5f0 [xemacs-hg @ 2006-10-31 09:16:27 by michaels]
michaels
parents: 2888
diff changeset
160 t)
1149
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
161 (eq (window-configuration-current-buffer conf-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
162 (window-configuration-current-buffer conf-2))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
163 (saved-window-equal (window-configuration-saved-root-window conf-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
164 (window-configuration-saved-root-window conf-2)))))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
165
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
166 (defun saved-window-equal (saved-1 saved-2)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
167 "Returns a boolean indicating whether the two given saved windows
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
168 are identical."
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
169 (or (eq saved-1 saved-2)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
170 (and (eq (saved-window-currentp saved-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
171 (saved-window-currentp saved-2))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
172 (eq (saved-window-minibuffer-scrollp saved-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
173 (saved-window-minibuffer-scrollp saved-2))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
174 (eq (saved-window-buffer saved-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
175 (saved-window-buffer saved-2))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
176 (equal (saved-window-mark-marker saved-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
177 (saved-window-mark-marker saved-2))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
178 (or (and (saved-window-currentp saved-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
179 (saved-window-currentp saved-2))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
180 (equal (saved-window-start-marker saved-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
181 (saved-window-start-marker saved-2)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
182 (or (and (saved-window-currentp saved-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
183 (saved-window-currentp saved-2))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
184 (equal (saved-window-point-marker saved-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
185 (saved-window-point-marker saved-2)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
186 (= (saved-window-pixel-left saved-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
187 (saved-window-pixel-left saved-2))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
188 (= (saved-window-pixel-top saved-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
189 (saved-window-pixel-top saved-2))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
190 (= (saved-window-pixel-right saved-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
191 (saved-window-pixel-right saved-2))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
192 (= (saved-window-pixel-bottom saved-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
193 (saved-window-pixel-bottom saved-2))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
194 (= (saved-window-hscroll saved-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
195 (saved-window-hscroll saved-2))
1387
e04cd2f562b7 [xemacs-hg @ 2003-03-26 15:09:51 by james]
james
parents: 1261
diff changeset
196 (equal (saved-window-modeline-hscroll saved-1)
e04cd2f562b7 [xemacs-hg @ 2003-03-26 15:09:51 by james]
james
parents: 1261
diff changeset
197 (saved-window-modeline-hscroll saved-2))
1149
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
198 (eq (saved-window-dedicatedp saved-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
199 (saved-window-dedicatedp saved-2))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
200 (maybe-saved-window-equal (saved-window-first-hchild saved-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
201 (saved-window-first-hchild saved-2))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
202 (maybe-saved-window-equal (saved-window-first-vchild saved-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
203 (saved-window-first-vchild saved-2))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
204 (maybe-saved-window-equal (saved-window-next-child saved-1)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
205 (saved-window-next-child saved-2)))))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
206
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
207 (defun maybe-saved-window-equal (maybe-saved-1 maybe-saved-2)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
208 "Returns a boolean indicating whether the two given saved windows
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
209 or NILs are identical."
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
210 (cond
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
211 ((and (not maybe-saved-1) (not maybe-saved-2)) t)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
212 ((not maybe-saved-1) (not maybe-saved-2))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
213 ((not maybe-saved-2) (not maybe-saved-1))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
214 (t (saved-window-equal maybe-saved-1 maybe-saved-2))))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
215
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
216 (defun current-window-configuration (&optional frame)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
217 "Return an object representing the current window configuration of FRAME.
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
218 If FRAME is nil or omitted, use the selected frame.
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
219 This describes the number of windows, their sizes and current buffers,
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
220 and for each window on FRAME the displayed buffer, where display
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
221 starts, and the positions of point and mark.
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
222 An exception is made for point in the current buffer:
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
223 its value is -not- saved."
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
224 (let ((frame (or frame (selected-frame))))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
225 ;; The original C code used complicated but still incomplete logic
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
226 ;; to decide if and how to restore the size of the minibuffer. It
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
227 ;; goes something like this:
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
228 ; (let ((real-font-height
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
229 ; (font-height (face-font 'default) frame))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
230 ; (minibuffer-height
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
231 ; (if (and (minibuffer-window frame)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
232 ; (not (frame-minibuffer-only-p frame)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
233 ; (window-pixel-height (minibuffer-window frame))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
234 ; 0)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
235 ; ...)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
236
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
237 (make-window-configuration
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
238 :frame frame
2885
6caa3d30f19f [xemacs-hg @ 2005-08-04 17:13:18 by michaels]
michaels
parents: 2872
diff changeset
239 :frame-top (frame-property frame 'top)
6caa3d30f19f [xemacs-hg @ 2005-08-04 17:13:18 by michaels]
michaels
parents: 2872
diff changeset
240 :frame-left (frame-property frame 'left)
1149
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
241 :frame-pixel-width (frame-pixel-width frame)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
242 :frame-pixel-height (frame-pixel-height frame)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
243 :current-buffer (current-buffer)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
244 :min-width window-min-width :min-height window-min-height
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
245 :minibuffer-pixel-height (window-pixel-height (minibuffer-window frame))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
246 ;; this tries to do what the old code did:
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
247 ; :minibuffer-height (if (zerop (% minibuffer-height real-font-height))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
248 ; (- (/ minibuffer-height real-font-height)) ; lines
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
249 ; minibuffer-height) ; pixels
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
250 :saved-root-window (root-window->saved-window (frame-root-window frame)))))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
251
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
252 (defun root-window->saved-window (window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
253 "Converts a root window into a tree of saved-window structures."
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
254 (let ((buffer (window-buffer window))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
255 (edges (window-pixel-edges window)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
256 (let ((left (nth 0 edges))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
257 (top (nth 1 edges))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
258 (right (nth 2 edges))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
259 (bottom (nth 3 edges)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
260 (let ((saved-window
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
261 (make-saved-window
4445
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
262 :window window
1149
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
263 :currentp (eq window (selected-window (window-frame window)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
264 :minibufferp (eq window (minibuffer-window (window-frame window)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
265 :minibuffer-scrollp (eq window minibuffer-scroll-window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
266 :buffer buffer
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
267 :pixel-left left :pixel-top top :pixel-right right :pixel-bottom bottom
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
268 :hscroll (window-hscroll window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
269 :modeline-hscroll (modeline-hscroll window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
270 :dedicatedp (window-dedicated-p window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
271 :first-hchild (if (window-first-hchild window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
272 (root-window->saved-window (window-first-hchild window))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
273 nil)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
274 :first-vchild (if (window-first-vchild window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
275 (root-window->saved-window (window-first-vchild window))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
276 nil)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
277 :next-child (if (window-next-child window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
278 (root-window->saved-window (window-next-child window))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
279 nil))))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
280 (if buffer
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
281 (progn
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
282 (let ((marker (make-marker)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
283 (set-marker marker (window-start window) buffer)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
284 (setf (saved-window-start-marker saved-window) marker))
4136
db22824aa020 [xemacs-hg @ 2007-08-22 07:15:24 by michaels]
michaels
parents: 3646
diff changeset
285 (if (not (eq buffer (current-buffer)))
db22824aa020 [xemacs-hg @ 2007-08-22 07:15:24 by michaels]
michaels
parents: 3646
diff changeset
286 (let ((marker (make-marker)))
db22824aa020 [xemacs-hg @ 2007-08-22 07:15:24 by michaels]
michaels
parents: 3646
diff changeset
287 (set-marker marker (window-point window) buffer)
db22824aa020 [xemacs-hg @ 2007-08-22 07:15:24 by michaels]
michaels
parents: 3646
diff changeset
288 (setf (saved-window-point-marker saved-window) marker)))
1149
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
289 (setf (saved-window-mark-marker saved-window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
290 (copy-marker (mark-marker t buffer)))))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
291 saved-window))))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
292
4445
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
293 (defmacro save-window-excursion/mapping (&rest body)
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
294 "Execute body, preserving window sizes and contents.
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
295 Restores which buffer appears in which window, where display starts,
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
296 as well as the current buffer.
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
297 Return alist mapping old windows to new windows.
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
298 This alist maps the originally captured windows to the windows that correspond
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
299 to them in the restored configuration. It does not include entries for
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
300 windows that have not changed identity.
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
301 Does not restore the value of point in current buffer."
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
302 (let ((window-config (gensym 'window-config))
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
303 (mapping (gensym 'mapping)))
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
304 `(let ((,window-config (current-window-configuration))
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
305 (,mapping))
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
306 (unwind-protect
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
307 (progn ,@body)
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
308 (setq ,mapping (set-window-configuration/mapping ,window-config)))
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
309 ,mapping)))
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
310
4674
e95ddfd6a409 In `set-window-configuration', don't restore frame size unconditionally.
Mike Sperber <sperber@deinprogramm.de>
parents: 4673
diff changeset
311 (defun set-window-configuration (configuration &optional set-frame-size-p)
4445
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
312 "Set the configuration of windows and buffers as specified by CONFIGURATION.
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
313 CONFIGURATION must be a value previously returned
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
314 by `current-window-configuration'.
4674
e95ddfd6a409 In `set-window-configuration', don't restore frame size unconditionally.
Mike Sperber <sperber@deinprogramm.de>
parents: 4673
diff changeset
315 If SET-FRAME-SIZE-P is true, the frame size is also restored.
e95ddfd6a409 In `set-window-configuration', don't restore frame size unconditionally.
Mike Sperber <sperber@deinprogramm.de>
parents: 4673
diff changeset
316 "
e95ddfd6a409 In `set-window-configuration', don't restore frame size unconditionally.
Mike Sperber <sperber@deinprogramm.de>
parents: 4673
diff changeset
317 (set-window-configuration/mapping configuration set-frame-size-p)
e95ddfd6a409 In `set-window-configuration', don't restore frame size unconditionally.
Mike Sperber <sperber@deinprogramm.de>
parents: 4673
diff changeset
318 nil) ; make sure nobody relies on mapping return value
e95ddfd6a409 In `set-window-configuration', don't restore frame size unconditionally.
Mike Sperber <sperber@deinprogramm.de>
parents: 4673
diff changeset
319
e95ddfd6a409 In `set-window-configuration', don't restore frame size unconditionally.
Mike Sperber <sperber@deinprogramm.de>
parents: 4673
diff changeset
320 (defun set-window-configuration/mapping (configuration &optional set-frame-size-p)
e95ddfd6a409 In `set-window-configuration', don't restore frame size unconditionally.
Mike Sperber <sperber@deinprogramm.de>
parents: 4673
diff changeset
321 "Set the configuration of windows and buffers as specified by CONFIGURATION.
e95ddfd6a409 In `set-window-configuration', don't restore frame size unconditionally.
Mike Sperber <sperber@deinprogramm.de>
parents: 4673
diff changeset
322 CONFIGURATION must be a value previously returned
e95ddfd6a409 In `set-window-configuration', don't restore frame size unconditionally.
Mike Sperber <sperber@deinprogramm.de>
parents: 4673
diff changeset
323 by `current-window-configuration'.
e95ddfd6a409 In `set-window-configuration', don't restore frame size unconditionally.
Mike Sperber <sperber@deinprogramm.de>
parents: 4673
diff changeset
324 If SET-FRAME-SIZE-P is true, the frame size is also restored.
4445
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
325 Return alist mapping old windows to new windows.
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
326 This alist maps the originally captured windows to the windows that correspond
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
327 to them in the restored configuration. It does not include entries for
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
328 windows that have not changed identity."
1149
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
329 (let ((frame (window-configuration-frame configuration)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
330 (if (and (frame-live-p frame)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
331 (not (window-configuration-equal configuration
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
332 (current-window-configuration))))
4674
e95ddfd6a409 In `set-window-configuration', don't restore frame size unconditionally.
Mike Sperber <sperber@deinprogramm.de>
parents: 4673
diff changeset
333 (really-set-window-configuration frame configuration set-frame-size-p))))
1149
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
334
4674
e95ddfd6a409 In `set-window-configuration', don't restore frame size unconditionally.
Mike Sperber <sperber@deinprogramm.de>
parents: 4673
diff changeset
335 (defun really-set-window-configuration (frame configuration set-frame-size-p)
4445
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
336 "Set the window configuration CONFIGURATION on live frame FRAME.
4674
e95ddfd6a409 In `set-window-configuration', don't restore frame size unconditionally.
Mike Sperber <sperber@deinprogramm.de>
parents: 4673
diff changeset
337 If SET-FRAME-SIZE-P is true, the frame size is also restored.
4445
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
338 Return alist mapping old windows to new windows."
1149
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
339 ;; avoid potential temporary problems
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
340 (setq window-min-width 0)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
341 (setq window-min-height 0)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
342 (setq minibuffer-scroll-window nil)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
343
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
344 (frame-reduce-to-one-window frame)
4674
e95ddfd6a409 In `set-window-configuration', don't restore frame size unconditionally.
Mike Sperber <sperber@deinprogramm.de>
parents: 4673
diff changeset
345 (if set-frame-size-p
e95ddfd6a409 In `set-window-configuration', don't restore frame size unconditionally.
Mike Sperber <sperber@deinprogramm.de>
parents: 4673
diff changeset
346 (set-window-configuration-frame-size configuration))
2888
469ce4fa0ade [xemacs-hg @ 2005-08-06 09:41:58 by michaels]
michaels
parents: 2885
diff changeset
347
4673
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
348 ;; avoid setting these if they're already up-to-date
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
349 ;; This also avoids potential inaccuracies in these settings --Mike
3646
b6287dbce5f0 [xemacs-hg @ 2006-10-31 09:16:27 by michaels]
michaels
parents: 2888
diff changeset
350 (when window-configuration-includes-position
b6287dbce5f0 [xemacs-hg @ 2006-10-31 09:16:27 by michaels]
michaels
parents: 2888
diff changeset
351 (let ((left (window-configuration-frame-left configuration))
4673
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
352 (top (window-configuration-frame-top configuration)))
3646
b6287dbce5f0 [xemacs-hg @ 2006-10-31 09:16:27 by michaels]
michaels
parents: 2888
diff changeset
353 (if (not (equal left (frame-property frame 'left)))
4673
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
354 (set-frame-property frame 'left left))
3646
b6287dbce5f0 [xemacs-hg @ 2006-10-31 09:16:27 by michaels]
michaels
parents: 2888
diff changeset
355 (if (not (equal top (frame-property frame 'top)))
4673
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
356 (set-frame-property frame 'top top))))
1149
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
357
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
358 ;; these may have changed because of the delete
4673
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
359 (set-window-pixel-height (minibuffer-window frame)
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
360 (window-configuration-minibuffer-pixel-height configuration))
1149
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
361
4673
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
362 ;; avoid that `set-window-point' will set the buffer's point for
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
363 ;; the selected window
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
364 (select-window (minibuffer-window frame))
1149
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
365
4673
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
366 (let ((window-configuration-current-window nil)
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
367 (mapping (list nil))) ; poor man's box
4445
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
368
4673
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
369 (declare (special window-configuration-current-window))
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
370 (restore-saved-window configuration
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
371 (frame-root-window frame)
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
372 (window-configuration-saved-root-window configuration)
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
373 'vertical
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
374 mapping)
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
375 (if window-configuration-current-window
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
376 (select-window window-configuration-current-window))
4445
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
377
4673
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
378 (setq window-min-width (window-configuration-min-width configuration))
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
379 (setq window-min-height (window-configuration-min-height configuration))
4445
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
380
4673
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
381 (let ((buffer (window-configuration-current-buffer configuration)))
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
382 (if (buffer-live-p buffer)
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
383 (set-buffer buffer)
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
384 (set-buffer (car (buffer-list)))))
4674
e95ddfd6a409 In `set-window-configuration', don't restore frame size unconditionally.
Mike Sperber <sperber@deinprogramm.de>
parents: 4673
diff changeset
385 ; this resets the window configuration so that the frame is filled
e95ddfd6a409 In `set-window-configuration', don't restore frame size unconditionally.
Mike Sperber <sperber@deinprogramm.de>
parents: 4673
diff changeset
386 (if (not set-frame-size-p)
e95ddfd6a409 In `set-window-configuration', don't restore frame size unconditionally.
Mike Sperber <sperber@deinprogramm.de>
parents: 4673
diff changeset
387 (set-frame-pixel-size frame (frame-pixel-width frame) (frame-pixel-height frame)))
4673
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
388 (car mapping)))
1149
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
389
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
390 (defun set-window-configuration-frame-size (configuration)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
391 "Restore the frame size of a window configuration."
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
392 (set-frame-pixel-size
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
393 (window-configuration-frame configuration)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
394 (window-configuration-frame-pixel-width configuration)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
395 (window-configuration-frame-pixel-height configuration)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
396
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
397 (defun frame-reduce-to-one-window (frame)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
398 "Delete all windows except the minibuffer and one other in FRAME."
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
399 (let* ((root-window (frame-root-window frame))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
400 (combination-start (or (window-first-hchild root-window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
401 (window-first-vchild root-window))))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
402 (if combination-start
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
403 (window-reduce-to-one combination-start))))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
404
1230
78781398fc4c [xemacs-hg @ 2003-01-23 10:09:41 by michaels]
michaels
parents: 1208
diff changeset
405 ;; Note that simply using `delete-other-windows' causes obscure
78781398fc4c [xemacs-hg @ 2003-01-23 10:09:41 by michaels]
michaels
parents: 1208
diff changeset
406 ;; breakage. --Mike
78781398fc4c [xemacs-hg @ 2003-01-23 10:09:41 by michaels]
michaels
parents: 1208
diff changeset
407
1149
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
408 (defun window-reduce-to-one (window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
409 "Make sure only one subwindow of WINDOW is left."
1230
78781398fc4c [xemacs-hg @ 2003-01-23 10:09:41 by michaels]
michaels
parents: 1208
diff changeset
410 (let ((window (window-next-child window)))
78781398fc4c [xemacs-hg @ 2003-01-23 10:09:41 by michaels]
michaels
parents: 1208
diff changeset
411 (while window
78781398fc4c [xemacs-hg @ 2003-01-23 10:09:41 by michaels]
michaels
parents: 1208
diff changeset
412 (if (window-live-p window)
78781398fc4c [xemacs-hg @ 2003-01-23 10:09:41 by michaels]
michaels
parents: 1208
diff changeset
413 (let ((next (window-next-child window)))
4444
715c3ced8fa8 Use `real-split-window', `real-delete-window' in window-config code.
Mike Sperber <sperber@deinprogramm.de>
parents: 4438
diff changeset
414 (real-delete-window window)
1230
78781398fc4c [xemacs-hg @ 2003-01-23 10:09:41 by michaels]
michaels
parents: 1208
diff changeset
415 (setq window next)))))
78781398fc4c [xemacs-hg @ 2003-01-23 10:09:41 by michaels]
michaels
parents: 1208
diff changeset
416 (cond
78781398fc4c [xemacs-hg @ 2003-01-23 10:09:41 by michaels]
michaels
parents: 1208
diff changeset
417 ((window-first-hchild window)
78781398fc4c [xemacs-hg @ 2003-01-23 10:09:41 by michaels]
michaels
parents: 1208
diff changeset
418 (window-reduce-to-one (window-first-hchild window)))
78781398fc4c [xemacs-hg @ 2003-01-23 10:09:41 by michaels]
michaels
parents: 1208
diff changeset
419 ((window-first-vchild window)
78781398fc4c [xemacs-hg @ 2003-01-23 10:09:41 by michaels]
michaels
parents: 1208
diff changeset
420 (window-reduce-to-one (window-first-vchild window)))))
1149
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
421
4445
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
422 (defun restore-saved-window (configuration window saved-window direction mapping)
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
423 "Within CONFIGURATION, restore WINDOW to the state of SAVED-WINDOW.
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
424 MAPPING is a one-element list whose element is an old-window-to-new-window
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
425 mapping, which this function will extend."
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
426 (if (not (eq (saved-window-window saved-window) window))
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
427 (rplaca mapping
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
428 (cons (cons (saved-window-window saved-window) window)
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
429 (car mapping))))
4438
2785829fe37c Fix window-configuration problem.
Mike Sperber <sperber@deinprogramm.de>
parents: 4136
diff changeset
430 (cond
2785829fe37c Fix window-configuration problem.
Mike Sperber <sperber@deinprogramm.de>
parents: 4136
diff changeset
431 ((and (saved-window-next-child saved-window)
2785829fe37c Fix window-configuration problem.
Mike Sperber <sperber@deinprogramm.de>
parents: 4136
diff changeset
432 (not (saved-window-minibufferp (saved-window-next-child saved-window))))
2785829fe37c Fix window-configuration problem.
Mike Sperber <sperber@deinprogramm.de>
parents: 4136
diff changeset
433 (cond ((eq direction 'vertical)
4444
715c3ced8fa8 Use `real-split-window', `real-delete-window' in window-config code.
Mike Sperber <sperber@deinprogramm.de>
parents: 4438
diff changeset
434 (real-split-window window nil nil))
4438
2785829fe37c Fix window-configuration problem.
Mike Sperber <sperber@deinprogramm.de>
parents: 4136
diff changeset
435 ((eq direction 'horizontal)
4444
715c3ced8fa8 Use `real-split-window', `real-delete-window' in window-config code.
Mike Sperber <sperber@deinprogramm.de>
parents: 4438
diff changeset
436 (real-split-window window nil t)))
4438
2785829fe37c Fix window-configuration problem.
Mike Sperber <sperber@deinprogramm.de>
parents: 4136
diff changeset
437 (if (not (saved-window-minibufferp saved-window))
2785829fe37c Fix window-configuration problem.
Mike Sperber <sperber@deinprogramm.de>
parents: 4136
diff changeset
438 (restore-saved-window-parameters configuration window saved-window))
2785829fe37c Fix window-configuration problem.
Mike Sperber <sperber@deinprogramm.de>
parents: 4136
diff changeset
439 (restore-saved-window configuration
2785829fe37c Fix window-configuration problem.
Mike Sperber <sperber@deinprogramm.de>
parents: 4136
diff changeset
440 (window-next-child window)
2785829fe37c Fix window-configuration problem.
Mike Sperber <sperber@deinprogramm.de>
parents: 4136
diff changeset
441 (saved-window-next-child saved-window)
4445
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
442 direction
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
443 mapping))
4438
2785829fe37c Fix window-configuration problem.
Mike Sperber <sperber@deinprogramm.de>
parents: 4136
diff changeset
444 ((not (saved-window-minibufferp saved-window))
2785829fe37c Fix window-configuration problem.
Mike Sperber <sperber@deinprogramm.de>
parents: 4136
diff changeset
445 (restore-saved-window-parameters configuration window saved-window)))
1149
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
446
1576
bd921b813d33 [xemacs-hg @ 2003-07-17 14:41:23 by james]
james
parents: 1387
diff changeset
447 (if (saved-window-first-hchild saved-window)
bd921b813d33 [xemacs-hg @ 2003-07-17 14:41:23 by james]
james
parents: 1387
diff changeset
448 (restore-saved-window configuration
bd921b813d33 [xemacs-hg @ 2003-07-17 14:41:23 by james]
james
parents: 1387
diff changeset
449 window
bd921b813d33 [xemacs-hg @ 2003-07-17 14:41:23 by james]
james
parents: 1387
diff changeset
450 (saved-window-first-hchild saved-window)
4445
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
451 'horizontal
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
452 mapping))
1576
bd921b813d33 [xemacs-hg @ 2003-07-17 14:41:23 by james]
james
parents: 1387
diff changeset
453 (if (saved-window-first-vchild saved-window)
bd921b813d33 [xemacs-hg @ 2003-07-17 14:41:23 by james]
james
parents: 1387
diff changeset
454 (restore-saved-window configuration
bd921b813d33 [xemacs-hg @ 2003-07-17 14:41:23 by james]
james
parents: 1387
diff changeset
455 window
bd921b813d33 [xemacs-hg @ 2003-07-17 14:41:23 by james]
james
parents: 1387
diff changeset
456 (saved-window-first-vchild saved-window)
4445
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
457 'vertical
1d41b9bcf74f Add `set-window-configuration/mapping' and `save-window-excursion/mapping'.
Mike Sperber <sperber@deinprogramm.de>
parents: 4444
diff changeset
458 mapping)))
1149
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
459
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
460 (defun restore-saved-window-parameters (configuration window saved-window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
461 "Restore the window parameters stored in SAVED-WINDOW on WINDOW."
1261
465bd3c7d932 [xemacs-hg @ 2003-02-06 06:35:47 by ben]
ben
parents: 1230
diff changeset
462 (declare (special window-configuration-current-window))
1149
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
463 (let ((buffer (saved-window-buffer saved-window)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
464 (if (and buffer (buffer-live-p buffer))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
465 (progn
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
466 (set-window-buffer window
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
467 (saved-window-buffer saved-window))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
468 (set-window-start window
1161
8e95979f01c6 [xemacs-hg @ 2002-12-16 02:32:47 by ben]
ben
parents: 1149
diff changeset
469 (marker-position (saved-window-start-marker saved-window))
8e95979f01c6 [xemacs-hg @ 2002-12-16 02:32:47 by ben]
ben
parents: 1149
diff changeset
470 t)
4136
db22824aa020 [xemacs-hg @ 2007-08-22 07:15:24 by michaels]
michaels
parents: 3646
diff changeset
471 (if (markerp (saved-window-point-marker saved-window))
db22824aa020 [xemacs-hg @ 2007-08-22 07:15:24 by michaels]
michaels
parents: 3646
diff changeset
472 (set-window-point window
db22824aa020 [xemacs-hg @ 2007-08-22 07:15:24 by michaels]
michaels
parents: 3646
diff changeset
473 (marker-position (saved-window-point-marker saved-window))))
1149
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
474 (set-marker (mark-marker t buffer)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
475 (marker-position (saved-window-mark-marker saved-window))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
476 buffer)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
477 (if (not (eq buffer (window-configuration-current-buffer configuration)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
478 (goto-char (window-point window) buffer)))))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
479
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
480 (if (and (not (saved-window-first-hchild saved-window))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
481 (not (saved-window-first-vchild saved-window)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
482 ;; only set size for non-container windows
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
483 (progn
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
484 ;; If this is the root window, it may be the only window.
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
485 ;; Because of mismatches between actual and reported frame
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
486 ;; size, it may not let us actually set the size of the root
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
487 ;; window to what we want. --Mike
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
488 (if (not (eq window (frame-root-window (window-frame window))))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
489 (progn
4673
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
490 (set-window-pixel-width window
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
491 (saved-window-pixel-width saved-window))
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
492 (set-window-pixel-height window
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
493 (saved-window-pixel-height saved-window))))
1149
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
494 (set-window-hscroll window (saved-window-hscroll saved-window))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
495 (set-modeline-hscroll window
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
496 (saved-window-modeline-hscroll saved-window))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
497 (set-window-dedicated-p window (saved-window-dedicatedp saved-window))))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
498
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
499 (if (saved-window-currentp saved-window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
500 (setq window-configuration-current-window window))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
501 (if (saved-window-minibuffer-scrollp saved-window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
502 (setq minibuffer-scroll-window window)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
503
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
504 (defun saved-window-pixel-width (saved-window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
505 "Compute the pixel width of SAVED-WINDOW."
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
506 (- (saved-window-pixel-right saved-window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
507 (saved-window-pixel-left saved-window)))
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
508
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
509 (defun saved-window-pixel-height (saved-window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
510 "Compute the pixel height of SAVED-WINDOW."
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
511 (- (saved-window-pixel-bottom saved-window)
a123f88fa975 [xemacs-hg @ 2002-12-08 10:24:33 by michaels]
michaels
parents: 903
diff changeset
512 (saved-window-pixel-top saved-window)))
4673
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
513
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
514 (defun set-window-pixel-width (window width)
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
515 "Set the pixel width of WINDOW."
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
516 (enlarge-window-pixels (- width (window-pixel-width window)) t window))
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
517
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
518 (defun set-window-pixel-height (window height)
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
519 "Set the pixel height of WINDOW."
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
520 (enlarge-window-pixels (- height (window-pixel-height window)) nil window))
11d71be1c232 Add `set-window-pixel-{width,height} convenience functions.
Mike Sperber <sperber@deinprogramm.de>
parents: 4445
diff changeset
521
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 ;; The window-config stack is stored as a list in frame property
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 ;; 'window-config-stack, with the most recent element at the front.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 ;; 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
526 ;; front of frame property 'window-config-unpop-stack, so you can
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 ;; retrieve it using unpop-window-configuration.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 (defcustom window-config-stack-max 16
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 "*Maximum size of window configuration stack.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 Start discarding off end if it gets this big."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 :type 'integer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 :group 'windows)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 (defun window-config-stack (&optional frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 (or frame (setq frame (selected-frame)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 (let ((stack (frame-property frame 'window-config-stack)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 (if stack
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 (set-undoable-stack-max stack window-config-stack-max)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 (setq stack (make-undoable-stack window-config-stack-max))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 (set-frame-property frame 'window-config-stack stack)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 stack))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 (defun push-window-configuration (&optional config)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 "Push the current window configuration onto the window-config stack.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 If CONFIG is specified, push it instead of the current window configuration.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 Each frame has its own window-config stack."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 (let ((wc (or config (current-window-configuration)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 (stack (window-config-stack)))
5366
f00192e1cd49 Examining the result of #'length: `eql', not `=', it's better style & cheaper
Aidan Kehoe <kehoea@parhasard.net>
parents: 4674
diff changeset
552 (if (or (eql 0 (undoable-stack-a-length stack))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 (not (equal (undoable-stack-a-top stack) wc)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 (undoable-stack-push stack wc))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 (defun pop-window-configuration ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 "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
558 Before setting the new window configuration, the current window configuration
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 is pushed onto the \"unpop\" stack.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 `unpop-window-configuration' undoes what this function does.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 Each frame has its own window-config and \"unpop\" stack."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 (let ((stack (window-config-stack))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 (wc (current-window-configuration))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 popped)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 (condition-case nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 (setq popped (undoable-stack-pop stack))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 (while (equal popped wc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 (setq popped (undoable-stack-pop stack)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 (undoable-stack-push stack wc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 (undoable-stack-undo stack)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 (set-window-configuration popped)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 popped)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 (trunc-stack-bottom
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 (error "Bottom of window config stack")))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 (defun unpop-window-configuration ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 "Undo the effect of the most recent `pop-window-configuration'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 This does exactly the inverse of what `pop-window-configuration' does:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 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
582 pushes the current window configuration onto the window-config stack.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 Each frame has its own window-config and \"unpop\" stack."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 (let ((stack (window-config-stack))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 (wc (current-window-configuration))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 popped)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 (condition-case nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 (setq popped
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 (undoable-stack-redo stack)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 (undoable-stack-pop stack)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 (while (equal popped wc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 (setq popped
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 (undoable-stack-redo stack)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 (undoable-stack-pop stack))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 (undoable-stack-push stack wc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 (set-window-configuration popped)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 popped)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 (trunc-stack-bottom
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 (error "Top of window config stack")))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 ;;;;;;;;;;;;; display-buffer, moved here from C. Hallelujah.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
608 (make-variable-buffer-local '__buffer-dedicated-frame)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
609
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
610 (defun buffer-dedicated-frame (&optional buffer)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
611 "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
612 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
613 (let ((buffer (decode-buffer buffer)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
614 (let ((frame (symbol-value-in-buffer '__buffer-dedicated-frame buffer)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
615 ;; 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
616 (when (and (framep frame) (not (frame-live-p frame)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
617 (with-current-buffer buffer
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
618 (setq __buffer-dedicated-frame nil))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
619 (setq frame nil))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
620 frame)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
621
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
622 (defun set-buffer-dedicated-frame (buffer frame)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
623 "For this BUFFER, set the FRAME dedicated to it.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
624 FRAME must be a frame or nil."
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
625 (let ((buffer (decode-buffer buffer)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
626 (and frame
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
627 (check-argument-type #'frame-live-p frame))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
628 (with-current-buffer buffer
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
629 (setq __buffer-dedicated-frame frame))))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
630
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 (defvar display-buffer-function nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 "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
633 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
634
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 (defvar pre-display-buffer-function nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 "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
637 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
638 to `display-buffer'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 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
640 for example. See also the variable `display-buffer-function', which may
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 be used to completely replace the `display-buffer' function.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 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
643 and that frame will be used to display the buffer.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 (defcustom pop-up-frames nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 "*Non-nil means `display-buffer' should make a separate frame."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 :type 'boolean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 :group 'frames)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 (defvar pop-up-frame-function nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 "Function to call to handle automatic new frame creation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 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
653
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 A typical value might be `(lambda () (new-frame pop-up-frame-alist))'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 where `pop-up-frame-alist' would hold the default frame parameters.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 (defcustom special-display-buffer-names nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 "*List of buffer names that should have their own special frames.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 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
660 using `special-display-function'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 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
663 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
664 parameters for creating the frame for that buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 More precisely, the cdr is passed as the second argument to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 the function found in `special-display-function', when making that frame.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 See also `special-display-regexps'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668 :type '(repeat (choice :value ""
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669 (string :tag "Name")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670 (cons :menu-tag "Properties"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 :value ("" . nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 (string :tag "Name")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 (repeat :tag "Properties"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 (group :inline t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 (symbol :tag "Property")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 (sexp :tag "Value"))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 :group 'frames)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 (defcustom special-display-regexps nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680 "*List of regexps saying which buffers should have their own special frames.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681 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
682 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
683 using `special-display-function'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685 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
686 Then the car should be the regexp, and the cdr specifies frame
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687 parameters for creating the frame for buffers that match.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 More precisely, the cdr is passed as the second argument to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 the function found in `special-display-function', when making that frame.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 See also `special-display-buffer-names'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 :type '(repeat (choice :value ""
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692 regexp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 (cons :menu-tag "Properties"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694 :value ("" . nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695 regexp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696 (repeat :tag "Properties"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697 (group :inline t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698 (symbol :tag "Property")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 (sexp :tag "Value"))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700 :group 'frames)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702 (defvar special-display-function nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703 "Function to call to make a new frame for a special buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704 It is called with two arguments, the buffer and optional buffer specific
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705 data, and should return a window displaying that buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 The default value makes a separate frame for the buffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 using `special-display-frame-alist' to specify the frame parameters.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709 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
710 or matches a regexp in `special-display-regexps'.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 (defcustom same-window-buffer-names nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 "*List of buffer names that should appear in the selected window.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714 Displaying one of these buffers using `display-buffer' or `pop-to-buffer'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715 switches to it in the selected window, rather than making it appear
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 in some other window.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 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
719 Then the car must be a string, which specifies the buffer name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720 This is for compatibility with `special-display-buffer-names';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721 the cdr of the cons cell is ignored.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 See also `same-window-regexps'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724 :type '(repeat (string :tag "Name"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 :group 'windows)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 (defcustom same-window-regexps nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728 "*List of regexps saying which buffers should appear in the selected window.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 If a buffer name matches one of these regexps, then displaying it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 using `display-buffer' or `pop-to-buffer' switches to it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731 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
732
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 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
734 Then the car must be a string, which specifies the buffer name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735 This is for compatibility with `special-display-buffer-names';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736 the cdr of the cons cell is ignored.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738 See also `same-window-buffer-names'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 :type '(repeat regexp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740 :group 'windows)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742 (defcustom pop-up-windows t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743 "*Non-nil means display-buffer should make new windows."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744 :type 'boolean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745 :group 'windows)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747 (defcustom split-height-threshold 500
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
748 "*display-buffer would prefer to split the largest window if this large.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749 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
750 :type 'integer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751 :group 'windows)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753 (defcustom split-width-threshold 500
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754 "*display-buffer would prefer to split the largest window if this large.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755 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
756 :type 'integer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757 :group 'windows)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759 ;; Deiconify the frame containing the window WINDOW, then return WINDOW.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761 (defun display-buffer-1 (window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762 (if (frame-iconified-p (window-frame window))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763 (make-frame-visible (window-frame window)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764 window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
765
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766 ;; Can you believe that all of this crap was formerly in C?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767 ;; Praise Jesus that it's not there any more.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 444
diff changeset
769 (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
770 shrink-to-fit)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771 "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
772 BUFFER can be a buffer or a buffer name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773 If BUFFER is shown already in some window in the current frame,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774 just uses that one, unless the window is the selected window and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 NOT-THIS-WINDOW-P is non-nil (interactively, with prefix arg).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777 If BUFFER has a dedicated frame, display on that frame instead of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
778 the current frame, unless OVERRIDE-FRAME is non-nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780 If OVERRIDE-FRAME is non-nil, display on that frame instead of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
781 the current frame (or the dedicated frame).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
782
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 444
diff changeset
783 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
784 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
785
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786 If `pop-up-windows' is non-nil, always use the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
787 current frame and create a new window regardless of whether the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
788 buffer has a dedicated frame, and regardless of whether
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789 OVERRIDE-FRAME was specified.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791 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
792
2590
627e25731054 [xemacs-hg @ 2005-02-16 11:07:29 by aidan]
aidan
parents: 2227
diff changeset
793 If the buffer name is a member of the `same-window-buffer-names' list,
627e25731054 [xemacs-hg @ 2005-02-16 11:07:29 by aidan]
aidan
parents: 2227
diff changeset
794 or matches one of the `same-window-regexps' expressions, display the
627e25731054 [xemacs-hg @ 2005-02-16 11:07:29 by aidan]
aidan
parents: 2227
diff changeset
795 buffer in the currently selected window.
627e25731054 [xemacs-hg @ 2005-02-16 11:07:29 by aidan]
aidan
parents: 2227
diff changeset
796
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
797 Returns the window displaying BUFFER."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798 (interactive "BDisplay buffer:\nP")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800 (let ((wconfig (current-window-configuration))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801 (result
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802 ;; We just simulate a `return' in C. This function is way ugly
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
803 ;; and does `returns' all over the place and there's no sense
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
804 ;; in trying to rewrite it to be more Lispy.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
805 (catch 'done
1669
c5f86842283a [xemacs-hg @ 2003-09-07 19:46:30 by adrian]
adrian
parents: 1576
diff changeset
806 (let (window old-frame target-frame explicit-frame shrink-it)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
807 (setq old-frame (or (last-nonminibuf-frame) (selected-frame)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
808 (setq buffer (get-buffer buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
809 (check-argument-type 'bufferp buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
810
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
811 (setq explicit-frame
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
812 (if pre-display-buffer-function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
813 (funcall pre-display-buffer-function buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
814 not-this-window-p
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 444
diff changeset
815 override-frame
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 444
diff changeset
816 shrink-to-fit)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818 ;; Give the user the ability to completely reimplement
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
819 ;; this function via the `display-buffer-function'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
820 (if display-buffer-function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
821 (throw 'done
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
822 (funcall display-buffer-function buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
823 not-this-window-p
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 444
diff changeset
824 override-frame
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 444
diff changeset
825 shrink-to-fit)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
826
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
827 ;; If the buffer has a dedicated frame, that takes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
828 ;; precedence over the current frame, and over what the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
829 ;; pre-display-buffer-function did.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830 (let ((dedi (buffer-dedicated-frame buffer)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
831 (if (frame-live-p dedi) (setq explicit-frame dedi)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
832
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
833 ;; if override-frame is supplied, that takes precedence over
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
834 ;; everything. This is gonna look bad if the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
835 ;; pre-display-buffer-function raised some other frame
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
836 ;; already.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
837 (if override-frame
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
838 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839 (check-argument-type 'frame-live-p override-frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
840 (setq explicit-frame override-frame)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
841
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
842 (setq target-frame
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
843 (or explicit-frame
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
844 (last-nonminibuf-frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
845 (selected-frame)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
846
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847 ;; If we have switched frames, then set not-this-window-p
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848 ;; to false. Switching frames means that selected-window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
849 ;; 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
850 ;; selected-window of target_frame instead of old_frame,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
851 ;; so it's a fine candidate for display.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
852 (if (not (eq old-frame target-frame))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
853 (setq not-this-window-p nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
855 ;; 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
856 (if (and (not not-this-window-p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
857 (eq buffer (window-buffer (selected-window))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
858 (throw 'done (display-buffer-1 (selected-window))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
859
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
860 ;; See if the user has specified this buffer should appear
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
861 ;; in the selected window.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
863 (if not-this-window-p
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
864 nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
866 (if (or (member (buffer-name buffer) same-window-buffer-names)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
867 (assoc (buffer-name buffer) same-window-buffer-names))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
868 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
869 (switch-to-buffer buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
870 (throw 'done (display-buffer-1 (selected-window)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
872 (let ((tem same-window-regexps))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
873 (while tem
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
874 (let ((car (car tem)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875 (if (or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
876 (and (stringp car)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
877 (string-match car (buffer-name buffer)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
878 (and (consp car) (stringp (car car))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
879 (string-match (car car) (buffer-name buffer))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
880 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
881 (switch-to-buffer buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
882 (throw 'done (display-buffer-1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883 (selected-window))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
884 (setq tem (cdr tem)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
885
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886 ;; If pop-up-frames, look for a window showing BUFFER on
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887 ;; any visible or iconified frame. Otherwise search only
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
888 ;; the current frame.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
889 (if (and (not explicit-frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
890 (or pop-up-frames (not (last-nonminibuf-frame))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
891 (setq target-frame 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
892
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
893 ;; Otherwise, find some window that it's already in, and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
894 ;; return that, unless that window is the selected window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
895 ;; and that isn't ok. What a contorted mess!
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
896 (setq window (or (if (not explicit-frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
897 ;; search the selected frame
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
898 ;; first if the user didn't
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
899 ;; specify an explicit frame.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
900 (get-buffer-window buffer nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
901 (get-buffer-window buffer target-frame)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
902 (if (and window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
903 (or (not not-this-window-p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
904 (not (eq window (selected-window)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905 (throw 'done (display-buffer-1 window)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
906
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907 ;; Certain buffer names get special handling.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
908 (if special-display-function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
910 (if (member (buffer-name buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
911 special-display-buffer-names)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
912 (throw 'done (funcall special-display-function buffer)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
914 (let ((tem (assoc (buffer-name buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
915 special-display-buffer-names)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916 (if tem
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
917 (throw 'done (funcall special-display-function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
918 buffer (cdr tem)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
920 (let ((tem special-display-regexps))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921 (while tem
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
922 (let ((car (car tem)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
923 (if (and (stringp car)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
924 (string-match car (buffer-name buffer)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
925 (throw 'done
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
926 (funcall special-display-function buffer)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
927 (if (and (consp car)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
928 (stringp (car car))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
929 (string-match (car car)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
930 (buffer-name buffer)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
931 (throw 'done (funcall
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
932 special-display-function buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
933 (cdr car)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
934 (setq tem (cdr tem))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
935
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936 ;; If there are no frames open that have more than a minibuffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937 ;; we need to create a new frame.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
938 (if (or pop-up-frames
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
939 (null (last-nonminibuf-frame)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
940 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
941 (setq window (frame-selected-window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
942 (funcall pop-up-frame-function)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
943 (set-window-buffer window buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
944 (throw 'done (display-buffer-1 window))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
945
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
946 ;; Otherwise, make it be in some window, splitting if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
947 ;; appropriate/possible. Do not split a window if we are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
948 ;; displaying the buffer in a different frame than that which
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
949 ;; was current when we were called. (It is already in a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
950 ;; different window by virtue of being in another frame.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
951 (if (or (and pop-up-windows (eq target-frame old-frame))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
952 (eq 'only (frame-property (selected-frame) 'minibuffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
953 ;; If the current frame is a special display frame,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
954 ;; don't try to reuse its windows.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
955 (window-dedicated-p (frame-root-window (selected-frame))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
956 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
957 (if (eq 'only (frame-property (selected-frame) 'minibuffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
958 (setq target-frame (last-nonminibuf-frame)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
959
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
960 ;; 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
961 ;; height.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
962 (if (< split-height-threshold (* 2 window-min-height))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
963 (setq split-height-threshold (* 2 window-min-height)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
964
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
965 ;; Same with width.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
966 (if (< split-width-threshold (* 2 window-min-width))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
967 (setq split-width-threshold (* 2 window-min-width)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
968
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
969 ;; If the frame we would try to split cannot be split,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
970 ;; try other frames.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
971 (if (frame-property (if (null target-frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
972 (selected-frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
973 (last-nonminibuf-frame))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
974 'unsplittable)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
975 (setq window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
976 ;; Try visible frames first.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
977 (or (get-largest-window 'visible)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
978 ;; If that didn't work, try iconified frames.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
979 (get-largest-window 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
980 (get-largest-window t)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
981 (setq window (get-largest-window target-frame)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
982
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
983 ;; If we got a tall enough full-width window that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
984 ;; can be split, split it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
985 (if (and window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
986 (not (frame-property (window-frame window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
987 'unsplittable))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
988 (>= (window-height window) split-height-threshold)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
989 (or (>= (window-width window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
990 split-width-threshold)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
991 (and (window-leftmost-p window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
992 (window-rightmost-p window))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
993 (setq window (split-window window))
1669
c5f86842283a [xemacs-hg @ 2003-09-07 19:46:30 by adrian]
adrian
parents: 1576
diff changeset
994 (let (upper other)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
995 (setq window (get-lru-window target-frame))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
996 ;; If the LRU window is selected, and big enough,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
997 ;; and can be split, split it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
998 (if (and window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
999 (not (frame-property (window-frame window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1000 'unsplittable))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1001 (or (eq window (selected-window))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1002 (not (window-parent window)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1003 (>= (window-height window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1004 (* 2 window-min-height)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1005 (setq window (split-window window)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1006 ;; If get-lru-window returned nil, try other approaches.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1007 ;; Try visible frames first.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1008 (or window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1009 (setq window (or (get-largest-window 'visible)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1010 ;; If that didn't work, try
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1011 ;; iconified frames.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1012 (get-largest-window 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1013 ;; Try invisible frames.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1014 (get-largest-window t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1015 ;; As a last resort, make
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1016 ;; a new frame.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1017 (frame-selected-window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1018 (funcall
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1019 pop-up-frame-function)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1020 ;; If window appears above or below another,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1021 ;; even out their heights.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1022 (if (window-previous-child window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1023 (setq other (window-previous-child window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1024 upper other))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1025 (if (window-next-child window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1026 (setq other (window-next-child window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1027 upper window))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1028 ;; Check that OTHER and WINDOW are vertically arrayed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1029 (if (and other
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1030 (not (= (nth 1 (window-pixel-edges other))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1031 (nth 1 (window-pixel-edges window))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1032 (> (window-pixel-height other)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1033 (window-pixel-height window)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1034 (enlarge-window (- (/ (+ (window-height other)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1035 (window-height window))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1036 2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1037 (window-height upper))
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 444
diff changeset
1038 nil upper))
1669
c5f86842283a [xemacs-hg @ 2003-09-07 19:46:30 by adrian]
adrian
parents: 1576
diff changeset
1039 ;; Klaus Berndl <klaus.berndl@sdm.de>: Only in
c5f86842283a [xemacs-hg @ 2003-09-07 19:46:30 by adrian]
adrian
parents: 1576
diff changeset
1040 ;; this situation we shrink-to-fit but we can do
c5f86842283a [xemacs-hg @ 2003-09-07 19:46:30 by adrian]
adrian
parents: 1576
diff changeset
1041 ;; this first after we have displayed buffer in
c5f86842283a [xemacs-hg @ 2003-09-07 19:46:30 by adrian]
adrian
parents: 1576
diff changeset
1042 ;; window (s.b. (set-window-buffer window buffer))
c5f86842283a [xemacs-hg @ 2003-09-07 19:46:30 by adrian]
adrian
parents: 1576
diff changeset
1043 (setq shrink-it shrink-to-fit))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1044
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1045 (setq window (get-lru-window target-frame)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1046
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1047 ;; 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
1048 (if (window-buffer window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1049 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1050 (save-selected-window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1051 (select-window window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1052 (record-buffer (window-buffer window)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1053
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1054 (set-window-buffer window buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1055
1669
c5f86842283a [xemacs-hg @ 2003-09-07 19:46:30 by adrian]
adrian
parents: 1576
diff changeset
1056 ;; Now window's previous buffer has been brought to the top
c5f86842283a [xemacs-hg @ 2003-09-07 19:46:30 by adrian]
adrian
parents: 1576
diff changeset
1057 ;; of the MRU chain and window displays buffer - now we can
c5f86842283a [xemacs-hg @ 2003-09-07 19:46:30 by adrian]
adrian
parents: 1576
diff changeset
1058 ;; shrink-to-fit if necessary
c5f86842283a [xemacs-hg @ 2003-09-07 19:46:30 by adrian]
adrian
parents: 1576
diff changeset
1059 (if shrink-it
c5f86842283a [xemacs-hg @ 2003-09-07 19:46:30 by adrian]
adrian
parents: 1576
diff changeset
1060 (shrink-window-if-larger-than-buffer window))
c5f86842283a [xemacs-hg @ 2003-09-07 19:46:30 by adrian]
adrian
parents: 1576
diff changeset
1061
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1062 (display-buffer-1 window)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1063 (or (equal wconfig (current-window-configuration))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1064 (push-window-configuration wconfig))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1065 result))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1066
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1067 ;;; window-xemacs.el ends here