]> code.delx.au - gnu-emacs/commitdiff
Rework recent image-multi-frame stuff a little
authorGlenn Morris <rgm@gnu.org>
Wed, 20 Feb 2013 07:57:33 +0000 (23:57 -0800)
committerGlenn Morris <rgm@gnu.org>
Wed, 20 Feb 2013 07:57:33 +0000 (23:57 -0800)
* image.el (image-current-frame): Change from variable to function.
(image-show-frame): Rename from image-nth-frame.  Update callers.

* image-mode.el (image-multi-frame): New variable.
(image-mode-map, image-mode, image-goto-frame):
Use image-multi-frame rather than image-current-frame.
(image-mode, image-goto-frame):
Use image-current-frame as function rather than as variable.

lisp/ChangeLog
lisp/image-mode.el
lisp/image.el

index 081583258b0fd8a58e0984a6b685e3857d3ff41a..8b8f724da550682e8ed91da7bfd7e71ef9f3431a 100644 (file)
@@ -1,5 +1,13 @@
 2013-02-20  Glenn Morris  <rgm@gnu.org>
 
+       * image.el (image-current-frame): Change from variable to function.
+       (image-show-frame): Rename from image-nth-frame.  Update callers.
+       * image-mode.el (image-multi-frame): New variable.
+       (image-mode-map, image-mode, image-goto-frame):
+       Use image-multi-frame rather than image-current-frame.
+       (image-mode, image-goto-frame): Use image-current-frame as
+       function rather than as variable.
+
        * emacs-lisp/cl-lib.el (cl-floatp-safe): Make it an alias for floatp.
        * emacs-lisp/cl-macs.el (cl--make-type-test)
        (cl--compiler-macro-assoc): Use floatp rather than cl-floatp-safe.
index 7787a26cc085c47eed28d5c20caf95f3c28bde34..6ae1bb20cdc86a8438c3ae6f8c8c2ea651eda75e 100644 (file)
@@ -329,6 +329,9 @@ call."
   "The image type for the current Image mode buffer.")
 (make-variable-buffer-local 'image-type)
 
+(defvar-local image-multi-frame nil
+  "Non-nil if image for the current Image mode buffer has multiple frames.")
+
 (defvar image-mode-previous-major-mode nil
   "Internal variable to keep the previous non-image major mode.")
 
@@ -390,7 +393,7 @@ call."
        ["Animate Image" image-toggle-animation :style toggle
         :selected (let ((image (image-get-display-property)))
                     (and image (image-animate-timer image)))
-        :active image-current-frame
+        :active image-multi-frame
          :help "Toggle image animation"]
        ["Loop Animation"
         (lambda () (interactive)
@@ -403,13 +406,13 @@ call."
             (image-toggle-animation)
             (image-toggle-animation)))
         :style toggle :selected image-animate-loop
-        :active image-current-frame
+        :active image-multi-frame
          :help "Animate images once, or forever?"]
-       ["Next Frame" image-next-frame :active image-current-frame
+       ["Next Frame" image-next-frame :active image-multi-frame
         :help "Show the next frame of this image"]
-       ["Previous Frame" image-previous-frame :active image-current-frame
+       ["Previous Frame" image-previous-frame :active image-multi-frame
         :help "Show the previous frame of this image"]
-       ["Goto Frame..." image-goto-frame :active image-current-frame
+       ["Goto Frame..." image-goto-frame :active image-multi-frame
         :help "Show a specific frame of this image"]
        ))
     map)
@@ -471,12 +474,13 @@ to toggle between display as an image and display as text."
           ((null image)
            (message "%s" (concat msg1 "an image.")))
           ((setq animated (image-multi-frame-p image))
-           (setq image-current-frame (or (plist-get (cdr image) :index) 0)
+           (setq image-multi-frame t
                  mode-line-process
-                 `(:eval (propertize (format " [%s/%s]"
-                                             (1+ image-current-frame)
-                                             ,(car animated))
-                                     'help-echo "Frame number")))
+                 `(:eval (propertize
+                          (format " [%s/%s]"
+                                  (1+ (image-current-frame ',image))
+                                  ,(car animated))
+                          'help-echo "Frame number")))
            (message "%s"
                     (concat msg1 "text.  This image has multiple frames.")))
 ;;;                         (substitute-command-keys
@@ -694,10 +698,13 @@ current frame.  Frames are indexed from 1."
     (cond
      ((null image)
       (error "No image is present"))
-     ((null image-current-frame)
+     ((null image-multi-frame)
       (message "No image animation."))
      (t
-      (image-nth-frame image (if relative (+ n image-current-frame) (1- n)))))))
+      (image-show-frame image
+                       (if relative
+                           (+ n (image-current-frame image))
+                         (1- n)))))))
 
 (defun image-next-frame (&optional n)
   "Switch to the next frame of a multi-frame image.
index b91d136443d5280242af4d60cb3e94c05f3bdc2d..ec7b41bf12660c86d9ce7c680c8a66f4e066a404 100644 (file)
@@ -660,10 +660,11 @@ number, play until that number of seconds has elapsed."
 (defconst image-minimum-frame-delay 0.01
   "Minimum interval in seconds between frames of an animated image.")
 
-(defvar-local image-current-frame nil
-  "The frame index of the current animated image.")
+(defun image-current-frame (image)
+  "The current frame number of IMAGE, indexed from 0."
+  (or (plist-get (cdr image) :index) 0))
 
-(defun image-nth-frame (image n &optional nocheck)
+(defun image-show-frame (image n &optional nocheck)
   "Show frame N of IMAGE.
 Frames are indexed from 0.  Optional argument NOCHECK non-nil means
 do not check N is within the range of frames present in the image."
@@ -671,7 +672,6 @@ do not check N is within the range of frames present in the image."
     (if (< n 0) (setq n 0)
       (setq n (min n (1- (car (image-multi-frame-p image)))))))
   (plist-put (cdr image) :index n)
-  (setq image-current-frame n)
   (force-window-update))
 
 ;; FIXME? The delay may not be the same for different sub-images,
@@ -688,7 +688,7 @@ LIMIT determines when to stop.  If t, loop forever.  If nil, stop
  after displaying the last animation frame.  Otherwise, stop
  after LIMIT seconds have elapsed.
 The minimum delay between successive frames is `image-minimum-frame-delay'."
-  (image-nth-frame image n t)
+  (image-show-frame image n t)
   (setq n (1+ n))
   (let* ((time (float-time))
         (animation (image-multi-frame-p image))