Closed jeeger closed 5 months ago
This seems to work:
(defun dired-dwim-target-next-visible-skipping-preview-buffers ()
;; Return directories from all next visible windows with dired-mode buffers,
;; filtering out buffers that are used by dired-preview.
(mapcan (lambda (w)
(with-current-buffer (window-buffer w)
(when (and (eq major-mode 'dired-mode)
(not (seq-contains-p dired-preview--buffers (current-buffer))))
(list (dired-current-directory)))))
(delq (selected-window)
(window-list-1
(next-window nil 'nomini 'visible)
'nomini 'visible))))
(setq dired-dwim-target #'dired-dwim-target-next-visible-skipping-preview-buffers)
dired-dwim-target
automatically selects directories open in other dired buffers when set tot
(or some other functions). However, because the preview window is also in dired mode, it will get selected as the DWIM target, thus breaking the DWIM functionality. I'll see whether I can filter out the preview window from the DWIM target list.