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

From: martin rudalics <[email-masked]>
Date: Sat, 02 May 2009 20:53:08 +0200

>> Did you try it after applying my patch for window.el?
 >
 > Yes, with your patch for window.el and in a frame wider than 160 columns.

My bad.  Does the attached patch give better results?

martin
*** dired.el.~1.422.~	2009-04-18 08:32:56.546875000 +0200
--- dired.el	2009-05-02 20:49:03.656250000 +0200
***************
*** 2686,2694 ****
  
  (defun dired-pop-to-buffer (buf)
    "Pop up buffer BUF in a way suitable for Dired."
!   ;; Don't split window horizontally.  (Bug#1806)
!   (let (split-width-threshold)
!     (pop-to-buffer (get-buffer-create buf)))
    ;; If dired-shrink-to-fit is t, make its window fit its contents.
    (when dired-shrink-to-fit
      ;; Try to not delete window when we want to display less than
--- 2686,2698 ----
  
  (defun dired-pop-to-buffer (buf)
    "Pop up buffer BUF in a way suitable for Dired."
!   (lexical-let ((old-fun split-window-preferred-function)
! 		(old-window (selected-window)))
!     (let ((split-window-preferred-function
! 	   (lambda ()
! 	     (let (split-width-threshold)
! 	       (with-selected-window old-window (funcall old-fun))))))
!       (pop-to-buffer (get-buffer-create buf))))
    ;; If dired-shrink-to-fit is t, make its window fit its contents.
    (when dired-shrink-to-fit
      ;; Try to not delete window when we want to display less than