aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2010-03-10 00:18:51 -0500
committerStefan Monnier2010-03-10 00:18:51 -0500
commitb41460aedee99aaf7fefe6b545a5737aa7d9d0af (patch)
tree947eca894fc138d41f3cf253b4df861fdf6b0e62
parent25344b050dcb716283711790f58c6244a5f935a8 (diff)
parentbbbab483c46a346ce665230ad31dc2a6fb73641f (diff)
downloademacs-b41460aedee99aaf7fefe6b545a5737aa7d9d0af.tar.gz
emacs-b41460aedee99aaf7fefe6b545a5737aa7d9d0af.zip
Merge pending branch
-rw-r--r--etc/TODO41
-rw-r--r--lisp/ChangeLog14
-rw-r--r--lisp/image-mode.el2
-rw-r--r--lisp/image.el104
4 files changed, 159 insertions, 2 deletions
diff --git a/etc/TODO b/etc/TODO
index 7a585e2c230..a20ffdaa0d3 100644
--- a/etc/TODO
+++ b/etc/TODO
@@ -12,7 +12,46 @@ it best. Since Emacs is an FSF-copyrighted package, please be
12prepared to sign legal papers to transfer the copyright on your work 12prepared to sign legal papers to transfer the copyright on your work
13to the FSF. 13to the FSF.
14 14
15* Simple tasks. These don't require much emacs knowledge, they are 15* Tentative plan for Emacs-24
16
17** Bidi
18** lexbind: I haven't checked the status of the code recently, so
19 I don't know how realistic it is to include it. But it's been around
20 for a long time, and I trust Miles, so I have hope.
21** concurrency: including it as an "experimental" compile-time option
22 sounds good. Of course there might still be big questions around
23 "which form of concurrency" we'll want.
24** Overhaul of customize: sounds wonderful.
25** some kind of color-theme: agreed.
26** better support for dynamic embedded graphics: I like this idea (my
27 mpc.el code could use it for the volume widget), tho I wonder if the
28 resulting efficiency will be sufficient.
29** Spread Semantic.
30** Improve the "code snippets" support: consolidate skeleton.el, tempo.el,
31 and expand.el (any other?) and then advertise/use/improve it.
32** Improve VC: yes, there's a lot of work to be done there :-(
33 And most of it could/should make it into Emacs-23.3.
34** package manager.
35
36** Random things that cross my mind right now that I'd like to see (some of
37them from my local hacks), but it's not obvious at all whether they'll
38make it.
39*** multiple inheritance for keymaps (to get rid of the
40 fix_submap_inheritance hack and to more cleanly express the
41 relationship between minibuffer-local-*-map): I've had this locally
42 for a long time, but the details of the semantics is somewhat ... delicate.
43*** prog-mode (a parent-mode, like text-mode). Could/should provide
44 a better fill-paragraph default that uses syntax-tables to recognize
45 string/comment boundaries.
46*** provide more completion-at-point-functions. Make existing
47 in-buffer completion use completion-at-point.
48*** "functional" function-key-map that would make it easy to add (and
49 remove) mappings like "FOO-mouse-4 -> FOO-scroll-down",
50 "FOO-tab -> ?\FOO-\t", "uppercase -> lowercase", "[fringe KEY...] ->
51 [KEY]", "H-FOO -> M-FOO", "C-x C-y FOO -> H-FOO", ...
52
53
54* Simple tasks. These don't require much Emacs knowledge, they are
16suitable for anyone from beginners to experts. 55suitable for anyone from beginners to experts.
17 56
18** Convert modes that use view-mode to be derived from special-mode instead. 57** Convert modes that use view-mode to be derived from special-mode instead.
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 0157538dc47..1d5062660cf 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,17 @@
12010-03-10 Kim F. Storm <storm@cua.dk>
2
3 Animated image API.
4 http://lists.gnu.org/archive/html/emacs-devel/2010-03/msg00211.html
5
6 * image.el (image-animate-max-time): New defcustom.
7 (image-animated-types): New defconst.
8 (create-animated-image, image-animate-timer)
9 (image-animate-start, image-animate-stop, image-animate-timeout)
10 (image-animated-p): New functions.
11
12 * image-mode.el (image-toggle-display-image):
13 Replace `create-image' with `create-animated-image'.
14
12010-03-09 Miles Bader <Miles Bader <miles@gnu.org>> 152010-03-09 Miles Bader <Miles Bader <miles@gnu.org>>
2 16
3 * vc-git.el (vc-git-print-log): Use "tformat:" for shortlog, 17 * vc-git.el (vc-git-print-log): Use "tformat:" for shortlog,
diff --git a/lisp/image-mode.el b/lisp/image-mode.el
index 5b785f0031e..6169fa4cb71 100644
--- a/lisp/image-mode.el
+++ b/lisp/image-mode.el
@@ -466,7 +466,7 @@ was inserted."
466 (buffer-substring-no-properties (point-min) (point-max))) 466 (buffer-substring-no-properties (point-min) (point-max)))
467 filename)) 467 filename))
468 (type (image-type file-or-data nil data-p)) 468 (type (image-type file-or-data nil data-p))
469 (image (create-image file-or-data type data-p)) 469 (image (create-animated-image file-or-data type data-p))
470 (props 470 (props
471 `(display ,image 471 `(display ,image
472 intangible ,image 472 intangible ,image
diff --git a/lisp/image.el b/lisp/image.el
index 944c6135e23..e5dfe1a3996 100644
--- a/lisp/image.el
+++ b/lisp/image.el
@@ -584,7 +584,111 @@ Example:
584 (declare (doc-string 3)) 584 (declare (doc-string 3))
585 `(defvar ,symbol (find-image ',specs) ,doc)) 585 `(defvar ,symbol (find-image ',specs) ,doc))
586 586
587
588;;; Animated image API
587 589
590(defcustom image-animate-max-time 30
591 "Time in seconds to animate images."
592 :type 'integer
593 :version "22.1"
594 :group 'image)
595
596(defconst image-animated-types '(gif)
597 "List of supported animated image types.")
598
599;;;###autoload
600(defun create-animated-image (file-or-data &optional type data-p &rest props)
601 "Create an animated image.
602FILE-OR-DATA is an image file name or image data.
603Optional TYPE is a symbol describing the image type. If TYPE is omitted
604or nil, try to determine the image type from its first few bytes
605of image data. If that doesn't work, and FILE-OR-DATA is a file name,
606use its file extension as image type.
607Optional DATA-P non-nil means FILE-OR-DATA is a string containing image data.
608Optional PROPS are additional image attributes to assign to the image,
609like, e.g. `:mask MASK'.
610Value is the image created, or nil if images of type TYPE are not supported.
611
612Images should not be larger than specified by `max-image-size'."
613 (setq type (image-type file-or-data type data-p))
614 (when (image-type-available-p type)
615 (let* ((animate (memq type image-animated-types))
616 (image
617 (append (list 'image :type type (if data-p :data :file) file-or-data)
618 (if animate '(:index 0 :mask heuristic))
619 props)))
620 (if animate
621 (image-animate-start image))
622 image)))
623
624(defun image-animate-timer (image)
625 "Return the animation timer for image IMAGE."
626 ;; See cancel-function-timers
627 (let ((tail timer-list) timer)
628 (while tail
629 (setq timer (car tail)
630 tail (cdr tail))
631 (if (and (eq (aref timer 5) #'image-animate-timeout)
632 (consp (aref timer 6))
633 (eq (car (aref timer 6)) image))
634 (setq tail nil)
635 (setq timer nil)))
636 timer))
637
638(defun image-animate-start (image &optional max-time)
639 "Start animation of image IMAGE.
640Optional second arg MAX-TIME is number of seconds to animate image,
641or t to animate infinitely."
642 (let ((anim (image-animated-p image))
643 timer tmo)
644 (when anim
645 (if (setq timer (image-animate-timer image))
646 (setcar (nthcdr 3 (aref timer 6)) max-time)
647 (setq tmo (* (cdr anim) 0.01))
648 (setq max-time (or max-time image-animate-max-time))
649 (run-with-timer tmo nil #'image-animate-timeout
650 image 1 (car anim)
651 (if (numberp max-time)
652 (- max-time tmo)
653 max-time))))))
654
655(defun image-animate-stop (image)
656 "Stop animation of image."
657 (let ((timer (image-animate-timer image)))
658 (when timer
659 (cancel-timer timer))))
660
661(defun image-animate-timeout (image ino count time-left)
662 (if (>= ino count)
663 (setq ino 0))
664 (plist-put (cdr image) :index ino)
665 (force-window-update)
666 (let ((anim (image-animated-p image)) tmo)
667 (when anim
668 (setq tmo (* (cdr anim) 0.01))
669 (unless (and (= ino 0) (numberp time-left) (< time-left tmo))
670 (run-with-timer tmo nil #'image-animate-timeout
671 image (1+ ino) count
672 (if (numberp time-left)
673 (- time-left tmo)
674 time-left))))))
675
676(defun image-animated-p (image)
677 "Return non-nil if image is animated.
678Actually, return value is a cons (IMAGES . DELAY) where IMAGES
679is the number of sub-images in the animated image, and DELAY
680is the delay in 100ths of a second until the next sub-image
681shall be displayed."
682 (cond
683 ((eq (plist-get (cdr image) :type) 'gif)
684 (let* ((extdata (image-extension-data image))
685 (images (plist-get extdata 'count))
686 (anim (plist-get extdata #xF9)))
687 (and (integerp images) (> images 1)
688 (stringp anim) (>= (length anim) 4)
689 (cons images (+ (aref anim 1) (* (aref anim 2) 256))))))))
690
691
588(provide 'image) 692(provide 'image)
589 693
590;; arch-tag: 8e76a07b-eb48-4f3e-a7a0-1a7ba9f096b3 694;; arch-tag: 8e76a07b-eb48-4f3e-a7a0-1a7ba9f096b3