diff options
| author | Stefan Kangas | 2021-11-12 04:10:40 +0100 |
|---|---|---|
| committer | Stefan Kangas | 2021-11-12 04:27:35 +0100 |
| commit | 1d95cef0feeb8276abda379d978aa4d40c4cddde (patch) | |
| tree | 9a131da15b8dc7c6867fe1aa69e93428aa128d93 | |
| parent | 9ea7e7c4d4867422e4d4f94c764d529b96140f5d (diff) | |
| download | emacs-1d95cef0feeb8276abda379d978aa4d40c4cddde.tar.gz emacs-1d95cef0feeb8276abda379d978aa4d40c4cddde.zip | |
image-dired: Revamp slideshow functionality
* lisp/image-dired.el
(image-dired-slideshow-delay): New defcustom.
(image-dired--slideshow-initial): New defvar.
(image-dired-slideshow-start): Don't show any prompts when starting a
slideshow, unless user gave a negative prefix argument. Use the value
of the above new defcustom as the default delay.
(image-dired-slideshow-stop): Don't count number of images. Instead,
continue the slideshow until the next command.
(image-dired-slideshow-step): Use the correct buffer.
(image-dired-slideshow-count, image-dired-slideshow-times): Make
obsolete.
(image-dired--slideshow-timer): Rename from
'image-dired-slideshow-timer'. Make the old name into an obsolete
variable alias.
(image-dired-display-image-mode-map)
(image-dired-thumbnail-mode-map): Bind 'image-dired-slideshow-start'
to "S".
(image-dired-thumbnail-mode-menu): Add 'image-dired-slideshow-start'.
| -rw-r--r-- | etc/NEWS | 9 | ||||
| -rw-r--r-- | lisp/image-dired.el | 81 |
2 files changed, 63 insertions, 27 deletions
| @@ -426,6 +426,15 @@ used for images that are flagged for deletion in the Dired buffer | |||
| 426 | associated with Image-Dired. | 426 | associated with Image-Dired. |
| 427 | 427 | ||
| 428 | --- | 428 | --- |
| 429 | *** The 'image-dired-slideshow-start' command has been revamped. | ||
| 430 | It no longer inconveniently prompts for a number of images and a | ||
| 431 | delay: it runs indefinitely, but stops automatically on any command. | ||
| 432 | You can set the delay with a prefix argument, or a negative prefix | ||
| 433 | argument to prompt anyways. Customize the user option | ||
| 434 | 'image-dired-slideshow-delay' to change the default, which is 5 | ||
| 435 | seconds. It is bound to 'S' in the thumbnail and display buffer. | ||
| 436 | |||
| 437 | --- | ||
| 429 | *** Support for bookmark.el. | 438 | *** Support for bookmark.el. |
| 430 | The command 'bookmark-set' (bound to 'C-x r m') is now supported in | 439 | The command 'bookmark-set' (bound to 'C-x r m') is now supported in |
| 431 | the thumbnail view, and will create a bookmark that opens the current | 440 | the thumbnail view, and will create a bookmark that opens the current |
diff --git a/lisp/image-dired.el b/lisp/image-dired.el index 4015f42c6b8..8e5a6d898c0 100644 --- a/lisp/image-dired.el +++ b/lisp/image-dired.el | |||
| @@ -1580,6 +1580,7 @@ You probably want to use this together with | |||
| 1580 | (define-key map "R" 'image-dired-rotate-original-right) | 1580 | (define-key map "R" 'image-dired-rotate-original-right) |
| 1581 | 1581 | ||
| 1582 | (define-key map "D" 'image-dired-thumbnail-set-image-description) | 1582 | (define-key map "D" 'image-dired-thumbnail-set-image-description) |
| 1583 | (define-key map "S" #'image-dired-slideshow-start) | ||
| 1583 | (define-key map "\C-d" 'image-dired-delete-char) | 1584 | (define-key map "\C-d" 'image-dired-delete-char) |
| 1584 | (define-key map " " 'image-dired-display-next-thumbnail-original) | 1585 | (define-key map " " 'image-dired-display-next-thumbnail-original) |
| 1585 | (define-key map (kbd "DEL") 'image-dired-display-previous-thumbnail-original) | 1586 | (define-key map (kbd "DEL") 'image-dired-display-previous-thumbnail-original) |
| @@ -1627,6 +1628,7 @@ You probably want to use this together with | |||
| 1627 | ["Tag current or marked thumbnails" image-dired-tag-thumbnail] | 1628 | ["Tag current or marked thumbnails" image-dired-tag-thumbnail] |
| 1628 | ["Remove tag from current or marked thumbnails" | 1629 | ["Remove tag from current or marked thumbnails" |
| 1629 | image-dired-tag-thumbnail-remove] | 1630 | image-dired-tag-thumbnail-remove] |
| 1631 | ["Start slideshow" image-dired-slideshow-start] | ||
| 1630 | "---" | 1632 | "---" |
| 1631 | ("View Options" | 1633 | ("View Options" |
| 1632 | ["Toggle movement tracking" image-dired-toggle-movement-tracking | 1634 | ["Toggle movement tracking" image-dired-toggle-movement-tracking |
| @@ -1640,6 +1642,7 @@ You probably want to use this together with | |||
| 1640 | 1642 | ||
| 1641 | (defvar image-dired-display-image-mode-map | 1643 | (defvar image-dired-display-image-mode-map |
| 1642 | (let ((map (make-sparse-keymap))) | 1644 | (let ((map (make-sparse-keymap))) |
| 1645 | (define-key map "S" #'image-dired-slideshow-start) | ||
| 1643 | ;; Disable keybindings from `image-mode-map' that doesn't make sense here. | 1646 | ;; Disable keybindings from `image-mode-map' that doesn't make sense here. |
| 1644 | (define-key map "o" nil) ; image-save | 1647 | (define-key map "o" nil) ; image-save |
| 1645 | (define-key map "n" nil) ; image-next-file | 1648 | (define-key map "n" nil) ; image-next-file |
| @@ -1755,44 +1758,60 @@ With prefix argument ARG, create thumbnails even if they already exist | |||
| 1755 | (image-dired-create-thumb curr-file thumb-name))))) | 1758 | (image-dired-create-thumb curr-file thumb-name))))) |
| 1756 | 1759 | ||
| 1757 | 1760 | ||
| 1758 | ;;; Slideshow. | 1761 | ;;; Slideshow |
| 1759 | 1762 | ||
| 1760 | (defvar image-dired-slideshow-timer nil | 1763 | (defcustom image-dired-slideshow-delay 5.0 |
| 1761 | "Slideshow timer.") | 1764 | "Seconds to wait before showing the next image in a slideshow. |
| 1765 | This is used by `image-dired-slideshow-start'." | ||
| 1766 | :type 'float | ||
| 1767 | :version "29.1") | ||
| 1762 | 1768 | ||
| 1763 | (defvar image-dired-slideshow-count 0 | 1769 | (define-obsolete-variable-alias 'image-dired-slideshow-timer |
| 1764 | "Keeping track on number of images in slideshow.") | 1770 | 'image-dired--slideshow-timer "29.1") |
| 1771 | (defvar image-dired--slideshow-timer nil | ||
| 1772 | "Slideshow timer.") | ||
| 1765 | 1773 | ||
| 1766 | (defvar image-dired-slideshow-times 0 | 1774 | (defvar image-dired--slideshow-initial nil) |
| 1767 | "Number of pictures to display in slideshow.") | ||
| 1768 | 1775 | ||
| 1769 | (defun image-dired-slideshow-step () | 1776 | (defun image-dired-slideshow-step () |
| 1770 | "Step to next file, if `image-dired-slideshow-times' has not been reached." | 1777 | "Step to next image in a slideshow." |
| 1771 | (if (< image-dired-slideshow-count image-dired-slideshow-times) | 1778 | (if-let ((buf (get-buffer image-dired-thumbnail-buffer))) |
| 1772 | (progn | 1779 | (with-current-buffer buf |
| 1773 | (message "%s" (1+ image-dired-slideshow-count)) | 1780 | (image-dired-display-next-thumbnail-original)) |
| 1774 | (setq image-dired-slideshow-count (1+ image-dired-slideshow-count)) | ||
| 1775 | (image-dired-next-line-and-display)) | ||
| 1776 | (image-dired-slideshow-stop))) | 1781 | (image-dired-slideshow-stop))) |
| 1777 | 1782 | ||
| 1778 | (defun image-dired-slideshow-start () | 1783 | (defun image-dired-slideshow-start (&optional arg) |
| 1779 | "Start slideshow. | 1784 | "Start a slideshow. |
| 1780 | Ask user for number of images to show and the delay in between." | 1785 | Wait `image-dired-slideshow-delay' seconds before showing the |
| 1781 | (interactive) | 1786 | next image. |
| 1782 | (setq image-dired-slideshow-count 0) | 1787 | |
| 1783 | (setq image-dired-slideshow-times (string-to-number (read-string "How many: "))) | 1788 | With prefix argument ARG, wait that many seconds before going to |
| 1784 | (let ((repeat (string-to-number | 1789 | the next image. |
| 1785 | (read-string | 1790 | |
| 1786 | "Delay, in seconds. Decimals are accepted : " "1")))) | 1791 | With a negative prefix argument, prompt user for the delay." |
| 1787 | (setq image-dired-slideshow-timer | 1792 | (interactive "P" image-dired-thumbnail-mode image-dired-display-image-mode) |
| 1793 | (let ((delay (if (> arg 0) | ||
| 1794 | arg | ||
| 1795 | (string-to-number | ||
| 1796 | (read-string | ||
| 1797 | (let ((delay (number-to-string image-dired-slideshow-delay))) | ||
| 1798 | (format-prompt "Delay, in seconds. Decimals are accepted" delay) delay)))))) | ||
| 1799 | (setq image-dired--slideshow-timer | ||
| 1788 | (run-with-timer | 1800 | (run-with-timer |
| 1789 | 0 repeat | 1801 | 0 delay |
| 1790 | 'image-dired-slideshow-step)))) | 1802 | 'image-dired-slideshow-step)) |
| 1803 | (add-hook 'post-command-hook 'image-dired-slideshow-stop) | ||
| 1804 | (setq image-dired--slideshow-initial t) | ||
| 1805 | (message "Running slideshow; use any command to stop"))) | ||
| 1791 | 1806 | ||
| 1792 | (defun image-dired-slideshow-stop () | 1807 | (defun image-dired-slideshow-stop () |
| 1793 | "Cancel slideshow." | 1808 | "Cancel slideshow." |
| 1794 | (interactive) | 1809 | ;; Make sure we don't immediately stop after |
| 1795 | (cancel-timer image-dired-slideshow-timer)) | 1810 | ;; `image-dired-slideshow-start'. |
| 1811 | (unless image-dired--slideshow-initial | ||
| 1812 | (remove-hook 'post-command-hook 'image-dired-slideshow-stop) | ||
| 1813 | (cancel-timer image-dired--slideshow-timer)) | ||
| 1814 | (setq image-dired--slideshow-initial nil)) | ||
| 1796 | 1815 | ||
| 1797 | 1816 | ||
| 1798 | ;;; Thumbnail mode (cont. 3) | 1817 | ;;; Thumbnail mode (cont. 3) |
| @@ -2975,6 +2994,14 @@ Dired." | |||
| 2975 | (cons (list tag file) (cdr image-dired-tag-file-list)))) | 2994 | (cons (list tag file) (cdr image-dired-tag-file-list)))) |
| 2976 | (setq image-dired-tag-file-list (list (list tag file)))))) | 2995 | (setq image-dired-tag-file-list (list (list tag file)))))) |
| 2977 | 2996 | ||
| 2997 | (defvar image-dired-slideshow-count 0 | ||
| 2998 | "Keeping track on number of images in slideshow.") | ||
| 2999 | (make-obsolete-variable 'image-dired-slideshow-count "no longer used." "29.1") | ||
| 3000 | |||
| 3001 | (defvar image-dired-slideshow-times 0 | ||
| 3002 | "Number of pictures to display in slideshow.") | ||
| 3003 | (make-obsolete-variable 'image-dired-slideshow-times "no longer used." "29.1") | ||
| 3004 | |||
| 2978 | (define-obsolete-function-alias 'image-dired-create-display-image-buffer | 3005 | (define-obsolete-function-alias 'image-dired-create-display-image-buffer |
| 2979 | #'ignore "29.1") | 3006 | #'ignore "29.1") |
| 2980 | (define-obsolete-function-alias 'image-dired-create-gallery-lists | 3007 | (define-obsolete-function-alias 'image-dired-create-gallery-lists |