From: Morgan Smith <Morgan.J.Smith@outlook.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: martin rudalics <rudalics@gmx.at>,
74246@debbugs.gnu.org, stefankangas@gmail.com
Subject: bug#74246: [PATCH] Reuse display windows in image-dired
Date: Wed, 27 Nov 2024 19:32:43 -0500 [thread overview]
Message-ID: <CH3PR84MB34249702569748082C9BBF9CC5292@CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <86a5dqm9gl.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 23 Nov 2024 14:16:26 +0200")
[-- Attachment #1: Type: text/plain, Size: 1631 bytes --]
Eli Zaretskii <eliz@gnu.org> writes:
> Ping! Morgan, could you please try Martin's suggestions and report
> back?
>
>>
>> FWIW, I would rewrite 'image-dired-display-image' as the (largely
>> untested)
>>
>> (defun image-dired-display-image (file &optional _ignored)
>> "Display image FILE in the image buffer window.
>> If FILE is an image, the window will use `image-dired-image-mode'
>> which is based on `image-mode'."
>> (declare (advertised-calling-convention (file) "29.1"))
>> (setq file (expand-file-name file))
>> (when (not (file-exists-p file))
>> (error "No such file: %s" file))
>> (let* ((buffer (get-buffer-create image-dired-display-image-buffer))
>> (window (get-buffer-window buffer)))
>> (find-file-noselect-1 buffer file nil t nil nil)
>> (with-current-buffer buffer
>> (if (string-match (image-file-name-regexp) file)
>> (image-dired-image-mode)
>> ;; Support visiting PDF files.
>> (normal-mode)))
>>
>> (unless window
>> (display-buffer buffer))))
>>
>> instead of doing all that 'kill-buffer' (which could delete the selected
>> window as a side-effect so the final 'select-window' will throw an
>> error) 'rename-buffer' rigmarole.
>>
>> martin
I initially explored this option but was weary to use
'find-file-noselect-1` as it looks like it should be an internal
function and is used only in the file it's defined in.
However, I do like this solution the most. Attached is a patch almost
identical to the proposed function. The proposed function would be
perfect if it contained the line '(display-buffer buffer t)'.
Morgan
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Reuse-display-windows-in-image-dired-bug-74246.patch --]
[-- Type: text/x-patch, Size: 1569 bytes --]
From 7d0d9133b5276565589aadea9c0804522ed3cc64 Mon Sep 17 00:00:00 2001
From: Morgan Smith <Morgan.J.Smith@outlook.com>
Date: Wed, 27 Nov 2024 19:22:27 -0500
Subject: [PATCH] Reuse display windows in image-dired (bug#74246)
* lisp/image/image-dired.el(image-dired-display-image): Reuse
the buffer if it exists.
---
lisp/image/image-dired.el | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/lisp/image/image-dired.el b/lisp/image/image-dired.el
index 83745e88f09..29863acea8e 100644
--- a/lisp/image/image-dired.el
+++ b/lisp/image/image-dired.el
@@ -1268,18 +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)))
- (when buf
- (kill-buffer buf))
- (when-let* ((buf (find-file-noselect file nil t)))
- (pop-to-buffer buf)
- (rename-buffer image-dired-display-image-buffer)
+ (let ((buf (find-file-noselect-1
+ (get-buffer-create image-dired-display-image-buffer)
+ file nil t nil nil)))
+ (display-buffer buf t)
+ (with-current-buffer buf
(if (string-match (image-file-name-regexp) file)
(image-dired-image-mode)
;; Support visiting PDF files.
- (normal-mode))
- (select-window cur-win))))
+ (normal-mode)))))
(defun image-dired-display-this (&optional arg)
"Display current thumbnail's original image in display buffer.
--
2.46.0
next prev parent reply other threads:[~2024-11-28 0:32 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-07 20:19 bug#74246: [PATCH] Reuse display windows in image-dired Morgan Smith
2024-11-09 11:37 ` Eli Zaretskii
2024-11-09 17:36 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-23 12:16 ` Eli Zaretskii
2024-11-28 0:32 ` Morgan Smith [this message]
2024-11-28 9:28 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-28 18:27 ` Juri Linkov
2024-11-29 15:53 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-30 18:03 ` Juri Linkov
2024-12-01 8:46 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-02 7:42 ` Juri Linkov
2024-12-02 11:22 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-03 7:47 ` Juri Linkov
2024-12-03 8:25 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-03 17:24 ` Juri Linkov
2024-12-04 7:59 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-04 17:18 ` Juri Linkov
2024-12-05 9:23 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-05 17:54 ` Juri Linkov
2024-12-06 8:33 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-07 17:13 ` Juri Linkov
2024-12-08 16:55 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-09 19:16 ` Juri Linkov
2024-12-10 15:55 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-10 17:30 ` Juri Linkov
2024-12-11 9:38 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-12 7:52 ` Juri Linkov
2024-12-12 9:23 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-12 16:40 ` Juri Linkov
2024-12-12 17:24 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-12 18:42 ` Juri Linkov
2024-12-13 9:19 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-14 18:19 ` Juri Linkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CH3PR84MB34249702569748082C9BBF9CC5292@CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM \
--to=morgan.j.smith@outlook.com \
--cc=74246@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=rudalics@gmx.at \
--cc=stefankangas@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.