GNU bug report logs - #1415
23.0.60; display-buffer doesn't honor NOT-THIS-WINDOW argument

Previous Next

Package: emacs;

Reported by: Helmut Eller <eller.helmut <at> gmail.com>

Date: Mon, 24 Nov 2008 04:20:02 UTC

Severity: normal

Done: martin rudalics <rudalics <at> gmx.at>

Bug is archived. No further changes may be made.

Full log


Message #10 received at 1415 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: Helmut Eller <eller.helmut <at> gmail.com>
Cc: 1415 <at> debbugs.gnu.org
Subject: Re: bug#1415: 23.0.60;	display-buffer doesn't honor NOT-THIS-WINDOW
 argument
Date: Mon, 24 Nov 2008 10:59:48 +0100
[Message part 1 (text/plain, inline)]
> I think that display-buffer returns sometimes the selected window even
> if the NOT-THIS-WINDOW argument is true.  Here is a test case:
>
> (progn
>   (defun display-buffer-checked (buffer)
>     (let ((selected (selected-window))
>           (window (display-buffer buffer t)))
>       (when (eq selected window)
>         (error "display-buffer returned selected window"))
>       window))
>
>   (let ((foo (get-buffer-create "foo"))
>         (bar (get-buffer-create "bar")))
>     (select-window (get-buffer-window "*scratch*"))
>     (save-selected-window
>       (select-window (display-buffer-checked foo)))
>     (save-selected-window
>       (select-window (display-buffer-checked bar)))))
>
>
> display-buffer-checked just calls display-buffer and checks that the
> returned window isn't the selected window.  From looking at the code of
> display-buffer, I would say that display-buffer returns the lru window
> even if that's the selected window.

Nice bug.  Thanks for the precise report and test case!

Emacs 22 handled this, but I'm too lazy to figure out how.

Please try the attached patch.

martin
[window.diff (text/plain, inline)]
*** window.el.~1.168.~	2008-11-18 22:26:34.390625000 +0100
--- window.el	2008-11-24 10:31:29.953125000 +0100
***************
*** 1038,1051 ****
  		     (window--try-to-split-window
  		      (get-lru-window frame-to-use t))))
  	   (window--display-buffer-2 buffer window-to-use)))
!      ((setq window-to-use
! 	    ;; Reuse an existing window.
! 	    (or (get-lru-window frame-to-use)
! 		(get-buffer-window buffer 'visible)
! 		(get-largest-window 'visible nil)
! 		(get-buffer-window buffer 0)
! 		(get-largest-window 0 nil)
! 		(frame-selected-window (funcall pop-up-frame-function))))
        (window--even-window-heights window-to-use)
        (window--display-buffer-2 buffer window-to-use)))))
  
--- 1038,1063 ----
  		     (window--try-to-split-window
  		      (get-lru-window frame-to-use t))))
  	   (window--display-buffer-2 buffer window-to-use)))
!      ((let ((window-to-undedicate
! 	     ;; When NOT-THIS-WINDOW is non-nil, temporarily dedicate
! 	     ;; the selected window to its buffer, to avoid that some of
! 	     ;; the routines below choose it.  (Bug#1415)
! 	     (and not-this-window
! 		  (not (window-dedicated-p (selected-window)))
! 		  (set-window-dedicated-p (selected-window) t)
! 		  (selected-window))))
! 	(unwind-protect
! 	    (setq window-to-use
! 		  ;; Reuse an existing window.
! 		  (or (get-lru-window frame-to-use)
! 		      (get-buffer-window buffer 'visible)
! 		      (get-largest-window 'visible)
! 		      (get-buffer-window buffer 0)
! 		      (get-largest-window 0)
! 		      (frame-selected-window (funcall pop-up-frame-function))))
! 	  (when (window-live-p window-to-undedicate)
! 	    ;; Restore dedicated status of selected window.
! 	    (set-window-dedicated-p window-to-undedicate nil))))
        (window--even-window-heights window-to-use)
        (window--display-buffer-2 buffer window-to-use)))))
  

This bug report was last modified 16 years and 258 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.