From xemacs-m  Mon Mar 24 19:57:26 1997
Received: from alphatech.com (erebus.alphatech.com [198.112.236.2])
	by xemacs.org (8.8.5/8.8.5) with SMTP id TAA03592
	for <xemacs-beta@xemacs.org>; Mon, 24 Mar 1997 19:57:24 -0600 (CST)
Received: from venus.alphatech.com by alphatech.com (4.1/SMI-4.1)
	id AA25104; Mon, 24 Mar 97 20:52:42 EST
Received: from pochacco.alphatech.com by venus.alphatech.com (4.1/SMI-4.1)
	id AA13354; Mon, 24 Mar 97 21:00:57 EST
Received: by pochacco.alphatech.com (SMI-8.6/SMI-SVR4)
	id UAA01433; Mon, 24 Mar 1997 20:50:11 -0500
Date: Mon, 24 Mar 1997 20:50:11 -0500
Message-Id: <199703250150.UAA01433@pochacco.alphatech.com>
Mime-Version: 1.0
From: greg@alphatech.com (Greg Klanderman)
To: xemacs-beta@xemacs.org (XEmacs beta list)
Subject: temp-buffer-shrink-to-fit lossage
X-Mailer: VM 6.21 under 19.15 XEmacs Lucid (beta103)
Reply-To: greg@alphatech.com
Content-Type: text/plain; charset=US-ASCII


While I agree that this behavior is a good thing I think a misfeature
has been introduced in the following 3 places (b103):

lisp/packages/apropos.el:566:    (when temp-buffer-shrink-to-fit
lisp/prim/help.el:394:	      (when temp-buffer-shrink-to-fit
lisp/prim/lisp.el:330:	     (when temp-buffer-shrink-to-fit

In these places, the when clause should be removed.  The function
shrink-window-if-larger-than-buffer() is already getting called
anyway, since in prim/frame.el we have,

(setq temp-buffer-show-function 'show-temp-buffer-in-current-frame)

and show-temp-buffer-in-current-frame does

      (when temp-buffer-shrink-to-fit
	(shrink-window-if-larger-than-buffer window))

and frame.elc is dumped standard.

Further, if I have set temp-buffer-show-function to some other
function of my choosing, these calls violate the docs for
temp-buffer-show-function: 

> If this function is used, then it must do the 
> entire job of showing the buffer
  ^^^^^^ 
and may cause my temp-buffer-show-function (eg. popper-show) to lose. 
Thankfully at least, setting temp-buffer-shrink-to-fit=nil disables this.

Pete Ware's patch to allow also expanding the buffer belongs in
show-temp-buffer-in-current-frame(), not with-displaying-help-buffer().
Why would you only want this behavior in some cases, anyway?  
But then again, why not just use popper?  ;-)

Here's a patch, I tested it a bit with xemacs -q.
buffer expansion now works several more places too ... :-)

Greg


--- /local/mstar/.backups/!local!mstar!software!xemacs!build!xemacs-19.15-b103!lisp!packages!apropos.el.~1~	Sat Feb 15 20:29:16 1997
+++ lisp/packages/apropos.el	Mon Mar 24 20:12:32 1997
@@ -562,9 +562,7 @@
 	  (apropos-print-doc 'describe-variable 2
 			     "Variable" do-keys)
 	  (apropos-print-doc 'apropos-describe-plist 3
-			     "Plist" nil))))
-    (when temp-buffer-shrink-to-fit
-      (shrink-window-if-larger-than-buffer (get-buffer-window "*Apropos*"))))
+			     "Plist" nil)))))
   (prog1 apropos-accumulator
     (setq apropos-accumulator ())))	; permit gc
 
--- /local/mstar/.backups/!local!mstar!software!xemacs!build!xemacs-19.15-b103!lisp!prim!frame.el.~1~	Sat Mar  8 21:37:39 1997
+++ lisp/prim/frame.el	Mon Mar 24 20:32:43 1997
@@ -1022,6 +1022,9 @@
 (defvar temp-buffer-shrink-to-fit t
   "*When non-nil resize temporary output buffers to minimize blank lines.")
 
+(defvar temp-buffer-max-height .5
+  "*Proportion of frame to use for temp windows.")
+
 (defun show-temp-buffer-in-current-frame (buffer)
   "For use as the value of temp-buffer-show-function:
 always displays the buffer in the current frame, regardless of the behavior
@@ -1036,7 +1039,12 @@
       (set-window-start window 1) ; obeys narrowing
       (set-window-point window 1)
       (when temp-buffer-shrink-to-fit
-	(shrink-window-if-larger-than-buffer window))
+        (let* ((temp-window-size (round (* temp-buffer-max-height
+                                           (frame-height (window-frame window)))))
+               (size (window-displayed-height window)))
+          (when (< size temp-window-size)
+            (enlarge-window (- temp-window-size size) nil window)))
+        (shrink-window-if-larger-than-buffer window))
       nil)))
 
 (setq pre-display-buffer-function 'get-frame-for-buffer)
--- /local/mstar/.backups/!local!mstar!software!xemacs!build!xemacs-19.15-b103!lisp!prim!help.el.~1~	Thu Mar 20 01:47:46 1997
+++ lisp/prim/help.el	Mon Mar 24 20:15:17 1997
@@ -347,8 +347,6 @@
 This just displays the buffer in another window, rather than selecting
 the window.")
 
-(defvar help-window-max-height .5
-  "*Proportion of frame to use for help windows.")
 ;; Use this function for displaying help when C-h something is pressed
 ;; or in similar situations.  Do *not* use it when you are displaying
 ;; a help message and then prompting for input in the minibuffer --
@@ -390,14 +388,7 @@
                       (substitute-command-keys "Type \\[delete-other-windows] to remove help window, \\[scroll-other-window] to scroll the help.")))
                     (t
                      (message
-                      (substitute-command-keys "Type \\[switch-to-buffer-other-window] to restore the other window, \\[scroll-other-window] to scroll the help."))))
-	      (when temp-buffer-shrink-to-fit
-		(let* ((help-window-size (round (* help-window-max-height
-					    (frame-height (window-frame helpwin)))))
-		       (size (window-displayed-height helpwin)))
-		  (if (< size help-window-size)
-		      (enlarge-window (- help-window-size size) nil helpwin)))
-		(shrink-window-if-larger-than-buffer helpwin))))))))
+                      (substitute-command-keys "Type \\[switch-to-buffer-other-window] to restore the other window, \\[scroll-other-window] to scroll the help."))))))))))
 
 (defun describe-key (key)
   "Display documentation of the function invoked by KEY.
--- /local/mstar/.backups/!local!mstar!software!xemacs!build!xemacs-19.15-b103!lisp!prim!lisp.el.~1~	Sat Feb 15 20:29:26 1997
+++ lisp/prim/lisp.el	Mon Mar 24 20:13:21 1997
@@ -326,10 +326,7 @@
 		     (setq list (cdr list)))
 		   (setq list (nreverse new))))
 	     (with-output-to-temp-buffer "*Completions*"
-	       (display-completion-list list))
-	     (when temp-buffer-shrink-to-fit
-	       (shrink-window-if-larger-than-buffer
-		(get-buffer-window "*Completions*"))))
+	       (display-completion-list list)))
 	   (message "Making completion list...%s" "done")))))
 
 ;;; lisp.el ends here

