From bb9dfee1d6d0e67b3564d25580f144d25284c0ea Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Fri, 15 Feb 2013 20:58:20 -0500 Subject: [PATCH] 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. --- lisp/ChangeLog | 5 +++++ lisp/image-mode.el | 11 +++++++++-- lisp/image.el | 4 ++++ 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 @@ 2013-02-16 Glenn Morris + * image.el (image-current-frame): New variable. + (image-animate-timeout): Set image-current-frame. + * image-mode.el (image-mode): For animated images, + display a frame counter via mode-line-process. + * font-lock.el (lisp-font-lock-keywords-1): Add defvar-local. 2013-02-15 Stefan Monnier 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." (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 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." (setq timer nil))) timer)) +(defvar-local image-current-frame nil + "The frame index of the current animated image.") + ;; 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 @@ -672,6 +675,7 @@ LIMIT determines when to stop. If t, loop forever. If nil, 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) (setq n (1+ n)) (let* ((time (float-time)) -- 2.11.4.GIT