* lisp/image.el (image-type-from-file-name): Make obsolete.
(image-supported-file-p): New function that has a more sensible
value.
(image-type): Adjust caller.
* lisp/thumbs.el (thumbs-file-size, thumbs-show-image-num): Adjust
callers.
* lisp/mail/rmailmm.el (rmail-mime-set-bulk-data): Adjust caller
and logic.
"Determine the type of image file FILE from its name.
Value is a symbol specifying the image type, or nil if type cannot
be determined."
+ (declare (obsolete image-supported-file-p "29.1"))
(let (type first (case-fold-search t))
(catch 'found
(dolist (elem image-type-file-name-regexps first)
;; If nothing seems to be supported, return first type that matched.
(or first (setq first type))))))))
+ ;;;###autoload
+(defun image-supported-file-p (file)
+ "Say whether Emacs has native support for displaying TYPE.
+The value is a symbol specifying the image type, or nil if type
+cannot be determined (or if Emacs doesn't have built-in support
+for the image type)."
+ (let ((case-fold-search t)
+ type)
+ (catch 'found
+ (dolist (elem image-type-file-name-regexps)
+ (when (and (string-match-p (car elem) file)
+ (image-type-available-p (setq type (cdr elem))))
+ (throw 'found type))))))
+
(declare-function image-convert-p "image-converter.el"
(source &optional image-format))
(declare-function image-convert "image-converter.el"
(require 'image-converter)
(image-convert-p source data-p))))
(or (image-type-from-file-header source)
- (image-type-from-file-name source)
+ (image-supported-file-p source)
(and image-use-external-converter
(progn
(require 'image-converter)
((string-match "text/" content-type)
(setq type 'text))
((string-match "image/\\(.*\\)" content-type)
- (setq type (image-type-from-file-name
+ (setq type (image-supported-file-p
(concat "." (match-string 1 content-type))))
- (if (and (boundp 'image-types)
- (memq type image-types)
- (image-type-available-p type))
- (if (and rmail-mime-show-images
- (not (eq rmail-mime-show-images 'button))
- (or (not (numberp rmail-mime-show-images))
- (< size rmail-mime-show-images)))
- (setq to-show t))
- (setq type nil))))
+ (when (and type
+ rmail-mime-show-images
+ (not (eq rmail-mime-show-images 'button))
+ (or (not (numberp rmail-mime-show-images))
+ (< size rmail-mime-show-images)))
+ (setq to-show t))))
(setcar bulk-data size)
(setcdr bulk-data type)
to-show))
(defun thumbs-file-size (img)
(let ((i (image-size
- (find-image `((:type ,(image-type-from-file-name img) :file ,img))) t)))
+ (find-image `((:type ,(image-supported-file-p img) :file ,img)))
+ t)))
(concat (number-to-string (round (car i))) "x"
(number-to-string (round (cdr i))))))
thumbs-image-num (or num 0))
(delete-region (point-min)(point-max))
(save-excursion
- (thumbs-insert-image img (image-type-from-file-name img) 0)))))
+ (thumbs-insert-image img (image-supported-file-p img) 0)))))
(defun thumbs-find-image-at-point (&optional img otherwin)
"Display image IMG for thumbnail at point.
" - " (number-to-string num)))
(let ((inhibit-read-only t))
(erase-buffer)
- (thumbs-insert-image img (image-type-from-file-name img) 0)
+ (thumbs-insert-image img (image-supported-file-p img) 0)
(goto-char (point-min))))
(setq thumbs-image-num num
thumbs-current-image-filename img))))
(define-key dired-mode-map "\C-tw" 'thumbs-dired-setroot)
(define-obsolete-function-alias 'thumbs-image-type
- #'image-type-from-file-name "29.1")
+ #'image-supported-file-p "29.1")
(provide 'thumbs)