From c70fdcdd114659d5358256938013c22a70b18f07 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Wed, 27 Oct 2021 20:39:10 +0200 Subject: [PATCH] Increase image-dired-show-all-from-dir-max-files to 500 * lisp/image-dired.el (image-dired-show-all-from-dir-max-files): Increase default to 500 to ask for confirmation much less frequently. The old value was added before we had asynchronous generation of thumbnails, when a large number of files would lock up Emacs. Asking for confirmation could probably be disabled completely these days, but let's be conservative and set it to some large number of files for which some users might want to see a prompt. It can't hurt. (image-dired-show-all-from-dir): Never warn if above variable is nil. (image-dired-bookmark-jump): Let-bind above variable to nil instead of 'most-positive-fixnum'. * doc/emacs/dired.texi (Image-Dired): Don't mention the above variable, as it is no longer important enough to deserve the space. * etc/NEWS: Announce the above change. --- doc/emacs/dired.texi | 3 +-- etc/NEWS | 9 +++++++++ lisp/image-dired.el | 29 +++++++++++++++++++---------- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/doc/emacs/dired.texi b/doc/emacs/dired.texi index 9cdd4b805e6..387ccdf4a57 100644 --- a/doc/emacs/dired.texi +++ b/doc/emacs/dired.texi @@ -1509,8 +1509,7 @@ image-dired}. This prompts for a directory; specify one that has image files. This creates thumbnails for all the images in that directory, and displays them all in the thumbnail buffer. The thumbnails are generated in the background and are loaded as they -become available. This command asks for confirmation if the number of -image files exceeds @code{image-dired-show-all-from-dir-max-files}. +become available. With point in the thumbnail buffer, you can type @key{RET} (@code{image-dired-display-thumbnail-original-image}) to display a diff --git a/etc/NEWS b/etc/NEWS index 2106a62c8f5..e475a49b98d 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -233,6 +233,15 @@ The command 'bookmark-set' (bound to 'C-x r m') is now supported in the thumbnail view, and will create a bookmark that opens the current directory in Image-Dired. ++++ +*** 'image-dired-show-all-from-dir-max-files' has been increased to 500. +This option controls asking for confirmation when starting Image-Dired +in a directory with many files. However, Image-Dired creates +thumbnails in the background these days, so this is not as important +as it used to be, back when entering a large directory could lock up +Emacs for tens of seconds. In addition, you can now customize this +option to nil to disable this confirmation completely. + ** Dired --- diff --git a/lisp/image-dired.el b/lisp/image-dired.el index 2eddf3c9e0b..1239821b019 100644 --- a/lisp/image-dired.el +++ b/lisp/image-dired.el @@ -573,11 +573,15 @@ Used by `image-dired-copy-with-exif-file-name'." :type 'string :version "29.1") -(defcustom image-dired-show-all-from-dir-max-files 100 +(defcustom image-dired-show-all-from-dir-max-files 500 "Maximum number of files in directory before prompting. -If there are more files than this in a selected directory, the -`image-dired-show-all-from-dir' command will show a prompt." - :type 'integer + +If there are more image files than this in a selected directory, +the `image-dired-show-all-from-dir' command will ask for +confirmation before creating the thumbnail buffer. If this +variable is nil, it will never ask." + :type '(choice integer + (const :tag "Disable warning" nil)) :version "29.1") (defvar image-dired-debug nil @@ -1125,15 +1129,20 @@ thumbnail buffer to be selected." ;;;###autoload (defun image-dired-show-all-from-dir (dir) - "Make a preview buffer for all images in DIR and display it. -If the number of files in DIR matching `image-file-name-regexp' -exceeds `image-dired-show-all-from-dir-max-files', a warning will be -displayed." + "Make a thumbnail buffer for all images in DIR and display it. +Any file matching `image-file-name-regexp' is considered an image +file. + +If the number of image files in DIR exceeds +`image-dired-show-all-from-dir-max-files', ask for confirmation +before creating the thumbnail buffer. If that variable is nil, +never ask for confirmation." (interactive "DImage Dired: ") (dired dir) (dired-mark-files-regexp (image-file-name-regexp)) (let ((files (dired-get-marked-files))) - (if (or (<= (length files) image-dired-show-all-from-dir-max-files) + (if (or (not image-dired-show-all-from-dir-max-files) + (<= (length files) image-dired-show-all-from-dir-max-files) (and (> (length files) image-dired-show-all-from-dir-max-files) (y-or-n-p (format @@ -2844,7 +2853,7 @@ tags to their respective image file. Internal function used by (defun image-dired-bookmark-jump (bookmark) "Default bookmark handler for Image-Dired buffers." ;; User already cached thumbnails, so disable any checking. - (let ((image-dired-show-all-from-dir-max-files most-positive-fixnum)) + (let ((image-dired-show-all-from-dir-max-files nil)) (image-dired (bookmark-prop-get bookmark 'location)) ;; TODO: Go to the bookmarked file, if it exists. ;; (bookmark-prop-get bookmark 'image-dired-file) -- 2.39.2