Source

xemacs-beta / lisp / window-xemacs.el

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
;;; window-xemacs.el --- XEmacs window commands aside from those written in C.

;; Copyright (C) 1985, 1989, 1993-94, 1997, 2012 Free Software Foundation, Inc.
;; Copyright (C) 1995, 1996 Ben Wing.

;; Maintainer: XEmacs Development Team
;; Keywords: frames, extensions, dumped

;; This file is part of XEmacs.

;; XEmacs is free software: you can redistribute it and/or modify it
;; under the terms of the GNU General Public License as published by the
;; Free Software Foundation, either version 3 of the License, or (at your
;; option) any later version.

;; XEmacs is distributed in the hope that it will be useful, but WITHOUT
;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
;; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
;; for more details.

;; You should have received a copy of the GNU General Public License
;; along with XEmacs.  If not, see <http://www.gnu.org/licenses/>.

;;; Synched up with: Not synched except for partial sync of
;;; recenter-top-bottom

;;; Commentary:

;; This file is dumped with XEmacs.

;; slb - 5/29/97
;; Split apart from window.el in order to keep that file better in synch
;; with Emacs.

;;; Code:

(defgroup windows nil
  "Windows within a frame."
  :group 'environment)

(defun recenter (&optional n window)
  "Center point in WINDOW and redisplay frame.  With N, put point on line N.
The desired position of point is always relative to the window.
Just C-u as prefix means put point in the center of the window.
No N (i.e., it is nil) erases the entire frame and then
redraws with point in the center of the window.
If WINDOW is nil, the selected window is used."
  (interactive "_P")
  (center-to-window-line (if (consp n) nil n) window)
  (when (null n)
    (redraw-frame (window-frame window) t)))

(defvar recenter-last-op nil
  "Indicates the last recenter operation performed.
Possible values: `top', `middle', `bottom', integer or float numbers.")

;; Merged from FSF 23.2 with use of scroll-margin for top and bottom
;; destinations removed. We don't support scroll-margin.
(defcustom recenter-positions '(middle top bottom)
  "Cycling order for `recenter-top-bottom'.
A list of elements with possible values `top', `middle', `bottom',
integer or float numbers that define the cycling order for
the command `recenter-top-bottom'.

Top and bottom destinations are the window top and bottom.  Middle
redraws the frame and centers point vertically within the window.
Integer number moves current line to the specified absolute
window-line.  Float number between 0.0 and 1.0 means the percentage of
the screen space from the top.  The default cycling order is middle ->
top -> bottom."
  :type '(repeat (choice
		  (const :tag "Top" top)
		  (const :tag "Middle" middle)
		  (const :tag "Bottom" bottom)
		  (integer :tag "Line number")
		  (float :tag "Percentage")))
  :version "23.2"
  :group 'windows)

(defun recenter-top-bottom (&optional arg)
  "Move current buffer line to the specified window line.
With no prefix argument, successive calls place point according
to the cycling order defined by `recenter-positions'.

A prefix argument is handled like `recenter':
 With numeric prefix ARG, move current line to window-line ARG.
 With plain `C-u', move current line to window center."
  (interactive "P")
  (cond
   (arg (recenter arg))			; Always respect ARG.
   (t
    (setq recenter-last-op
	  (if (eq this-command last-command)
	      (car (or (cdr (member recenter-last-op recenter-positions))
		       recenter-positions))
	    (car recenter-positions)))
    (cond ((eq recenter-last-op 'middle)
	   (recenter))
	  ((eq recenter-last-op 'top)
	   (recenter 0))
	  ((eq recenter-last-op 'bottom)
	   (recenter -1))
	  ((integerp recenter-last-op)
	   (recenter recenter-last-op))
	  ((floatp recenter-last-op)
	   (recenter (round (* recenter-last-op (window-height)))))))))

(defun backward-other-window (count &optional which-frames which-devices)
  "Select the COUNT'th different window on this frame, going backwards.
This is just like calling `other-window' with COUNT negated."
  (interactive "p")
  (other-window (- count) which-frames which-devices))

(defalias 'windows-of-buffer 'get-buffer-window-list)

(defun buffer-in-multiple-windows-p (&optional buffer)
  "Return t if BUFFER is in multiple windows.
If BUFFER is not specified, the current buffer will be used."
  (setq buffer (or buffer
		   (get-buffer buffer)
		   (get-file-buffer buffer)
		   (current-buffer)))
  (> (length (windows-of-buffer buffer)) 1))

(defun window-list (&optional frame minibuf window)
  "Return a list of windows on FRAME, beginning with WINDOW.
FRAME and WINDOW default to the selected ones.
Optional second arg MINIBUF t means count the minibuffer window
even if not active.  If MINIBUF is neither t nor nil it means
not to count the minibuffer even if it is active."
  (setq frame (or frame (selected-frame))
	window (or window (selected-window frame)))
  (if (not (eq (window-frame window) frame))
      (error "Window must be on frame."))
  (let ((current-frame (selected-frame))
	list)
    (unwind-protect
	(save-window-excursion
	  (select-frame frame)
	  (walk-windows
	   (function (lambda (cur-window)
		       (if (not (eq window cur-window))
			   (setq list (cons cur-window list)))))
	   minibuf)
	  (setq list (cons window list)))
      (select-frame current-frame))))

;; We used to have set-window-dedicated-p as an obsolete version
;; of set-window-buffer-dedicated, but it really makes more sense
;; this way.

(make-obsolete 'set-window-buffer-dedicated 'set-window-dedicated-p)
(defun set-window-buffer-dedicated (window buffer)
  "Make WINDOW display BUFFER and be dedicated to that buffer.
Then Emacs will not automatically change which buffer appears in WINDOW.
If BUFFER is nil, make WINDOW not be dedicated (but don't change which
buffer appears in it currently)."
  (if (bufferp buffer)
      (set-window-buffer window (get-buffer-create buffer)))
  (set-window-dedicated-p window (not (null buffer))))

;; Window configurations

(defcustom window-configuration-includes-position nil
  "*Whether restoring window configurations will restore positions too.
If nil, only the size of windows will be restored.

Note that setting this value to t may have counterintuitive consequences,
if a window manager employing virtual desktops is in use."
:type 'boolean
:group 'windows)

(defstruct saved-window
  currentp minibufferp minibuffer-scrollp
  buffer mark-marker
  start-marker
  point-marker
  pixel-left pixel-top pixel-right pixel-bottom
  hscroll modeline-hscroll
  dedicatedp
  first-hchild first-vchild next-child
  window)

(defstruct window-configuration
  frame
  frame-top frame-left
  frame-pixel-width frame-pixel-height
  current-buffer
  minibuffer-pixel-height
  min-width min-height
  saved-root-window)

; make sure we don't get affected by harmful advice
(fset 'real-split-window (symbol-function 'split-window))
(fset 'real-delete-window (symbol-function 'delete-window))

(defun window-configuration-equal (conf-1 conf-2)
  "Returns a boolean indicating whether the two given configurations
are identical.

Window configurations containing windows with different window
positions are not identical iff `window-configuration-includes-position'
is t."
  (or (eq conf-1 conf-2)
      (and (eq (window-configuration-frame conf-1)
	       (window-configuration-frame conf-2))
	   (= (window-configuration-frame-pixel-width conf-1)
	      (window-configuration-frame-pixel-width conf-2))
	   (= (window-configuration-frame-pixel-height conf-1)
	      (window-configuration-frame-pixel-height conf-2))
	   (if window-configuration-includes-position
               (and (equal (window-configuration-frame-top conf-1)
                           (window-configuration-frame-top conf-2))
                    (equal (window-configuration-frame-left conf-1)
                           (window-configuration-frame-left conf-2)))
             t)
	   (eq (window-configuration-current-buffer conf-1)
	       (window-configuration-current-buffer conf-2))
	   (saved-window-equal (window-configuration-saved-root-window conf-1)
			       (window-configuration-saved-root-window conf-2)))))

(defun saved-window-equal (saved-1 saved-2)
  "Returns a boolean indicating whether the two given saved windows
are identical."
  (or (eq saved-1 saved-2)
      (and (eq (saved-window-currentp saved-1)
	       (saved-window-currentp saved-2))
	   (eq (saved-window-minibuffer-scrollp saved-1)
	       (saved-window-minibuffer-scrollp saved-2))
	   (eq (saved-window-buffer saved-1)
	       (saved-window-buffer saved-2))
	   (equal (saved-window-mark-marker saved-1)
		  (saved-window-mark-marker saved-2))
	   (or (and (saved-window-currentp saved-1)
		    (saved-window-currentp saved-2))
	       (equal (saved-window-start-marker saved-1)
		      (saved-window-start-marker saved-2)))
	   (or (and (saved-window-currentp saved-1)
		    (saved-window-currentp saved-2))
	       (equal (saved-window-point-marker saved-1)
		      (saved-window-point-marker saved-2)))
	   (= (saved-window-pixel-left saved-1)
	      (saved-window-pixel-left saved-2))
	   (= (saved-window-pixel-top saved-1)
	      (saved-window-pixel-top saved-2))
	   (= (saved-window-pixel-right saved-1)
	      (saved-window-pixel-right saved-2))
	   (= (saved-window-pixel-bottom saved-1)
	      (saved-window-pixel-bottom saved-2))
	   (= (saved-window-hscroll saved-1)
	      (saved-window-hscroll saved-2))
	   (equal (saved-window-modeline-hscroll saved-1)
		  (saved-window-modeline-hscroll saved-2))
	   (eq (saved-window-dedicatedp saved-1)
	       (saved-window-dedicatedp saved-2))
	   (maybe-saved-window-equal (saved-window-first-hchild saved-1)
				     (saved-window-first-hchild saved-2))
	   (maybe-saved-window-equal (saved-window-first-vchild saved-1)
				     (saved-window-first-vchild saved-2))
	   (maybe-saved-window-equal (saved-window-next-child saved-1)
				     (saved-window-next-child saved-2)))))

(defun maybe-saved-window-equal (maybe-saved-1 maybe-saved-2)
  "Returns a boolean indicating whether the two given saved windows
or NILs are identical."
  (cond
   ((and (not maybe-saved-1) (not maybe-saved-2)) t)
   ((not maybe-saved-1) (not maybe-saved-2))
   ((not maybe-saved-2) (not maybe-saved-1))
   (t (saved-window-equal maybe-saved-1 maybe-saved-2))))

(defun current-window-configuration (&optional frame)
  "Return an object representing the current window configuration of FRAME.
If FRAME is nil or omitted, use the selected frame.
This describes the number of windows, their sizes and current buffers,
and for each window on FRAME the displayed buffer, where display
starts, and the positions of point and mark.
An exception is made for point in the current buffer:
its value is -not- saved."
  (let ((frame (or frame (selected-frame))))
    ;; The original C code used complicated but still incomplete logic
    ;; to decide if and how to restore the size of the minibuffer.  It
    ;; goes something like this:
;     (let ((real-font-height
; 	   (font-height (face-font 'default) frame))
; 	  (minibuffer-height
; 	   (if (and (minibuffer-window frame)
; 		    (not (frame-minibuffer-only-p frame)))
; 	       (window-pixel-height (minibuffer-window frame))
; 	     0)))
;       ...)
	      
    (make-window-configuration
     :frame frame
     :frame-top (frame-property frame 'top)
     :frame-left (frame-property frame 'left)
     :frame-pixel-width (frame-pixel-width frame)
     :frame-pixel-height (frame-pixel-height frame)
     :current-buffer (current-buffer)
     :min-width window-min-width :min-height window-min-height
     :minibuffer-pixel-height (window-pixel-height (minibuffer-window frame))
     ;; this tries to do what the old code did:
;        :minibuffer-height (if (zerop (% minibuffer-height real-font-height))
; 			      (- (/ minibuffer-height real-font-height)) ; lines
; 			    minibuffer-height) ; pixels
     :saved-root-window (root-window->saved-window (frame-root-window frame)))))

(defun root-window->saved-window (window)
  "Converts a root window into a tree of saved-window structures."
  (let ((buffer (window-buffer window))
	(edges (window-pixel-edges window)))
    (let ((left (nth 0 edges))
	  (top (nth 1 edges))
	  (right (nth 2 edges))
	  (bottom (nth 3 edges)))
      (let ((saved-window
	     (make-saved-window
	      :window window
	      :currentp (eq window (selected-window (window-frame window)))
	      :minibufferp (eq window (minibuffer-window (window-frame window)))
	      :minibuffer-scrollp (eq window minibuffer-scroll-window)
	      :buffer buffer
	      :pixel-left left :pixel-top top :pixel-right right :pixel-bottom bottom
	      :hscroll (window-hscroll window)
	      :modeline-hscroll (modeline-hscroll window)
	      :dedicatedp (window-dedicated-p window)
	      :first-hchild (if (window-first-hchild window)
				(root-window->saved-window (window-first-hchild window))
			      nil)
	      :first-vchild (if (window-first-vchild window)
				(root-window->saved-window (window-first-vchild window))
			      nil)
	      :next-child (if (window-next-child window)
			      (root-window->saved-window (window-next-child window))
			    nil))))
	(if buffer
	    (progn
	      (let ((marker (make-marker)))
		(set-marker marker (window-start window) buffer)
		(setf (saved-window-start-marker saved-window) marker))
	      (if (not (eq buffer (current-buffer)))
		  (let ((marker (make-marker)))
		    (set-marker marker (window-point window) buffer)
		    (setf (saved-window-point-marker saved-window) marker)))
	      (setf (saved-window-mark-marker saved-window)
		    (copy-marker (mark-marker t buffer)))))
	saved-window))))

(defmacro save-window-excursion/mapping (&rest body)
  "Execute body, preserving window sizes and contents.
Restores which buffer appears in which window, where display starts,
as well as the current buffer.
Return alist mapping old windows to new windows.
This alist maps the originally captured windows to the windows that correspond
to them in the restored configuration.  It does not include entries for
windows that have not changed identity.
Does not restore the value of point in current buffer."
  (let ((window-config (gensym 'window-config))
	(mapping (gensym 'mapping)))
    `(let ((,window-config (current-window-configuration))
	   (,mapping))
      (unwind-protect
	  (progn ,@body)
	(setq ,mapping (set-window-configuration/mapping ,window-config)))
      ,mapping)))

(defun set-window-configuration (configuration &optional set-frame-size-p)
  "Set the configuration of windows and buffers as specified by CONFIGURATION.
CONFIGURATION must be a value previously returned
by `current-window-configuration'.
If SET-FRAME-SIZE-P is true, the frame size is also restored.
"
  (set-window-configuration/mapping configuration set-frame-size-p)
  nil) ; make sure nobody relies on mapping return value

(defun set-window-configuration/mapping (configuration &optional set-frame-size-p)
  "Set the configuration of windows and buffers as specified by CONFIGURATION.
CONFIGURATION must be a value previously returned
by `current-window-configuration'.
If SET-FRAME-SIZE-P is true, the frame size is also restored.
Return alist mapping old windows to new windows.
This alist maps the originally captured windows to the windows that correspond
to them in the restored configuration.  It does not include entries for
windows that have not changed identity."
  (let ((frame (window-configuration-frame configuration)))
    (if (and (frame-live-p frame)
	     (not (window-configuration-equal configuration
					      (current-window-configuration))))
	(really-set-window-configuration frame configuration set-frame-size-p))))

(defun really-set-window-configuration (frame configuration set-frame-size-p)
  "Set the window configuration CONFIGURATION on live frame FRAME.
If SET-FRAME-SIZE-P is true, the frame size is also restored.
Return alist mapping old windows to new windows."
  ;; avoid potential temporary problems
  (setq window-min-width 0)
  (setq window-min-height 0)
  (setq minibuffer-scroll-window nil)

  (frame-reduce-to-one-window frame)
  (if set-frame-size-p
      (set-window-configuration-frame-size configuration))

  ;; avoid setting these if they're already up-to-date
  ;; This also avoids potential inaccuracies in these settings --Mike
  (when window-configuration-includes-position
    (let ((left (window-configuration-frame-left configuration))
	  (top (window-configuration-frame-top configuration)))
      (if (not (equal left (frame-property frame 'left)))
	  (set-frame-property frame 'left left))
      (if (not (equal top (frame-property frame 'top)))
	  (set-frame-property frame 'top top))))

  ;; these may have changed because of the delete
  (set-window-pixel-height (minibuffer-window frame)
			   (window-configuration-minibuffer-pixel-height configuration))

  ;; avoid that `set-window-point' will set the buffer's point for
  ;; the selected window
  (select-window (minibuffer-window frame))

  (let ((window-configuration-current-window nil)
	(mapping (list nil)))		; poor man's box
      
    (declare (special window-configuration-current-window))
    (restore-saved-window configuration
			  (frame-root-window frame)
			  (window-configuration-saved-root-window configuration)
			  'vertical
			  mapping) 
    (if window-configuration-current-window
	(select-window window-configuration-current-window))
    
    (setq window-min-width (window-configuration-min-width configuration))
    (setq window-min-height (window-configuration-min-height configuration))
      
    (let ((buffer (window-configuration-current-buffer configuration)))
      (if (buffer-live-p buffer)
	  (set-buffer buffer)
	(set-buffer (car (buffer-list)))))
    ; this resets the window configuration so that the frame is filled
    (if (not set-frame-size-p)
	(set-frame-pixel-size frame (frame-pixel-width frame) (frame-pixel-height frame)))
    (car mapping)))

(defun set-window-configuration-frame-size (configuration)
  "Restore the frame size of a window configuration."
  (set-frame-pixel-size
   (window-configuration-frame configuration)
   (window-configuration-frame-pixel-width configuration)
   (window-configuration-frame-pixel-height configuration)))

(defun frame-reduce-to-one-window (frame)
  "Delete all windows except the minibuffer and one other in FRAME."
  (let* ((root-window (frame-root-window frame))
	 (combination-start (or (window-first-hchild root-window)
				(window-first-vchild root-window))))
    (if combination-start
	(window-reduce-to-one combination-start))))

;; Note that simply using `delete-other-windows' causes obscure
;; breakage. --Mike

(defun window-reduce-to-one (window)
  "Make sure only one subwindow of WINDOW is left."
  (let ((window (window-next-child window)))
    (while window
      (if (window-live-p window)
	  (let ((next (window-next-child window)))
	    (real-delete-window window)
	    (setq window next)))))
  (cond
   ((window-first-hchild window)
    (window-reduce-to-one (window-first-hchild window)))
   ((window-first-vchild window)
    (window-reduce-to-one (window-first-vchild window)))))

(defun restore-saved-window (configuration window saved-window direction mapping)
  "Within CONFIGURATION, restore WINDOW to the state of SAVED-WINDOW.
MAPPING is a one-element list whose element is an old-window-to-new-window
mapping, which this function will extend."
  (if (not (eq (saved-window-window saved-window) window))
      (rplaca mapping
	      (cons (cons (saved-window-window saved-window) window)
		    (car mapping))))
  (cond
   ((and (saved-window-next-child saved-window)
	 (not (saved-window-minibufferp (saved-window-next-child saved-window))))
    (cond ((eq direction 'vertical)
	   (real-split-window window nil nil))
	  ((eq direction 'horizontal)
	   (real-split-window window nil t)))
    (if (not (saved-window-minibufferp saved-window))
	(restore-saved-window-parameters configuration window saved-window))
    (restore-saved-window configuration
			  (window-next-child window)
			  (saved-window-next-child saved-window)
			  direction
			  mapping))
  ((not (saved-window-minibufferp saved-window))
   (restore-saved-window-parameters configuration window saved-window)))

  (if (saved-window-first-hchild saved-window)
      (restore-saved-window configuration
			    window
			    (saved-window-first-hchild saved-window)
			    'horizontal
			    mapping))
  (if (saved-window-first-vchild saved-window)
      (restore-saved-window configuration
			    window
			    (saved-window-first-vchild saved-window)
			    'vertical
			    mapping)))

(defun restore-saved-window-parameters (configuration window saved-window)
  "Restore the window parameters stored in SAVED-WINDOW on WINDOW."
  (declare (special window-configuration-current-window))
  (let ((buffer (saved-window-buffer saved-window)))
    (if (and buffer (buffer-live-p buffer))
	(progn
	  (set-window-buffer window
			     (saved-window-buffer saved-window))
	  (set-window-start window
			    (marker-position (saved-window-start-marker saved-window))
			    t)
	  (if (markerp (saved-window-point-marker saved-window))
	      (set-window-point window
				(marker-position (saved-window-point-marker saved-window))))
	  (set-marker (mark-marker t buffer)
		      (marker-position (saved-window-mark-marker saved-window))
		      buffer)
	  (if (not (eq buffer (window-configuration-current-buffer configuration)))
	      (goto-char (window-point window) buffer)))))

  (if (and (not (saved-window-first-hchild saved-window))
	   (not (saved-window-first-vchild saved-window)))
      ;; only set size for non-container windows
      (progn
	;; If this is the root window, it may be the only window.
	;; Because of mismatches between actual and reported frame
	;; size, it may not let us actually set the size of the root
	;; window to what we want. --Mike
	(if (not (eq window (frame-root-window (window-frame window))))
	    (progn
	      (set-window-pixel-width window 
				      (saved-window-pixel-width saved-window))
	      (set-window-pixel-height window
				       (saved-window-pixel-height saved-window))))
	(set-window-hscroll window (saved-window-hscroll saved-window))
	(set-modeline-hscroll window
			      (saved-window-modeline-hscroll saved-window))
	(set-window-dedicated-p window (saved-window-dedicatedp saved-window))))

  (if (saved-window-currentp saved-window)
      (setq window-configuration-current-window window))
  (if (saved-window-minibuffer-scrollp saved-window)
      (setq minibuffer-scroll-window window)))

(defun saved-window-pixel-width (saved-window)
  "Compute the pixel width of SAVED-WINDOW."
  (- (saved-window-pixel-right saved-window)
     (saved-window-pixel-left saved-window)))

(defun saved-window-pixel-height (saved-window)
  "Compute the pixel height of SAVED-WINDOW."
  (- (saved-window-pixel-bottom saved-window)
     (saved-window-pixel-top saved-window)))

(defun set-window-pixel-width (window width)
  "Set the pixel width of WINDOW."
  (enlarge-window-pixels (- width (window-pixel-width window)) t window))

(defun set-window-pixel-height (window height)
  "Set the pixel height of WINDOW."
  (enlarge-window-pixels (- height (window-pixel-height window)) nil window))


;; The window-config stack is stored as a list in frame property
;; 'window-config-stack, with the most recent element at the front.
;; When you pop off an element, the popped off element gets put at the
;; front of frame property 'window-config-unpop-stack, so you can
;; retrieve it using unpop-window-configuration.

(defcustom window-config-stack-max 16
  "*Maximum size of window configuration stack.
Start discarding off end if it gets this big."
  :type 'integer
  :group 'windows)

(defun window-config-stack (&optional frame)
  (or frame (setq frame (selected-frame)))
  (let ((stack (frame-property frame 'window-config-stack)))
    (if stack
	(set-undoable-stack-max stack window-config-stack-max)
      (progn
	(setq stack (make-undoable-stack window-config-stack-max))
	(set-frame-property frame 'window-config-stack stack)))
    stack))

(defun push-window-configuration (&optional config)
  "Push the current window configuration onto the window-config stack.
If CONFIG is specified, push it instead of the current window configuration.
Each frame has its own window-config stack."
  (interactive)
  (let ((wc (or config (current-window-configuration)))
	(stack (window-config-stack)))
    (if (or (eql 0 (undoable-stack-a-length stack))
	    (not (equal (undoable-stack-a-top stack) wc)))
	(undoable-stack-push stack wc))))

(defun pop-window-configuration ()
  "Pop the top window configuration off the window-config stack and set it.
Before setting the new window configuration, the current window configuration
 is pushed onto the \"unpop\" stack.
`unpop-window-configuration' undoes what this function does.
Each frame has its own window-config and \"unpop\" stack."
  (interactive)
  (let ((stack (window-config-stack))
	(wc (current-window-configuration))
	popped)
    (condition-case nil
	(progn
	  (setq popped (undoable-stack-pop stack))
	  (while (equal popped wc)
	    (setq popped (undoable-stack-pop stack)))
	  (undoable-stack-push stack wc)
	  (undoable-stack-undo stack)
	  (set-window-configuration popped)
	  popped)
      (trunc-stack-bottom
       (error "Bottom of window config stack")))))

(defun unpop-window-configuration ()
  "Undo the effect of the most recent `pop-window-configuration'.
This does exactly the inverse of what `pop-window-configuration' does:
 i.e. it pops a window configuration off of the \"unpop\" stack and
 pushes the current window configuration onto the window-config stack.
Each frame has its own window-config and \"unpop\" stack."
  (interactive)
  (let ((stack (window-config-stack))
	(wc (current-window-configuration))
	popped)
    (condition-case nil
	(progn
	  (setq popped
		(progn
		  (undoable-stack-redo stack)
		  (undoable-stack-pop stack)))
	  (while (equal popped wc)
	    (setq popped
		  (progn
		    (undoable-stack-redo stack)
		    (undoable-stack-pop stack))))
	  (undoable-stack-push stack wc)
	  (set-window-configuration popped)
	  popped)
      (trunc-stack-bottom
       (error "Top of window config stack")))))


;;;;;;;;;;;;; display-buffer, moved here from C.  Hallelujah.

(make-variable-buffer-local '__buffer-dedicated-frame)

(defun buffer-dedicated-frame (&optional buffer)
  "Return the frame dedicated to this BUFFER, or nil if there is none.
No argument or nil as argument means use current buffer as BUFFER."
  (let ((buffer (decode-buffer buffer)))
    (let ((frame (symbol-value-in-buffer '__buffer-dedicated-frame buffer)))
      ;; XEmacs addition: if the frame is dead, silently make it go away.
      (when (and (framep frame) (not (frame-live-p frame)))
	    (with-current-buffer buffer
	      (setq __buffer-dedicated-frame nil))
	    (setq frame nil))
      frame)))

(defun set-buffer-dedicated-frame (buffer frame)
  "For this BUFFER, set the FRAME dedicated to it.
FRAME must be a frame or nil."
  (let ((buffer (decode-buffer buffer)))
    (and frame
	 (check-argument-type #'frame-live-p frame))
    (with-current-buffer buffer
      (setq __buffer-dedicated-frame frame))))

(defvar display-buffer-function nil
  "If non-nil, function to call to handle `display-buffer'.
It will receive four args: the same as those to `display-buffer'.")

(defvar pre-display-buffer-function nil
  "If non-nil, function that will be called from `display-buffer'
as the first action.  It will receive four args: the same as those
to `display-buffer'.
This function may be used to select an appropriate frame for the buffer,
for example.  See also the variable `display-buffer-function', which may
be used to completely replace the `display-buffer' function.
If the return value of this function is non-nil, it should be a frame,
and that frame will be used to display the buffer.")

(defcustom pop-up-frames nil
  "*Non-nil means `display-buffer' should make a separate frame."
  :type 'boolean
  :group 'frames)

(defvar pop-up-frame-function nil
  "Function to call to handle automatic new frame creation.
It is called with no arguments and should return a newly created frame.

A typical value might be `(lambda () (new-frame pop-up-frame-alist))'
where `pop-up-frame-alist' would hold the default frame parameters.")

(defcustom special-display-buffer-names nil
  "*List of buffer names that should have their own special frames.
Displaying a buffer whose name is in this list makes a special frame for it
using `special-display-function'.

An element of the list can be a cons cell instead of just a string.
Then the car should be a buffer name, and the cdr specifies frame
parameters for creating the frame for that buffer.
More precisely, the cdr is passed as the second argument to
the function found in `special-display-function', when making that frame.
See also `special-display-regexps'."
  :type '(repeat (choice :value ""
			 (string :tag "Name")
			 (cons :menu-tag "Properties"
			       :value ("" . nil)
			       (string :tag "Name")
			       (repeat :tag "Properties"
				       (group :inline t
					      (symbol :tag "Property")
					      (sexp :tag "Value"))))))
  :group 'frames)

(defcustom special-display-regexps nil
  "*List of regexps saying which buffers should have their own special frames.
If a buffer name matches one of these regexps, it gets its own frame.
Displaying a buffer whose name is in this list makes a special frame for it
using `special-display-function'.

An element of the list can be a cons cell instead of just a string.
Then the car should be the regexp, and the cdr specifies frame
parameters for creating the frame for buffers that match.
More precisely, the cdr is passed as the second argument to
the function found in `special-display-function', when making that frame.
See also `special-display-buffer-names'."
  :type '(repeat (choice :value ""
			 regexp
			 (cons :menu-tag "Properties"
			       :value ("" . nil)
			       regexp
			       (repeat :tag "Properties"
				       (group :inline t
					      (symbol :tag "Property")
					      (sexp :tag "Value"))))))
  :group 'frames)

(defvar special-display-function nil
  "Function to call to make a new frame for a special buffer.
It is called with two arguments, the buffer and optional buffer specific
data, and should return a window displaying that buffer.
The default value makes a separate frame for the buffer,
using `special-display-frame-alist' to specify the frame parameters.

A buffer is special if its is listed in `special-display-buffer-names'
or matches a regexp in `special-display-regexps'.")

(defcustom same-window-buffer-names nil
  "*List of buffer names that should appear in the selected window.
Displaying one of these buffers using `display-buffer' or `pop-to-buffer'
switches to it in the selected window, rather than making it appear
in some other window.

An element of the list can be a cons cell instead of just a string.
Then the car must be a string, which specifies the buffer name.
This is for compatibility with `special-display-buffer-names';
the cdr of the cons cell is ignored.

See also `same-window-regexps'."
  :type '(repeat (string :tag "Name"))
  :group 'windows)

(defcustom same-window-regexps nil
  "*List of regexps saying which buffers should appear in the selected window.
If a buffer name matches one of these regexps, then displaying it
using `display-buffer' or `pop-to-buffer' switches to it
in the selected window, rather than making it appear in some other window.

An element of the list can be a cons cell instead of just a string.
Then the car must be a string, which specifies the buffer name.
This is for compatibility with `special-display-buffer-names';
the cdr of the cons cell is ignored.

See also `same-window-buffer-names'."
  :type '(repeat regexp)
  :group 'windows)

(defcustom pop-up-windows t
  "*Non-nil means display-buffer should make new windows."
  :type 'boolean
  :group 'windows)

(defcustom split-height-threshold 500
 "*display-buffer would prefer to split the largest window if this large.
If there is only one window, it is split regardless of this value."
 :type 'integer
 :group 'windows)

(defcustom split-width-threshold 500
  "*display-buffer would prefer to split the largest window if this large.
If there is only one window, it is split regardless of this value."
  :type 'integer
  :group 'windows)

;; Can you believe that all of this crap was formerly in C?
;; Praise Jesus that it's not there any more.

(defun display-buffer (buffer &optional not-this-window-p override-frame
                       shrink-to-fit)
  "Make BUFFER appear in some window on the current frame, but don't select it.
BUFFER can be a buffer or a buffer name.
If BUFFER is shown already in some window in the current frame,
just uses that one, unless the window is the selected window and
NOT-THIS-WINDOW-P is non-nil (interactively, with prefix arg).

If BUFFER has a dedicated frame, display on that frame instead of
the current frame, unless OVERRIDE-FRAME is non-nil.

If OVERRIDE-FRAME is non-nil, display on that frame instead of
the current frame (or the dedicated frame).

If SHRINK-TO-FIT is non-nil and splitting the window is appropriate, give
the new buffer less than half the space if it is small enough to fit.

If `pop-up-windows' is non-nil, always use the
current frame and create a new window regardless of whether the
buffer has a dedicated frame, and regardless of whether
OVERRIDE-FRAME was specified.

If `pop-up-frames' is non-nil, make a new frame if no window shows BUFFER.

If the buffer name is a member of the `same-window-buffer-names' list,
or matches one of the `same-window-regexps' expressions, display the
buffer in the currently selected window.

Returns the window displaying BUFFER."
  (interactive "BDisplay buffer:\nP")

  (let ((wconfig (current-window-configuration)))
    (prog1
        ;; We just simulate a `return' in C.  This function is way
        ;; ugly and does `returns' all over the place and there's
        ;; no sense in trying to rewrite it to be more Lispy.
        (block nil
          (labels
              ((display-buffer-1 (window)
                 ;; Deiconify the frame containing the window WINDOW, then
                 ;; return WINDOW.
                 (if (frame-iconified-p (window-frame window))
                     (make-frame-visible (window-frame window)))
                 window))
            (let (window old-frame target-frame explicit-frame shrink-it)
              (setq old-frame (or (last-nonminibuf-frame) (selected-frame)))
              (setq buffer (get-buffer buffer))
              (check-argument-type 'bufferp buffer)

              (setq explicit-frame
                    (if pre-display-buffer-function
                        (funcall pre-display-buffer-function buffer
                                 not-this-window-p
                                 override-frame
                                 shrink-to-fit)))

              ;; Give the user the ability to completely reimplement
              ;; this function via the `display-buffer-function'.
              (if display-buffer-function
                  (return (funcall display-buffer-function buffer
                                   not-this-window-p
                                   override-frame
                                   shrink-to-fit)))

              ;; If the buffer has a dedicated frame, that takes
              ;; precedence over the current frame, and over what the
              ;; pre-display-buffer-function did.
              (let ((dedi (buffer-dedicated-frame buffer)))
                (if (frame-live-p dedi) (setq explicit-frame dedi)))

              ;; if override-frame is supplied, that takes precedence over
              ;; everything.  This is gonna look bad if the
              ;; pre-display-buffer-function raised some other frame already.
              (if override-frame
                  (progn
                    (check-argument-type 'frame-live-p override-frame)
                    (setq explicit-frame override-frame)))

              (setq target-frame
                    (or explicit-frame
                        (last-nonminibuf-frame)
                        (selected-frame)))

              ;; If we have switched frames, then set not-this-window-p to
              ;; false.  Switching frames means that selected-window is no
              ;; longer the same as it was on entry -- it's the
              ;; selected-window of target_frame instead of old_frame, so
              ;; it's a fine candidate for display.
              (if (not (eq old-frame target-frame))
                  (setq not-this-window-p nil))

              ;; if it's in the selected window, and that's ok, then we're
              ;; done.
              (if (and (not not-this-window-p)
                   (eq buffer (window-buffer (selected-window))))
                  (return (display-buffer-1 (selected-window))))

              ;; See if the user has specified this buffer should
              ;; appear in the selected window.

              (if not-this-window-p
                  nil
                (if (or (member (buffer-name buffer) same-window-buffer-names)
                        (assoc (buffer-name buffer) same-window-buffer-names))
                    (progn
                      (switch-to-buffer buffer)
                      (return (display-buffer-1 (selected-window)))))

                (let ((tem same-window-regexps))
                  (while tem
                    (let ((car (car tem)))
                      (if (or
                           (and (stringp car)
                                (string-match car (buffer-name buffer)))
                           (and (consp car) (stringp (car car))
                                (string-match (car car) (buffer-name buffer))))
                          (progn
                            (switch-to-buffer buffer)
                            (return (display-buffer-1 (selected-window))))))
                    (setq tem (cdr tem)))))

              ;; If pop-up-frames, look for a window showing BUFFER
              ;; on any visible or iconified frame.  Otherwise search
              ;; only the current frame.
              (if (and (not explicit-frame)
                   (or pop-up-frames (not (last-nonminibuf-frame))))
                  (setq target-frame 0))

              ;; Otherwise, find some window that it's already in,
              ;; and return that, unless that window is the selected
              ;; window and that isn't ok.  What a contorted mess!
              (setq window (or (if (not explicit-frame)
                                   ;; search the selected frame
                                   ;; first if the user didn't
                                   ;; specify an explicit frame.
                                   (get-buffer-window buffer nil))
                               (get-buffer-window buffer target-frame)))
              (if (and window
                   (or (not not-this-window-p)
                       (not (eq window (selected-window)))))
                  (return (display-buffer-1 window)))
              ;; Certain buffer names get special handling.
              (if special-display-function
                  (progn
                    (if (member (buffer-name buffer)
                                special-display-buffer-names)
                        (return (funcall special-display-function buffer)))

                    (let ((tem (assoc (buffer-name buffer)
                                      special-display-buffer-names)))
                      (if tem
                          (return (funcall special-display-function
                                           buffer (cdr tem)))))

                    (let ((tem special-display-regexps))
                      (while tem
                        (let ((car (car tem)))
                          (if (and (stringp car)
                                   (string-match car (buffer-name buffer)))
                              (return
                               (funcall special-display-function buffer)))
                          (if (and (consp car)
                                   (stringp (car car))
                                   (string-match (car car)
                                                 (buffer-name buffer)))
                              (return (funcall special-display-function buffer
                                               (cdr car)))))
                        (setq tem (cdr tem))))))

              ;; If there are no frames open that have more than a minibuffer,
              ;; we need to create a new frame.
              (if (or pop-up-frames
                   (null (last-nonminibuf-frame)))
                  (progn
                    (setq window (frame-selected-window
                                  (funcall pop-up-frame-function)))
                    (set-window-buffer window buffer)
                    (return (display-buffer-1 window))))

              ;; Otherwise, make it be in some window, splitting if
              ;; appropriate/possible.  Do not split a window if we
              ;; are displaying the buffer in a different frame than
              ;; that which was current when we were called.  (It is
              ;; already in a different window by virtue of being in
              ;; another frame.)
              (if (or (and pop-up-windows (eq target-frame old-frame))
                   (eq 'only (frame-property (selected-frame) 'minibuffer))
                   ;; If the current frame is a special display frame,
                   ;; don't try to reuse its windows.
                   (window-dedicated-p
                    (frame-root-window (selected-frame))))
                  (progn
                    (if (eq 'only (frame-property (selected-frame)
                                                  'minibuffer))
                        (setq target-frame (last-nonminibuf-frame)))

                    ;; Don't try to create a window if would get an error with
                    ;; height.
                    (if (< split-height-threshold (* 2 window-min-height))
                        (setq split-height-threshold (* 2 window-min-height)))

                    ;; Same with width.
                    (if (< split-width-threshold (* 2 window-min-width))
                        (setq split-width-threshold (* 2 window-min-width)))

                    ;; If the frame we would try to split cannot be split,
                    ;; try other frames.
                    (if (frame-property (if (null target-frame)
                                            (selected-frame)
                                          (last-nonminibuf-frame))
                                        'unsplittable)
                        (setq window
                              ;; Try visible frames first.
                              (or (get-largest-window 'visible)
                                  ;; If that didn't work, try iconified frames.
                                  (get-largest-window 0)
                                  (get-largest-window t)))
                      (setq window (get-largest-window target-frame)))

                    ;; If we got a tall enough full-width window that
                    ;; can be split, split it.
                    (if (and window
                             (not (frame-property (window-frame window)
                                                  'unsplittable))
                             (>= (window-height window) split-height-threshold)
                             (or (>= (window-width window)
                                     split-width-threshold)
                                 (and (window-leftmost-p window)
                                      (window-rightmost-p window))))
                        (setq window (split-window window))
                      (let (upper other)
                        (setq window (get-lru-window target-frame))
                        ;; If the LRU window is selected, and big enough,
                        ;; and can be split, split it.
                        (if (and window
                                 (not (frame-property (window-frame window)
                                                      'unsplittable))
                                 (or (eq window (selected-window))
                                     (not (window-parent window)))
                                 (>= (window-height window)
                                     (* 2 window-min-height)))
                            (setq window (split-window window)))
                        ;; If get-lru-window returned nil, try other
                        ;; approaches.  Try visible frames first.
                        (or window
                            (setq window (or (get-largest-window 'visible)
                                             ;; If that didn't work, try
                                             ;; iconified frames.
                                             (get-largest-window 0)
                                             ;; Try invisible frames.
                                             (get-largest-window t)
                                             ;; As a last resort, make
                                             ;; a new frame.
                                             (frame-selected-window
                                              (funcall
                                               pop-up-frame-function)))))
                        ;; If window appears above or below another,
                        ;; even out their heights.
                        (if (window-previous-child window)
                            (setq other (window-previous-child window)
                                  upper other))
                        (if (window-next-child window)
                            (setq other (window-next-child window)
                                  upper window))
                        ;; Check that OTHER and WINDOW are vertically arrayed.
                        (if (and other
                                 (not (= (nth 1 (window-pixel-edges other))
                                         (nth 1 (window-pixel-edges window))))
                                 (> (window-pixel-height other)
                                    (window-pixel-height window)))
                            (enlarge-window (- (/ (+ (window-height other)
                                                     (window-height window))
                                                  2)
                                               (window-height upper))
                                            nil upper))
                        ;; Klaus Berndl <klaus.berndl@sdm.de>: Only in
                        ;; this situation we shrink-to-fit but we can do
                        ;; this first after we have displayed buffer in
                        ;; window (s.b. (set-window-buffer window buffer))
                        (setq shrink-it shrink-to-fit))))

                (setq window (get-lru-window target-frame)))

              ;; Bring the window's previous buffer to the top of the
              ;; MRU chain.
              (if (window-buffer window)
                  (save-excursion
                    (save-selected-window
                      (select-window window)
                      (record-buffer (window-buffer window)))))

              (set-window-buffer window buffer)

              ;; Now window's previous buffer has been brought to the
              ;; top of the MRU chain and window displays buffer -
              ;; now we can shrink-to-fit if necessary
              (if shrink-it
                  (shrink-window-if-larger-than-buffer window))
              (display-buffer-1 window)))) ;; End of prog1's 1th form.
      (or (equal wconfig (current-window-configuration))
          (push-window-configuration wconfig)))))

;;; window-xemacs.el ends here