Subject: bug#1806: dired-pop-to-buffer in wrong place

From: martin rudalics <[email-masked]>
Date: Thu, 08 Jan 2009 08:42:35 +0100

> As I can see currently `fit-window-to-buffer' always takes space
 > from the bottom window, but we need it from the top window.

Looking at this again, I believe what you want is to invert the order of
stealing and giving as in the attached patch.  Might have side-effects
elsewhere.

martin
Index: window.c
===================================================================
RCS file: /sources/emacs/emacs/src/window.c,v
retrieving revision 1.638
diff -c -r1.638 window.c
*** window.c	8 Jan 2009 03:16:08 -0000	1.638
--- window.c	8 Jan 2009 07:21:10 -0000
***************
*** 4125,4171 ****
        while (delta != 0
  	     && (!NILP (next) || !NILP (prev)))
  	{
! 	  if (! NILP (next))
  	    {
! 	      int this_one = ((*sizefun) (next)
! 			      - window_min_size (XWINDOW (next), horiz_flag,
  						 0, 0, &fixed_p));
  	      if (!fixed_p)
  		{
  		  if (this_one > delta)
  		    this_one = delta;
  
! 		  (*setsizefun) (next, (*sizefun) (next) - this_one, 0);
  		  (*setsizefun) (window, XINT (*sizep) + this_one, 0);
  
  		  delta -= this_one;
  		}
  
! 	      next = XWINDOW (next)->next;
  	    }
  
  	  if (delta == 0)
  	    break;
  
! 	  if (! NILP (prev))
  	    {
! 	      int this_one = ((*sizefun) (prev)
! 			      - window_min_size (XWINDOW (prev), horiz_flag,
  						 0, 0, &fixed_p));
  	      if (!fixed_p)
  		{
  		  if (this_one > delta)
  		    this_one = delta;
  
! 		  first_affected = prev;
! 
! 		  (*setsizefun) (prev, (*sizefun) (prev) - this_one, 0);
  		  (*setsizefun) (window, XINT (*sizep) + this_one, 0);
  
  		  delta -= this_one;
  		}
  
! 	      prev = XWINDOW (prev)->prev;
  	    }
  	}
  
--- 4125,4171 ----
        while (delta != 0
  	     && (!NILP (next) || !NILP (prev)))
  	{
! 	  if (! NILP (prev))
  	    {
! 	      int this_one = ((*sizefun) (prev)
! 			      - window_min_size (XWINDOW (prev), horiz_flag,
  						 0, 0, &fixed_p));
  	      if (!fixed_p)
  		{
  		  if (this_one > delta)
  		    this_one = delta;
  
! 		  first_affected = prev;
! 
! 		  (*setsizefun) (prev, (*sizefun) (prev) - this_one, 0);
  		  (*setsizefun) (window, XINT (*sizep) + this_one, 0);
  
  		  delta -= this_one;
  		}
  
! 	      prev = XWINDOW (prev)->prev;
  	    }
  
  	  if (delta == 0)
  	    break;
  
! 	  if (! NILP (next))
  	    {
! 	      int this_one = ((*sizefun) (next)
! 			      - window_min_size (XWINDOW (next), horiz_flag,
  						 0, 0, &fixed_p));
  	      if (!fixed_p)
  		{
  		  if (this_one > delta)
  		    this_one = delta;
  
! 		  (*setsizefun) (next, (*sizefun) (next) - this_one, 0);
  		  (*setsizefun) (window, XINT (*sizep) + this_one, 0);
  
  		  delta -= this_one;
  		}
  
! 	      next = XWINDOW (next)->next;
  	    }
  	}