emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r104422: Doc fixes for imagemagick su


From: Chong Yidong
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r104422: Doc fixes for imagemagick support code.
Date: Sun, 29 May 2011 14:17:28 -0400
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 104422
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Sun 2011-05-29 14:17:28 -0400
message:
  Doc fixes for imagemagick support code.
  
  * lisp/image.el (imagemagick-types-inhibit)
  (imagemagick-register-types): Doc fix.
  
  * src/image.c: Various fixes to ImageMagick code comments.
  (Fimagemagick_types): Doc fix.
modified:
  lisp/ChangeLog
  lisp/image.el
  src/ChangeLog
  src/image.c
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2011-05-29 05:42:00 +0000
+++ b/lisp/ChangeLog    2011-05-29 18:17:28 +0000
@@ -1,3 +1,8 @@
+2011-05-29  Chong Yidong  <address@hidden>
+
+       * image.el (imagemagick-types-inhibit)
+       (imagemagick-register-types): Doc fix.
+
 2011-05-29  Deniz Dogan  <address@hidden>
 
        * net/rcirc.el (rcirc): Use the user's stored encryption method by

=== modified file 'lisp/image.el'
--- a/lisp/image.el     2011-03-22 13:10:43 +0000
+++ b/lisp/image.el     2011-05-29 18:17:28 +0000
@@ -698,31 +698,38 @@
 
 (defcustom imagemagick-types-inhibit
   '(C HTML HTM TXT PDF)
-  ;; FIXME what are the possible options?
-  ;; Are these actually file-name extensions?
-  ;; Why are these upper-case when eg image-types is lower-case?
-  "Types the ImageMagick loader should not try to handle."
-  :type '(choice (const :tag "Let ImageMagick handle all the types it can" nil)
+  "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 the file types that ImageMagick is able to handle."
-  (if (fboundp 'imagemagick-types)
-      (let ((im-types (imagemagick-types)))
-       (dolist (im-inhibit imagemagick-types-inhibit)
-         (setq im-types (remove im-inhibit im-types)))
-       (dolist (im-type im-types)
-         (let ((extension (downcase (symbol-name im-type))))
-           (push
-            (cons (concat "\\." extension "\\'") 'image-mode)
-            auto-mode-alist)
-           (push
-            (cons (concat "\\." extension "\\'") 'imagemagick)
-            image-type-file-name-regexps))))
-    (error "Emacs was not built with ImageMagick support")))
+  "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)
 

=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2011-05-29 05:23:24 +0000
+++ b/src/ChangeLog     2011-05-29 18:17:28 +0000
@@ -1,3 +1,8 @@
+2011-05-29  Chong Yidong  <address@hidden>
+
+       * image.c: Various fixes to ImageMagick code comments.
+       (Fimagemagick_types): Doc fix.
+
 2011-05-29  Paul Eggert  <address@hidden>
 
        Minor fixes prompted by GCC 4.6.0 warnings.

=== modified file 'src/image.c'
--- a/src/image.c       2011-05-15 17:17:44 +0000
+++ b/src/image.c       2011-05-29 18:17:28 +0000
@@ -7352,6 +7352,10 @@
 
 Lisp_Object Qimagemagick;
 
+static int imagemagick_image_p (Lisp_Object);
+static int imagemagick_load (struct frame *, struct image *);
+static void imagemagick_clear_image (struct frame *, struct image *);
+
 /* Indices of image specification fields in imagemagick_format.  */
 
 enum imagemagick_keyword_index
@@ -7394,6 +7398,18 @@
     {":crop",          IMAGE_DONT_CHECK_VALUE_TYPE,            0}
   };
 
+/* Structure describing the image type for any image handled via
+   ImageMagick.  */
+
+static struct image_type imagemagick_type =
+  {
+    &Qimagemagick,
+    imagemagick_image_p,
+    imagemagick_load,
+    imagemagick_clear_image,
+    NULL
+  };
+
 /* Free X resources of imagemagick image IMG which is used on frame F.  */
 
 static void
@@ -7425,34 +7441,27 @@
 #define DrawRectangle DrawRectangleGif
 #include <wand/MagickWand.h>
 
-/* imagemagick_load_image is a helper function for imagemagick_load,
-   which does the actual loading given contents and size, apart from
-   frame and image structures, passed from imagemagick_load.
-
-   Uses librimagemagick to do most of the image processing.
-
-   Return non-zero if successful.
-*/
+/* Helper function for imagemagick_load, which does the actual loading
+   given contents and size, apart from frame and image structures,
+   passed from imagemagick_load.  Uses librimagemagick to do most of
+   the image processing.
+
+   F is a pointer to the Emacs frame; IMG to the image structure to
+   prepare; CONTENTS is the string containing the IMAGEMAGICK data to
+   be parsed; SIZE is the number of bytes of data; and FILENAME is
+   either the file name or the image data.
+
+   Return non-zero if successful.  */
 
 static int
-imagemagick_load_image (/* Pointer to emacs frame structure.  */
-                        struct frame *f,
-                        /* Pointer to emacs image structure.  */
-                        struct image *img,
-                        /* String containing the IMAGEMAGICK data to
-                           be parsed.  */
-                        unsigned char *contents,
-                        /* Size of data in bytes.  */
-                        unsigned int size,
-                        /* Filename, either pass filename or
-                           contents/size.  */
-                        unsigned char *filename)
+imagemagick_load_image (struct frame *f, struct image *img,
+                       unsigned char *contents, unsigned int size,
+                       unsigned char *filename)
 {
   unsigned long width;
   unsigned long height;
 
-  MagickBooleanType
-    status;
+  MagickBooleanType status;
 
   XImagePtr ximg;
   Lisp_Object specified_bg;
@@ -7514,8 +7523,8 @@
 
   DestroyMagickWand (ping_wand);
 
-  /* Now, after pinging, we know how many images are inside the
-     file.  If it's not a bundle, the number is one.  */
+  /* Now we know how many images are inside the file.  If it's not a
+     bundle, the number is one.  */
 
   if (filename != NULL)
     {
@@ -7628,8 +7637,8 @@
         }
     }
 
-  /* Finaly we are done manipulating the image, figure out resulting
-     width, height, and then transfer ownerwship to Emacs.  */
+  /* Finally we are done manipulating the image.  Figure out the
+     resulting width/height and transfer ownerwship to Emacs.  */
   height = MagickGetImageHeight (image_wand);
   width = MagickGetImageWidth (image_wand);
 
@@ -7784,8 +7793,7 @@
    the prototype thus needs to be compatible with that structure.  */
 
 static int
-imagemagick_load (struct frame *f,
-                  struct image *img)
+imagemagick_load (struct frame *f, struct image *img)
 {
   int success_p = 0;
   Lisp_Object file_name;
@@ -7823,36 +7831,18 @@
   return success_p;
 }
 
-/* Structure describing the image type `imagemagick'.  Its the same
-   type of structure defined for all image formats, handled by Emacs
-   image functions.  See struct image_type in dispextern.h.  */
-
-static struct image_type imagemagick_type =
-  {
-    /* An identifier showing that this is an image structure for the
-       IMAGEMAGICK format.  */
-    &Qimagemagick,
-    /* Handle to a function that can be used to identify a IMAGEMAGICK
-       file.  */
-    imagemagick_image_p,
-    /* Handle to function used to load a IMAGEMAGICK file.  */
-    imagemagick_load,
-    /* Handle to function to free resources for IMAGEMAGICK.  */
-    imagemagick_clear_image,
-    /* An internal field to link to the next image type in a list of
-       image types, will be filled in when registering the format.  */
-    NULL
-  };
-
-
 DEFUN ("imagemagick-types", Fimagemagick_types, Simagemagick_types, 0, 0, 0,
-       doc: /* Return the image types supported by ImageMagick.
-Note that ImageMagick recognizes many file-types that Emacs does not recognize
-as images, such as .c.  */)
+       doc: /* Return a list of image types supported by ImageMagick.
+Each entry in this list is a symbol named after an ImageMagick format
+tag.  See the ImageMagick manual for a list of ImageMagick formats and
+their descriptions (http://www.imagemagick.org/script/formats.php).
+
+Note that ImageMagick recognizes many file-types that Emacs does not
+recognize as images, such as C.  See `imagemagick-types-inhibit'.  */)
   (void)
 {
   Lisp_Object typelist = Qnil;
-  unsigned long numf;
+  unsigned long numf = 0;
   ExceptionInfo ex;
   char **imtypes = GetMagickList ("*", &numf, &ex);
   int i;


reply via email to

[Prev in Thread] Current Thread [Next in Thread]