diff options
author | Glenn Morris <rgm@gnu.org> | 2013-02-15 19:29:39 -0800 |
---|---|---|
committer | Glenn Morris <rgm@gnu.org> | 2013-02-15 19:29:39 -0800 |
commit | c0211c4e370ec5fb46b90764235282d098ca21c1 (patch) | |
tree | 67e77fdf18df591f7931ae598cc9823362968cf1 /lisp/image.el | |
parent | 6b6d804b1e278b465ba778bbd10bb008dfe13b21 (diff) |
Add commands for navigating multi-frame images
* lisp/image.el (image-nth-frame): New, split from image-animate-timeout.
(image-animate-timeout): Use image-nth-frame.
* lisp/image-mode.el (image-goto-frame, image-next-frame)
(image-previous-frame): New commands.
(image-mode-map): Add new frame commands.
* etc/NEWS: Mention this.
Diffstat (limited to 'lisp/image.el')
-rw-r--r-- | lisp/image.el | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lisp/image.el b/lisp/image.el index e0521ad065a..b03a634d060 100644 --- a/lisp/image.el +++ b/lisp/image.el @@ -660,6 +660,17 @@ number, play until that number of seconds has elapsed." (defvar-local image-current-frame nil "The frame index of the current animated image.") +(defun image-nth-frame (image n &optional nocheck) + "Show frame N of IMAGE. +Frames are indexed from 0. Optional argument NOCHECK non-nil means +do not check N is within the range of frames present in the image." + (unless nocheck + (if (< n 0) (setq n 0) + (setq n (min n (1- (car (image-animated-p image))))))) + (plist-put (cdr image) :index n) + (setq image-current-frame n) + (force-window-update)) + ;; FIXME? The delay may not be the same for different sub-images, ;; hence we need to call image-animated-p to return it. ;; But it also returns count, so why do we bother passing that as an @@ -674,9 +685,7 @@ LIMIT determines when to stop. If t, loop forever. If nil, stop after displaying the last animation frame. Otherwise, stop after LIMIT seconds have elapsed. The minimum delay between successive frames is 0.01s." - (plist-put (cdr image) :index n) - (setq image-current-frame n) - (force-window-update) + (image-nth-frame image n t) (setq n (1+ n)) (let* ((time (float-time)) (animation (image-animated-p image)) |