Index: lisp/image.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/image.el,v retrieving revision 1.33 diff -u -r1.33 image.el --- lisp/image.el 3 Nov 2002 08:34:45 -0000 1.33 +++ lisp/image.el 17 Nov 2002 12:45:00 -0000 @@ -49,6 +49,12 @@ a non-nil value, TYPE is the image's type ") +;;;###autoload +(defcustom use-lisp-xpm t + "If non-nil, use lisp functions to read XPM files. +This happens only if Emacs was compiled without XPM support on the C +level.") + (defun image-jpeg-p (data) "Value is non-nil if DATA, a string, consists of JFIF image data. We accept the tag Exif because that is the same format." @@ -143,9 +149,12 @@ (error "Cannot determine image type")) (unless (symbolp type) (error "Invalid image type `%s'" type)) - (when (image-type-available-p type) - (append (list 'image :type type (if data-p :data :file) file-or-data) - props))) + (if (image-type-available-p type) + (append (list 'image :type type (if data-p :data :file) file-or-data) + props) + (when (and (eq type 'xpm) use-lisp-xpm) + ;; Use Lisp to deal with the XPM. + (apply 'xpm-create-image file-or-data data-p props)))) ;;;###autoload @@ -245,7 +254,8 @@ (data (plist-get spec :data)) (file (plist-get spec :file)) found) - (when (image-type-available-p type) + (when (or (image-type-available-p type) + (and (eq type 'xpm) use-lisp-xpm)) (cond ((stringp file) (let ((path load-path)) (while (and (not found) path) @@ -257,12 +267,18 @@ (let ((try-file (expand-file-name file data-directory))) (if (file-readable-p try-file) (setq found try-file)))) - (if found + (when found + (if (image-type-available-p type) + (setq image + (cons 'image (plist-put (copy-sequence spec) + :file found))) + ;; Use Lisp functions to deal with XPMs. (setq image - (cons 'image (plist-put (copy-sequence spec) - :file found)))))) + (apply 'xpm-create-image found nil spec)))))) ((not (null data)) - (setq image (cons 'image spec))))) + (if (image-type-available-p type) + (setq image (cons 'image spec)) + (setq image (apply 'xpm-create-image data t spec)))))) (setq specs (cdr specs)))) image))