From a02b37cbcdbee4c773336a82f2109b1c03467107 Mon Sep 17 00:00:00 2001 From: Morgan Smith Date: Thu, 7 Nov 2024 14:24:01 -0500 Subject: [PATCH] Reuse display windows in image-dired * lisp/image/image-dired.el(image-dired-display-image): Reuse the windows used by the previous buffer. --- lisp/image/image-dired.el | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lisp/image/image-dired.el b/lisp/image/image-dired.el index 1928b0a2955..37f23665755 100644 --- a/lisp/image/image-dired.el +++ b/lisp/image/image-dired.el @@ -1268,11 +1268,15 @@ image-dired-display-image (setq file (expand-file-name file)) (when (not (file-exists-p file)) (error "No such file: %s" file)) - (let ((buf (get-buffer image-dired-display-image-buffer)) - (cur-win (selected-window))) + (let* ((buf (get-buffer image-dired-display-image-buffer)) + (windows (and buf + (get-buffer-window-list buf t t))) + (cur-win (selected-window))) (when buf (kill-buffer buf)) (when-let ((buf (find-file-noselect file nil t))) + (dolist (window windows) + (set-window-buffer window buf)) (pop-to-buffer buf) (rename-buffer image-dired-display-image-buffer) (if (string-match (image-file-name-regexp) file) -- 2.46.0