GNU bug report logs - #35385
27.0.50; Make dired-dwim-target aware of other frames

Previous Next

Package: emacs;

Reported by: "Basil L. Contovounesios" <contovob <at> tcd.ie>

Date: Mon, 22 Apr 2019 22:04:01 UTC

Severity: wishlist

Tags: patch

Found in version 27.0.50

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #25 received at 35385 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>,
 martin rudalics <rudalics <at> gmx.at>, 35385 <at> debbugs.gnu.org
Subject: Re: bug#35385: 27.0.50; Make dired-dwim-target aware of other frames
Date: Thu, 19 Sep 2019 00:48:30 +0300
[Message part 1 (text/plain, inline)]
> I'd like to elaborate on my comments: the thought was that instead of
> extending the scope of the search for the first random Dired window
> from the selected frame to all frames, would it be better to improve the
> heuristic of finding the window that the user really meant to use
> (remember that the user option name contains the word "DWIM").
>
> The proposed heuristic was to use `get-mru-window' to get
> the most recently used window from all frames, and even
> better way is to traverse all windows ordered by their visiting
> recency on all frames to find the window with Dired mode buffer.

I can't find an existing function that would sort windows by recency,
but fortunately the implementation is straightforward:

  (sort (window-list-1)
        (lambda (a b)
          (> (window-use-time a)
             (window-use-time b))))

using `>' gives the mru order, `<' - lru order.

BTW, while looking at windows walking functions, I noticed
an opportunity for simplification.

Martin, could you please confirm if I'm not mistaken with this patch:

[walk-windows-simplify.patch (text/x-diff, inline)]
diff --git a/lisp/window.el b/lisp/window.el
index cf733153b8..aedebd9d46 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -2217,6 +2217,10 @@ walk-windows
 
 - A frame means consider all windows on that frame only.
 
+If ALL-FRAMES specifies a frame, the first window walked is the
+first window on that frame (the one returned by `frame-first-window'),
+not necessarily the selected window.
+
 Anything else means consider all windows on the selected frame
 and no others.
 
@@ -2226,14 +2230,11 @@ walk-windows
   ;; back to it.
   (when (window-minibuffer-p)
     (setq minibuf t))
-  ;; Make sure to not mess up the order of recently selected
-  ;; windows.  Use `save-selected-window' and `select-window'
-  ;; with second argument non-nil for this purpose.
-  (save-selected-window
-    (when (framep all-frames)
-      (select-window (frame-first-window all-frames) 'norecord))
-    (dolist (walk-windows-window (window-list-1 nil minibuf all-frames))
-      (funcall fun walk-windows-window))))
+  (dolist (walk-windows-window
+           (window-list-1 (and (framep all-frames)
+                               (frame-first-window all-frames))
+                          minibuf all-frames))
+      (funcall fun walk-windows-window)))
 
 (defun window-at-side-p (&optional window side)
   "Return t if WINDOW is at SIDE of its containing frame.

This bug report was last modified 4 years and 343 days ago.

Previous Next


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