]> code.delx.au - gnu-emacs/blobdiff - lisp/image-mode.el
* lisp/info-look.el (info-lookup-select-mode): If major-mode has no
[gnu-emacs] / lisp / image-mode.el
index 6a13d5280376e2aa63cd3be67d9b1453f12579d8..e539848675c7f08dc45658a329c51889570b31e7 100644 (file)
@@ -337,8 +337,12 @@ call."
     (set-keymap-parent map special-mode-map)
     (define-key map "\C-c\C-c" 'image-toggle-display)
     (define-key map (kbd "SPC")       'image-scroll-up)
+    (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)
@@ -408,11 +412,18 @@ to toggle between display as an image and display as text."
        (run-mode-hooks 'image-mode-hook)
        (let ((image (image-get-display-property))
              (msg1 (substitute-command-keys
-                    "Type \\[image-toggle-display] to view the image as ")))
+                    "Type \\[image-toggle-display] to view the image as "))
+             animated)
          (cond
           ((null image)
            (message "%s" (concat msg1 "an image.")))
-          ((image-animated-p image)
+          ((setq animated (image-animated-p image))
+           (setq image-current-frame (or (plist-get (cdr image) :index) 0)
+                 mode-line-process
+                 `(:eval (propertize (format " [%s/%s]"
+                                             (1+ image-current-frame)
+                                             ,(car animated))
+                                     'help-echo "Frame number")))
            (message "%s"
                     (concat msg1 "text, or "
                             (substitute-command-keys
@@ -619,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)))
+
 \f
 ;;; Switching to the next/previous image