Subject: bug#17554: 24.3.91; [Regression] re-usage of dired *Marked Files* buffer window

From: Juri Linkov <[email-masked]>
Date: Tue, 10 Jun 2014 03:12:08 +0300

>> > Am I missing something?
>>
>> This is how `display-buffer-use-some-window' works:
>> it calls `get-lru-window' to get the least recently used window
>> which is `*Marked Files*' in this case.
>
> I see.  Thanks for your efforts to get this fixed.

While the latest patch with `display-buffer-at-bottom' provides a better
behavior for displaying *Completions*, I'm afraid it can't be installed
into emacs-24 branch because it changes the behavior of *Completions*
instead of just fixing the regression.

Since `get-lru-window' has a higher precedence than `get-largest-window'
in `display-buffer-use-some-window', we need to find a way to
mark the *Marked Files* window as dedicated to not use it
for displaying *Compilations*.

I tried to set `dedicated' in the window action alist:

=== modified file 'lisp/dired.el'
--- lisp/dired.el	2014-05-08 19:22:43 +0000
+++ lisp/dired.el	2014-06-10 00:02:14 +0000
@@ -3104,7 +3104,8 @@ (defun dired-mark-pop-up (buffer-or-name
 	(with-current-buffer-window
 	 buffer
 	 (cons 'display-buffer-below-selected
-	       '((window-height . fit-window-to-buffer)))
+	       '((window-height . fit-window-to-buffer)
+		 (dedicated . t)))
 	 #'(lambda (window _value)
 	     (with-selected-window window
 	       (unwind-protect

but this doesn't seem to work.  Then I found a workable solution:

=== modified file 'lisp/dired.el'
--- lisp/dired.el	2014-05-08 19:22:43 +0000
+++ lisp/dired.el	2014-06-10 00:08:38 +0000
@@ -3099,7 +3099,11 @@ (defun dired-mark-pop-up (buffer-or-name
 	  ;; If FILES defaulted to the current line's file.
 	  (= (length files) 1))
       (apply function args)
-    (let ((buffer (get-buffer-create (or buffer-or-name " *Marked Files*"))))
+    (let ((buffer (get-buffer-create (or buffer-or-name " *Marked Files*")))
+	  (temp-buffer-window-show-hook
+	   (cons (lambda ()
+		   (set-window-dedicated-p window t))
+		 temp-buffer-window-show-hook)))
       (with-current-buffer buffer
 	(with-current-buffer-window
 	 buffer

But it's too ugly and produces compilation warning
"reference to free variable `window'".

Maybe Martin has better ideas?