summaryrefslogtreecommitdiff
path: root/lisp/image-mode.el
diff options
context:
space:
mode:
authorGlenn Morris <rgm@gnu.org>2013-02-15 19:29:39 -0800
committerGlenn Morris <rgm@gnu.org>2013-02-15 19:29:39 -0800
commitc0211c4e370ec5fb46b90764235282d098ca21c1 (patch)
tree67e77fdf18df591f7931ae598cc9823362968cf1 /lisp/image-mode.el
parent6b6d804b1e278b465ba778bbd10bb008dfe13b21 (diff)
downloademacs-c0211c4e370ec5fb46b90764235282d098ca21c1.tar.gz
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-mode.el')
-rw-r--r--lisp/image-mode.el34
1 files changed, 34 insertions, 0 deletions
diff --git a/lisp/image-mode.el b/lisp/image-mode.el
index fcbea945714..e539848675c 100644
--- a/lisp/image-mode.el
+++ b/lisp/image-mode.el
@@ -340,6 +340,9 @@ call."
(define-key map (kbd "S-SPC") 'image-scroll-down)
(define-key map (kbd "DEL") 'image-scroll-down)
(define-key map (kbd "RET") 'image-toggle-animation)
+ (define-key map "F" 'image-goto-frame)
+ (define-key map "f" 'image-next-frame)
+ (define-key map "b" 'image-previous-frame)
(define-key map "n" 'image-next-file)
(define-key map "p" 'image-previous-file)
(define-key map [remap forward-char] 'image-forward-hscroll)
@@ -627,6 +630,37 @@ Otherwise it plays once, then stops."
(image-animate image index
(if image-animate-loop t)))))))))
+(defun image-goto-frame (n &optional relative)
+ "Show frame N of a multi-frame image.
+Optional argument OFFSET non-nil means interpret N as relative to the
+current frame. Frames are indexed from 1."
+ (interactive
+ (list (or current-prefix-arg
+ (read-number "Show frame number: "))))
+ (let ((image (image-get-display-property))
+ animation)
+ (cond
+ ((null image)
+ (error "No image is present"))
+ ((null image-current-frame)
+ (message "No image animation."))
+ (t
+ (image-nth-frame image (if relative (+ n image-current-frame) (1- n)))))))
+
+(defun image-next-frame (&optional n)
+ "Switch to the next frame of a multi-frame image.
+With optional argument N, switch to the Nth frame after the current one.
+If N is negative, switch to the Nth frame before the current one."
+ (interactive "p")
+ (image-goto-frame n t))
+
+(defun image-previous-frame (&optional n)
+ "Switch to the previous frame of a multi-frame image.
+With optional argument N, switch to the Nth frame before the current one.
+If N is negative, switch to the Nth frame after the current one."
+ (interactive "p")
+ (image-next-frame (- n)))
+
;;; Switching to the next/previous image