comparison lisp/window-xemacs.el @ 1669:c5f86842283a

[xemacs-hg @ 2003-09-07 19:46:30 by adrian] [A21.5SR21.4] [PATCH] xemacs-21.5: Klaus Berndl's shrink-to-fit fix for `diplay-buffer' -------------------- ChangeLog entries follow: -------------------- lisp/ChangeLog addition: 2003-09-07 Adrian Aichner <adrian@xemacs.org> * window-xemacs.el (display-buffer): Fix for `shrink-to-fit' by Klaus Berndl, calling `shrink-window-if-larger-than-buffer' when displaying buffer in question.
author adrian
date Sun, 07 Sep 2003 19:46:32 +0000
parents bd921b813d33
children 8e7b4a0c1a81
comparison
equal deleted inserted replaced
1668:1e2c36d0f4e2 1669:c5f86842283a
705 (result 705 (result
706 ;; We just simulate a `return' in C. This function is way ugly 706 ;; We just simulate a `return' in C. This function is way ugly
707 ;; and does `returns' all over the place and there's no sense 707 ;; and does `returns' all over the place and there's no sense
708 ;; in trying to rewrite it to be more Lispy. 708 ;; in trying to rewrite it to be more Lispy.
709 (catch 'done 709 (catch 'done
710 (let (window old-frame target-frame explicit-frame) 710 (let (window old-frame target-frame explicit-frame shrink-it)
711 (setq old-frame (or (last-nonminibuf-frame) (selected-frame))) 711 (setq old-frame (or (last-nonminibuf-frame) (selected-frame)))
712 (setq buffer (get-buffer buffer)) 712 (setq buffer (get-buffer buffer))
713 (check-argument-type 'bufferp buffer) 713 (check-argument-type 'bufferp buffer)
714 714
715 (setq explicit-frame 715 (setq explicit-frame
893 (or (>= (window-width window) 893 (or (>= (window-width window)
894 split-width-threshold) 894 split-width-threshold)
895 (and (window-leftmost-p window) 895 (and (window-leftmost-p window)
896 (window-rightmost-p window)))) 896 (window-rightmost-p window))))
897 (setq window (split-window window)) 897 (setq window (split-window window))
898 (let (upper 898 (let (upper other)
899 ;; lower
900 other)
901 (setq window (get-lru-window target-frame)) 899 (setq window (get-lru-window target-frame))
902 ;; If the LRU window is selected, and big enough, 900 ;; If the LRU window is selected, and big enough,
903 ;; and can be split, split it. 901 ;; and can be split, split it.
904 (if (and window 902 (if (and window
905 (not (frame-property (window-frame window) 903 (not (frame-property (window-frame window)
925 pop-up-frame-function))))) 923 pop-up-frame-function)))))
926 ;; If window appears above or below another, 924 ;; If window appears above or below another,
927 ;; even out their heights. 925 ;; even out their heights.
928 (if (window-previous-child window) 926 (if (window-previous-child window)
929 (setq other (window-previous-child window) 927 (setq other (window-previous-child window)
930 ;; lower window
931 upper other)) 928 upper other))
932 (if (window-next-child window) 929 (if (window-next-child window)
933 (setq other (window-next-child window) 930 (setq other (window-next-child window)
934 ;; lower other
935 upper window)) 931 upper window))
936 ;; Check that OTHER and WINDOW are vertically arrayed. 932 ;; Check that OTHER and WINDOW are vertically arrayed.
937 (if (and other 933 (if (and other
938 (not (= (nth 1 (window-pixel-edges other)) 934 (not (= (nth 1 (window-pixel-edges other))
939 (nth 1 (window-pixel-edges window)))) 935 (nth 1 (window-pixel-edges window))))
942 (enlarge-window (- (/ (+ (window-height other) 938 (enlarge-window (- (/ (+ (window-height other)
943 (window-height window)) 939 (window-height window))
944 2) 940 2)
945 (window-height upper)) 941 (window-height upper))
946 nil upper)) 942 nil upper))
947 (if shrink-to-fit 943 ;; Klaus Berndl <klaus.berndl@sdm.de>: Only in
948 (shrink-window-if-larger-than-buffer window))))) 944 ;; this situation we shrink-to-fit but we can do
945 ;; this first after we have displayed buffer in
946 ;; window (s.b. (set-window-buffer window buffer))
947 (setq shrink-it shrink-to-fit))))
949 948
950 (setq window (get-lru-window target-frame))) 949 (setq window (get-lru-window target-frame)))
951 950
952 ;; Bring the window's previous buffer to the top of the MRU chain. 951 ;; Bring the window's previous buffer to the top of the MRU chain.
953 (if (window-buffer window) 952 (if (window-buffer window)
956 (select-window window) 955 (select-window window)
957 (record-buffer (window-buffer window))))) 956 (record-buffer (window-buffer window)))))
958 957
959 (set-window-buffer window buffer) 958 (set-window-buffer window buffer)
960 959
960 ;; Now window's previous buffer has been brought to the top
961 ;; of the MRU chain and window displays buffer - now we can
962 ;; shrink-to-fit if necessary
963 (if shrink-it
964 (shrink-window-if-larger-than-buffer window))
965
961 (display-buffer-1 window))))) 966 (display-buffer-1 window)))))
962 (or (equal wconfig (current-window-configuration)) 967 (or (equal wconfig (current-window-configuration))
963 (push-window-configuration wconfig)) 968 (push-window-configuration wconfig))
964 result)) 969 result))
965 970