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

From: Juri Linkov <[email-masked]>
Date: Mon, 16 Jun 2014 09:51:17 +0300

>> But the 24.3 code handles Roland's scenario by displaying *Completions*
>> in a third window.  At least it does so here.  What do you get?
>
> 24.3 displays *Completions* in the window with the dired buffer
> because the lru-window is the dired window in 24.3, but in 24.4
> the lru-window is the small window with *Marked Files*.
>
> Maybe it's possible to change window's timestamp after displaying
> *Marked Files* to make the dired window lru, to display *Completions*
> in it like in 24.3?

The problem is that `with-selected-window' calls `select-window' with
the non-nil arg `norecord' that doesn't update the window's use_time,
so the displayed window considered least-recently used.

I don't know how general this problem is, but at least for *Marked files*
the following patch causes the Dired window to be least-recently used,
thus avoiding using *Marked files* window to display *Completions*:

=== modified file 'lisp/dired.el'
--- lisp/dired.el	2014-05-08 19:22:43 +0000
+++ lisp/dired.el	2014-06-16 06:45:18 +0000
@@ -3107,6 +3107,7 @@ (defun dired-mark-pop-up (buffer-or-name
 	       '((window-height . fit-window-to-buffer)))
 	 #'(lambda (window _value)
 	     (with-selected-window window
+	       (select-window window) ;; use nil NORECORD to make window the most recently selected.
 	       (unwind-protect
 		   (apply function args)
 		 (when (window-live-p window)