]> git.eshelyaron.com Git - emacs.git/commitdiff
image-dired: Don't show thumbnails if there are no image files
authorStefan Kangas <stefan@marxist.se>
Wed, 27 Oct 2021 19:04:10 +0000 (21:04 +0200)
committerStefan Kangas <stefan@marxist.se>
Wed, 27 Oct 2021 19:05:16 +0000 (21:05 +0200)
* lisp/image-dired.el (image-dired-show-all-from-dir): Don't show
thumbnail buffer if there are no image files.

lisp/image-dired.el

index 1239821b0198ae7573822d476edde2fef57b3859..250a76ba126796a24cb5d9ab5ea279b86d0126fa 100644 (file)
@@ -1140,18 +1140,19 @@ 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 (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
-                   "Directory contains more than %d image files.  Proceed? "
-                   image-dired-show-all-from-dir-max-files))))
-        (progn
-          (image-dired-display-thumbs)
-          (pop-to-buffer image-dired-thumbnail-buffer))
-      (message "Canceled."))))
+  (let ((files (dired-get-marked-files nil nil nil t)))
+    (cond ((and (null (cdr files)))
+           (message "No image files in directory"))
+          ((or (not image-dired-show-all-from-dir-max-files)
+               (<= (length (cdr files)) image-dired-show-all-from-dir-max-files)
+               (and (> (length (cdr files)) image-dired-show-all-from-dir-max-files)
+                    (y-or-n-p
+                     (format
+                      "Directory contains more than %d image files.  Proceed?"
+                      image-dired-show-all-from-dir-max-files))))
+           (image-dired-display-thumbs)
+           (pop-to-buffer image-dired-thumbnail-buffer))
+          (t (message "Image-Dired canceled")))))
 
 ;;;###autoload
 (defalias 'image-dired 'image-dired-show-all-from-dir)