* [PATCH] image-dired-show-all-from-dir: reuse dired's default directory
@ 2025-01-02 20:00 Sacha Chua
2025-01-02 20:22 ` Stefan Kangas
0 siblings, 1 reply; 4+ messages in thread
From: Sacha Chua @ 2025-01-02 20:00 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 502 bytes --]
Hello, everyone!
With a tiny tweak, image-dired-show-all-from-dir can handle a bunch of
things that dired can handle already (view arbitrary list of files,
handle wildcards). This is how I've been using it to quickly look at the
most recent screenshots in a couple of directories:
https://sachachua.com/blog/2025/01/using-image-dired-to-browse-the-latest-screenshots-from-multiple-directories/
What do you think? I believe I have copyright
assignment papers on file, although this is a tiny change.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-image-dired-show-all-from-dir-Reuse-dired-s-default-.patch --]
[-- Type: text/x-diff, Size: 1811 bytes --]
From afc2b649cd2b26765f4a7fd4c6f3eac51c4018f5 Mon Sep 17 00:00:00 2001
From: Sacha Chua <sacha@sachachua.com>
Date: Thu, 2 Jan 2025 14:52:28 -0500
Subject: [PATCH] image-dired-show-all-from-dir: Reuse dired's
default-directory
* lisp/image/image-dired.el (image-dired-show-all-from-dir): Delegate
figuring out default-directory to dired. This handles the case where
image-dired is called with a cons cell that has a directory in the car
and a list of files in the cdr, which dired can handle, and therefore
allows image-dired-show-all-from-dir to show an arbitrary list of
images. It also means that image-dired-show-all-from-dir can handle
wildcards.
---
lisp/image/image-dired.el | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/lisp/image/image-dired.el b/lisp/image/image-dired.el
index 83745e88f09..06fbca6a3f7 100644
--- a/lisp/image/image-dired.el
+++ b/lisp/image/image-dired.el
@@ -630,7 +630,8 @@ image-dired-show-all-from-dir
(interactive "DShow thumbnails for directory: ")
(dired dir)
(dired-mark-files-regexp (image-dired--file-name-regexp))
- (let ((files (dired-get-marked-files nil nil nil t)))
+ (let ((files (dired-get-marked-files nil nil nil t))
+ (dired-default-directory default-directory))
(cond ((and (null (cdr files)))
(message "No image files in directory"))
((or (not image-dired-show-all-from-dir-max-files)
@@ -644,7 +645,7 @@ image-dired-show-all-from-dir
(let ((inhibit-message t))
(dired-unmark-all-marks))
(pop-to-buffer image-dired-thumbnail-buffer)
- (setq default-directory dir)
+ (setq default-directory dired-default-directory)
(image-dired--update-header-line))
(t (message "Image-Dired canceled")))))
--
2.43.0
[-- Attachment #3: Type: text/plain, Size: 7 bytes --]
Sacha
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] image-dired-show-all-from-dir: reuse dired's default directory
2025-01-02 20:00 [PATCH] image-dired-show-all-from-dir: reuse dired's default directory Sacha Chua
@ 2025-01-02 20:22 ` Stefan Kangas
2025-01-02 22:17 ` Sacha Chua
0 siblings, 1 reply; 4+ messages in thread
From: Stefan Kangas @ 2025-01-02 20:22 UTC (permalink / raw)
To: Sacha Chua, emacs-devel
Sacha Chua <sacha@sachachua.com> writes:
> Hello, everyone!
>
> With a tiny tweak, image-dired-show-all-from-dir can handle a bunch of
> things that dired can handle already (view arbitrary list of files,
> handle wildcards). This is how I've been using it to quickly look at the
> most recent screenshots in a couple of directories:
> https://sachachua.com/blog/2025/01/using-image-dired-to-browse-the-latest-screenshots-from-multiple-directories/
>
> What do you think? I believe I have copyright
> assignment papers on file, although this is a tiny change.
Thanks for the patch, and interesting use case.
I can't find the variable `dired-default-directory`, but I do see that a
function of that name was removed in Emacs 27. Where did you find that
variable, and which version of Emacs are you running? Could it be that
this variable is from a third-party package?
> From afc2b649cd2b26765f4a7fd4c6f3eac51c4018f5 Mon Sep 17 00:00:00 2001
> From: Sacha Chua <sacha@sachachua.com>
> Date: Thu, 2 Jan 2025 14:52:28 -0500
> Subject: [PATCH] image-dired-show-all-from-dir: Reuse dired's
> default-directory
>
> * lisp/image/image-dired.el (image-dired-show-all-from-dir): Delegate
> figuring out default-directory to dired. This handles the case where
> image-dired is called with a cons cell that has a directory in the car
> and a list of files in the cdr, which dired can handle, and therefore
> allows image-dired-show-all-from-dir to show an arbitrary list of
> images. It also means that image-dired-show-all-from-dir can handle
> wildcards.
> ---
> lisp/image/image-dired.el | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/lisp/image/image-dired.el b/lisp/image/image-dired.el
> index 83745e88f09..06fbca6a3f7 100644
> --- a/lisp/image/image-dired.el
> +++ b/lisp/image/image-dired.el
> @@ -630,7 +630,8 @@ image-dired-show-all-from-dir
> (interactive "DShow thumbnails for directory: ")
> (dired dir)
> (dired-mark-files-regexp (image-dired--file-name-regexp))
> - (let ((files (dired-get-marked-files nil nil nil t)))
> + (let ((files (dired-get-marked-files nil nil nil t))
> + (dired-default-directory default-directory))
> (cond ((and (null (cdr files)))
> (message "No image files in directory"))
> ((or (not image-dired-show-all-from-dir-max-files)
> @@ -644,7 +645,7 @@ image-dired-show-all-from-dir
> (let ((inhibit-message t))
> (dired-unmark-all-marks))
> (pop-to-buffer image-dired-thumbnail-buffer)
> - (setq default-directory dir)
> + (setq default-directory dired-default-directory)
> (image-dired--update-header-line))
> (t (message "Image-Dired canceled")))))
>
> --
> 2.43.0
>
>
> Sacha
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] image-dired-show-all-from-dir: reuse dired's default directory
2025-01-02 20:22 ` Stefan Kangas
@ 2025-01-02 22:17 ` Sacha Chua
2025-01-03 0:23 ` Stefan Kangas
0 siblings, 1 reply; 4+ messages in thread
From: Sacha Chua @ 2025-01-02 22:17 UTC (permalink / raw)
To: Stefan Kangas, emacs-devel
Stefan Kangas <stefankangas@gmail.com> writes:
Hello, Stefan!
> Thanks for the patch, and interesting use case.
> I can't find the variable `dired-default-directory`, but I do see that a
> function of that name was removed in Emacs 27. Where did you find that
> variable, and which version of Emacs are you running? Could it be that
> this variable is from a third-party package?
Oh! That's a coincidence, I hadn't known that was used before. We can
call it temp-default-directory or something else if you prefer. I called it
dired-default-directory because I just needed to temporarily store the
default-directory from the dired buffer so that we could copy it to the
image-dired-thumbnail-buffer, which is why it's a let-bound variable.
>> - (let ((files (dired-get-marked-files nil nil nil t)))
>> + (let ((files (dired-get-marked-files nil nil nil t))
>> + (dired-default-directory default-directory))
I'm on GNU Emacs 31.0.50 (build 2, x86_64-pc-linux-gnu, GTK+ Version
3.24.41, cairo version 1.18.0) of 2025-01-02.
Sacha
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] image-dired-show-all-from-dir: reuse dired's default directory
2025-01-02 22:17 ` Sacha Chua
@ 2025-01-03 0:23 ` Stefan Kangas
0 siblings, 0 replies; 4+ messages in thread
From: Stefan Kangas @ 2025-01-03 0:23 UTC (permalink / raw)
To: Sacha Chua, emacs-devel
Sacha Chua <sacha@sachachua.com> writes:
> Stefan Kangas <stefankangas@gmail.com> writes:
>
> Hello, Stefan!
>
>> Thanks for the patch, and interesting use case.
>> I can't find the variable `dired-default-directory`, but I do see that a
>> function of that name was removed in Emacs 27. Where did you find that
>> variable, and which version of Emacs are you running? Could it be that
>> this variable is from a third-party package?
>
> Oh! That's a coincidence, I hadn't known that was used before. We can
> call it temp-default-directory or something else if you prefer. I called it
> dired-default-directory because I just needed to temporarily store the
> default-directory from the dired buffer so that we could copy it to the
> image-dired-thumbnail-buffer, which is why it's a let-bound variable.
Ah, my bad. I got confused and thought it was supposed to be a special
variable.
I think your patch looks basically good, but let me take a proper look
before installing it.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-01-03 0:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-02 20:00 [PATCH] image-dired-show-all-from-dir: reuse dired's default directory Sacha Chua
2025-01-02 20:22 ` Stefan Kangas
2025-01-02 22:17 ` Sacha Chua
2025-01-03 0:23 ` Stefan Kangas
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).