Subject: bug#11651: Special display is not dedicated any more

From: martin rudalics <[email-masked]>
Date: Fri, 08 Jun 2012 20:18:19 +0200

> Something's wrong with the way the `dedicated' bit is set:
 >
 >   % src/emacs -Q --eval '(setq special-display-regexps (quote ("\\*.*\\*")))'
 >   C-h v values RET
 >   M-: (window-dedicated-p nil) RET
 >   q
 >
 > The M-: shows that the window is not marked dedicated as it should.
 > And the `q' shows the consequence: rather than hiding the frame, Emacs
 > switches to some other buffer.
 >
 > This was probably introduced in the last couple weeks.

Indeed.  I was fooled by a comment in `special-display-popup-frame'.
The old code had

        (let* ((frame
	       (with-current-buffer buffer
		 (make-frame (append args special-display-frame-alist))))
	      (window (frame-selected-window frame)))
	 (display-buffer-record-window 'frame window buffer)
          ;; FIXME: Use window--display-buffer-2?
	 (set-window-buffer window buffer)
	 ;; Reset list of WINDOW's previous buffers to nil.
	 (set-window-prev-buffers window nil)
	 (set-window-dedicated-p window t)
	 window)))))

but `make-frame' already puts BUFFER into the new frame so the
`set-window-buffer' is silly.  I changed this to

        (let ((frame
	      (with-current-buffer buffer
		(make-frame (append args special-display-frame-alist)))))
	 (window--display-buffer
	  buffer (frame-selected-window frame) 'frame t))))))

but `window--display-buffer' detected that BUFFER was already displayed
in the new window and decided not to deal with it.

Can you try replacing the snippet by

        (let* ((frame
	       (with-current-buffer buffer
		 (make-frame (append args special-display-frame-alist))))
	      (window (frame-selected-window frame)))
	 (display-buffer-record-window 'frame window buffer)
	 (set-window-dedicated-p window t)
	 window)))))

martin