;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
When the name of an image file match REGEXP, it is assumed to
be of image type IMAGE-TYPE.")
+;; We rely on `auto-mode-alist' to detect xbm and xpm files, instead
+;; of content autodetection. Their contents are just C code, so it is
+;; easy to generate false matches.
(defvar image-type-auto-detectable
'((pbm . t)
- (xbm . t)
+ (xbm . nil)
(bmp . maybe)
(gif . maybe)
(png . maybe)
- (xpm . maybe)
+ (xpm . nil)
(jpeg . maybe)
(tiff . maybe)
(postscript . nil))
;;;###autoload
(defun image-type-auto-detected-p ()
- "Return t iff the current buffer contains an auto-detectable image.
-Whether image types are auto-detectable or not depends on the setting
-of the variable `image-type-auto-detectable'.
+ "Return t if the current buffer contains an auto-detectable image.
+This function is intended to be used from `magic-fallback-mode-alist'.
-This function is intended to be used from `magic-mode-alist' (which see)."
+The buffer is considered to contain an auto-detectable image if
+its beginning matches an image type in `image-type-header-regexps',
+and that image type is present in `image-type-auto-detectable'."
(let* ((type (image-type-from-buffer))
(auto (and type (cdr (assq type image-type-auto-detectable)))))
(and auto
- (or (eq auto t)
- (image-type-available-p type)))))
+ (or (eq auto t) (image-type-available-p type)))))
;;;###autoload