image-dired: Fix behavior of slideshow command

* lisp/image-dired.el (image-dired-slideshow-start): Fix behavior
to match documentation.  Minor simplification of docstring.
This commit is contained in:
Stefan Kangas 2021-12-07 12:59:18 +01:00
parent 8aa2aac500
commit 00e6aeacf2
2 changed files with 17 additions and 13 deletions

View file

@ -583,13 +583,16 @@ used for images that are flagged for deletion in the Dired buffer
associated with Image-Dired.
---
*** The 'image-dired-slideshow-start' command has been revamped.
*** 'image-dired-slideshow-start' is now bound to 'S'.
It is bound in both the thumbnail and display buffer.
---
*** The 'image-dired-slideshow-start' command no longer prompts.
It no longer inconveniently prompts for a number of images and a
delay: it runs indefinitely, but stops automatically on any command.
You can set the delay with a prefix argument, or a negative prefix
argument to prompt anyways. Customize the user option
'image-dired-slideshow-delay' to change the default, which is 5
seconds. It is bound to 'S' in the thumbnail and display buffer.
argument to prompt for a delay. Customize the user option
'image-dired-slideshow-delay' to change the default from 5 seconds.
---
*** Support for bookmark.el.

View file

@ -1777,21 +1777,22 @@ This is used by `image-dired-slideshow-start'."
(image-dired-slideshow-stop)))
(defun image-dired-slideshow-start (&optional arg)
"Start a slideshow.
Wait `image-dired-slideshow-delay' seconds before showing the
next image.
"Start a slideshow, waiting `image-dired-slideshow-delay' between images.
With prefix argument ARG, wait that many seconds before going to
the next image.
With a negative prefix argument, prompt user for the delay."
(interactive "P" image-dired-thumbnail-mode image-dired-display-image-mode)
(let ((delay (if (> arg 0)
arg
(string-to-number
(read-string
(let ((delay (number-to-string image-dired-slideshow-delay)))
(format-prompt "Delay, in seconds. Decimals are accepted" delay) delay))))))
(let ((delay (if (not arg)
image-dired-slideshow-delay
(if (> arg 0)
arg
(string-to-number
(let ((delay (number-to-string image-dired-slideshow-delay)))
(read-string
(format-prompt "Delay, in seconds. Decimals are accepted" delay))
delay))))))
(setq image-dired--slideshow-timer
(run-with-timer
0 delay