aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2013-02-15 20:58:20 -0500
committerGlenn Morris2013-02-15 20:58:20 -0500
commitbb9dfee1d6d0e67b3564d25580f144d25284c0ea (patch)
tree48504bfef887e8c395e18cd46f7b974bbc17017a
parentef5ae980aad7c1b67b4171f7a2c106d1f69aa94f (diff)
downloademacs-bb9dfee1d6d0e67b3564d25580f144d25284c0ea.tar.gz
emacs-bb9dfee1d6d0e67b3564d25580f144d25284c0ea.zip
Display a mode-line frame counter for animated images
* lisp/image.el (image-current-frame): New variable. (image-animate-timeout): Set image-current-frame. * lisp/image-mode.el (image-mode): For animated images, display a frame counter via mode-line-process.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/image-mode.el11
-rw-r--r--lisp/image.el4
3 files changed, 18 insertions, 2 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 09645ec4741..b932054261d 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,10 @@
12013-02-16 Glenn Morris <rgm@gnu.org> 12013-02-16 Glenn Morris <rgm@gnu.org>
2 2
3 * image.el (image-current-frame): New variable.
4 (image-animate-timeout): Set image-current-frame.
5 * image-mode.el (image-mode): For animated images,
6 display a frame counter via mode-line-process.
7
3 * font-lock.el (lisp-font-lock-keywords-1): Add defvar-local. 8 * font-lock.el (lisp-font-lock-keywords-1): Add defvar-local.
4 9
52013-02-15 Stefan Monnier <monnier@iro.umontreal.ca> 102013-02-15 Stefan Monnier <monnier@iro.umontreal.ca>
diff --git a/lisp/image-mode.el b/lisp/image-mode.el
index 196336717db..fcbea945714 100644
--- a/lisp/image-mode.el
+++ b/lisp/image-mode.el
@@ -409,11 +409,18 @@ to toggle between display as an image and display as text."
409 (run-mode-hooks 'image-mode-hook) 409 (run-mode-hooks 'image-mode-hook)
410 (let ((image (image-get-display-property)) 410 (let ((image (image-get-display-property))
411 (msg1 (substitute-command-keys 411 (msg1 (substitute-command-keys
412 "Type \\[image-toggle-display] to view the image as "))) 412 "Type \\[image-toggle-display] to view the image as "))
413 animated)
413 (cond 414 (cond
414 ((null image) 415 ((null image)
415 (message "%s" (concat msg1 "an image."))) 416 (message "%s" (concat msg1 "an image.")))
416 ((image-animated-p image) 417 ((setq animated (image-animated-p image))
418 (setq image-current-frame (or (plist-get (cdr image) :index) 0)
419 mode-line-process
420 `(:eval (propertize (format " [%s/%s]"
421 (1+ image-current-frame)
422 ,(car animated))
423 'help-echo "Frame number")))
417 (message "%s" 424 (message "%s"
418 (concat msg1 "text, or " 425 (concat msg1 "text, or "
419 (substitute-command-keys 426 (substitute-command-keys
diff --git a/lisp/image.el b/lisp/image.el
index 73b25f6da67..e0521ad065a 100644
--- a/lisp/image.el
+++ b/lisp/image.el
@@ -657,6 +657,9 @@ number, play until that number of seconds has elapsed."
657 (setq timer nil))) 657 (setq timer nil)))
658 timer)) 658 timer))
659 659
660(defvar-local image-current-frame nil
661 "The frame index of the current animated image.")
662
660;; FIXME? The delay may not be the same for different sub-images, 663;; FIXME? The delay may not be the same for different sub-images,
661;; hence we need to call image-animated-p to return it. 664;; hence we need to call image-animated-p to return it.
662;; But it also returns count, so why do we bother passing that as an 665;; But it also returns count, so why do we bother passing that as an
@@ -672,6 +675,7 @@ LIMIT determines when to stop. If t, loop forever. If nil, stop
672 after LIMIT seconds have elapsed. 675 after LIMIT seconds have elapsed.
673The minimum delay between successive frames is 0.01s." 676The minimum delay between successive frames is 0.01s."
674 (plist-put (cdr image) :index n) 677 (plist-put (cdr image) :index n)
678 (setq image-current-frame n)
675 (force-window-update) 679 (force-window-update)
676 (setq n (1+ n)) 680 (setq n (1+ n))
677 (let* ((time (float-time)) 681 (let* ((time (float-time))