aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2013-02-15 19:29:39 -0800
committerGlenn Morris2013-02-15 19:29:39 -0800
commitc0211c4e370ec5fb46b90764235282d098ca21c1 (patch)
tree67e77fdf18df591f7931ae598cc9823362968cf1
parent6b6d804b1e278b465ba778bbd10bb008dfe13b21 (diff)
downloademacs-c0211c4e370ec5fb46b90764235282d098ca21c1.tar.gz
emacs-c0211c4e370ec5fb46b90764235282d098ca21c1.zip
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.
-rw-r--r--etc/NEWS4
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/image-mode.el34
-rw-r--r--lisp/image.el15
4 files changed, 58 insertions, 3 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 98824220cec..62d84a0788d 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -141,6 +141,10 @@ amounts of data into the ERC input.
141visit the next image file and the previous image file in the same 141visit the next image file and the previous image file in the same
142directory, respectively. 142directory, respectively.
143 143
144*** New commands to show specific frames of multi-frame images.
145`f' (`image-next-frame') and `b' (`image-previous-frame') visit the
146next or previous frame. `F' (`image-goto-frame') shows a specific frame.
147
144--- 148---
145*** The command `image-mode-fit-frame' deletes other windows. 149*** The command `image-mode-fit-frame' deletes other windows.
146When toggling, it restores the frame's previous window configuration. 150When toggling, it restores the frame's previous window configuration.
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index d9e6a3eb5b4..e71e3d6752e 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12013-02-16 Glenn Morris <rgm@gnu.org>
2
3 * image.el (image-nth-frame): New, split from image-animate-timeout.
4 (image-animate-timeout): Use image-nth-frame.
5 * image-mode.el (image-goto-frame, image-next-frame)
6 (image-previous-frame): New commands.
7 (image-mode-map): Add new frame commands.
8
12013-02-16 Jonas Bernoulli <jonas@bernoul.li> 92013-02-16 Jonas Bernoulli <jonas@bernoul.li>
2 10
3 * emacs-lisp/tabulated-list.el (tabulated-list-print-col): 11 * emacs-lisp/tabulated-list.el (tabulated-list-print-col):
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."
340 (define-key map (kbd "S-SPC") 'image-scroll-down) 340 (define-key map (kbd "S-SPC") 'image-scroll-down)
341 (define-key map (kbd "DEL") 'image-scroll-down) 341 (define-key map (kbd "DEL") 'image-scroll-down)
342 (define-key map (kbd "RET") 'image-toggle-animation) 342 (define-key map (kbd "RET") 'image-toggle-animation)
343 (define-key map "F" 'image-goto-frame)
344 (define-key map "f" 'image-next-frame)
345 (define-key map "b" 'image-previous-frame)
343 (define-key map "n" 'image-next-file) 346 (define-key map "n" 'image-next-file)
344 (define-key map "p" 'image-previous-file) 347 (define-key map "p" 'image-previous-file)
345 (define-key map [remap forward-char] 'image-forward-hscroll) 348 (define-key map [remap forward-char] 'image-forward-hscroll)
@@ -627,6 +630,37 @@ Otherwise it plays once, then stops."
627 (image-animate image index 630 (image-animate image index
628 (if image-animate-loop t))))))))) 631 (if image-animate-loop t)))))))))
629 632
633(defun image-goto-frame (n &optional relative)
634 "Show frame N of a multi-frame image.
635Optional argument OFFSET non-nil means interpret N as relative to the
636current frame. Frames are indexed from 1."
637 (interactive
638 (list (or current-prefix-arg
639 (read-number "Show frame number: "))))
640 (let ((image (image-get-display-property))
641 animation)
642 (cond
643 ((null image)
644 (error "No image is present"))
645 ((null image-current-frame)
646 (message "No image animation."))
647 (t
648 (image-nth-frame image (if relative (+ n image-current-frame) (1- n)))))))
649
650(defun image-next-frame (&optional n)
651 "Switch to the next frame of a multi-frame image.
652With optional argument N, switch to the Nth frame after the current one.
653If N is negative, switch to the Nth frame before the current one."
654 (interactive "p")
655 (image-goto-frame n t))
656
657(defun image-previous-frame (&optional n)
658 "Switch to the previous frame of a multi-frame image.
659With optional argument N, switch to the Nth frame before the current one.
660If N is negative, switch to the Nth frame after the current one."
661 (interactive "p")
662 (image-next-frame (- n)))
663
630 664
631;;; Switching to the next/previous image 665;;; Switching to the next/previous image
632 666
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."
660(defvar-local image-current-frame nil 660(defvar-local image-current-frame nil
661 "The frame index of the current animated image.") 661 "The frame index of the current animated image.")
662 662
663(defun image-nth-frame (image n &optional nocheck)
664 "Show frame N of IMAGE.
665Frames are indexed from 0. Optional argument NOCHECK non-nil means
666do not check N is within the range of frames present in the image."
667 (unless nocheck
668 (if (< n 0) (setq n 0)
669 (setq n (min n (1- (car (image-animated-p image)))))))
670 (plist-put (cdr image) :index n)
671 (setq image-current-frame n)
672 (force-window-update))
673
663;; FIXME? The delay may not be the same for different sub-images, 674;; FIXME? The delay may not be the same for different sub-images,
664;; hence we need to call image-animated-p to return it. 675;; hence we need to call image-animated-p to return it.
665;; But it also returns count, so why do we bother passing that as an 676;; 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
674 after displaying the last animation frame. Otherwise, stop 685 after displaying the last animation frame. Otherwise, stop
675 after LIMIT seconds have elapsed. 686 after LIMIT seconds have elapsed.
676The minimum delay between successive frames is 0.01s." 687The minimum delay between successive frames is 0.01s."
677 (plist-put (cdr image) :index n) 688 (image-nth-frame image n t)
678 (setq image-current-frame n)
679 (force-window-update)
680 (setq n (1+ n)) 689 (setq n (1+ n))
681 (let* ((time (float-time)) 690 (let* ((time (float-time))
682 (animation (image-animated-p image)) 691 (animation (image-animated-p image))