Doc fixes for imagemagick support code.
[bpt/emacs.git] / lisp / image.el
index 287cca8..3f44be8 100644 (file)
@@ -1,10 +1,10 @@
 ;;; image.el --- image API
 
-;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
-;;   2007, 2008, 2009, 2010  Free Software Foundation, Inc.
+;; Copyright (C) 1998-2011  Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: multimedia
+;; Package: emacs
 
 ;; This file is part of GNU Emacs.
 
@@ -60,7 +60,7 @@ IMAGE-TYPE must be a pair (PREDICATE . TYPE).  PREDICATE is called
 with one argument, a string containing the image data.  If PREDICATE returns
 a non-nil value, TYPE is the image's type.")
 
-(defconst image-type-file-name-regexps
+(defvar image-type-file-name-regexps
   '(("\\.png\\'" . png)
     ("\\.gif\\'" . gif)
     ("\\.jpe?g\\'" . jpeg)
@@ -329,14 +329,16 @@ Optional DATA-P non-nil means SOURCE is a string containing image data."
   type)
 
 
-(defvar image-library-alist)
+(define-obsolete-variable-alias
+    'image-library-alist
+    'dynamic-library-alist "24.1")
 
 ;;;###autoload
 (defun image-type-available-p (type)
   "Return non-nil if image type TYPE is available.
 Image types are symbols like `xbm' or `jpeg'."
   (and (fboundp 'init-image-library)
-       (init-image-library type image-library-alist)))
+       (init-image-library type dynamic-library-alist)))
 
 
 ;;;###autoload
@@ -616,7 +618,7 @@ Images should not be larger than specified by `max-image-size'."
     (let* ((animate (memq type image-animated-types))
           (image
            (append (list 'image :type type (if data-p :data :file) file-or-data)
-                   (if animate '(:index 0 :mask heuristic))
+                   (if animate '(:index 0))
                    props)))
       (if animate
          (image-animate-start image))
@@ -694,7 +696,41 @@ shall be displayed."
        (cons images tmo))))))
 
 \f
+(defcustom imagemagick-types-inhibit
+  '(C HTML HTM TXT PDF)
+  "ImageMagick types that Emacs should not use ImageMagick to handle.
+This should be a list of symbols, each of which has the same
+names as one of the format tags used internally by ImageMagick;
+see `imagemagick-types'.  Entries in this list are excluded from
+being registered by `imagemagick-register-types'.
+
+If Emacs is compiled without ImageMagick, this variable has no effect."
+  :type '(choice (const :tag "Let ImageMagick handle all types it can" nil)
+                (repeat symbol))
+  :version "24.1"
+  :group 'image)
+
+;;;###autoload
+(defun imagemagick-register-types ()
+  "Register file types that can be handled by ImageMagick.
+This adds the file types returned by `imagemagick-types'
+\(excluding the ones in `imagemagick-types-inhibit') to
+`auto-mode-alist' and `image-type-file-name-regexps', so that
+Emacs visits them in Image mode.
+
+If Emacs is compiled without ImageMagick support, do nothing."
+  (when (fboundp 'imagemagick-types)
+    (let ((im-types (imagemagick-types)))
+      (dolist (im-inhibit imagemagick-types-inhibit)
+       (setq im-types (delq im-inhibit im-types)))
+      (dolist (im-type im-types)
+       (let ((extension
+              (concat "\\." (downcase (symbol-name im-type))
+                      "\\'")))
+         (push (cons extension 'image-mode) auto-mode-alist)
+         (push (cons extension 'imagemagick)
+               image-type-file-name-regexps))))))
+
 (provide 'image)
 
-;; arch-tag: 8e76a07b-eb48-4f3e-a7a0-1a7ba9f096b3
 ;;; image.el ends here