From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Oliver Scholz Newsgroups: gmane.emacs.devel Subject: Re: XPM via Lisp in the toolbar Date: Sun, 17 Nov 2002 13:49:06 +0100 Sender: emacs-devel-admin@gnu.org Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: main.gmane.org 1037538384 7881 80.91.224.249 (17 Nov 2002 13:06:24 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 17 Nov 2002 13:06:24 +0000 (UTC) Cc: emacs-devel@gnu.org Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18DP82-00022r-00 for ; Sun, 17 Nov 2002 14:06:22 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 18DPLs-0002jm-00 for ; Sun, 17 Nov 2002 14:20:40 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 18DP55-0000Xy-00; Sun, 17 Nov 2002 08:03:19 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 18DOsa-00015X-00 for emacs-devel@gnu.org; Sun, 17 Nov 2002 07:50:24 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 18DOsX-000154-00 for emacs-devel@gnu.org; Sun, 17 Nov 2002 07:50:23 -0500 Original-Received: from mail.gmx.de ([213.165.65.60] helo=mail.gmx.net) by monty-python.gnu.org with smtp (Exim 4.10) id 18DOsW-00014w-00 for emacs-devel@gnu.org; Sun, 17 Nov 2002 07:50:21 -0500 Original-Received: (qmail 10003 invoked by uid 0); 17 Nov 2002 12:50:18 -0000 Original-Received: from dialin-145-254-195-103.arcor-ip.net (HELO HERMES) (145.254.195.103) by mail.gmx.net (mp005-rz3) with SMTP; 17 Nov 2002 12:50:18 -0000 X-Mailer: emacs 21.2.1 (via feedmail 11-beta-1 Q) Original-To: rms@gnu.org In-Reply-To: (alkibiades@gmx.de's message of "Sun, 17 Nov 2002 13:30:12 +0100") X-Operating-System: GNU/Linux, built from scratch: http://www.linuxfromscratch.org/ X-Attribution: os X-Face: "HgH2sgK|bfH$;PiOJI6|qUCf.ve<51_Od(%ynHr?=>znn#~#oS>",F%B8&\vus),2AsPYb -n>PgddtGEn}s7kH?7kH{P_~vu?]OvVN^qD(L)>G^gDCl(U9n{:d>'DkilN!_K"eNzjrtI4Ya6;Td% IZGMbJ{lawG+'J>QXPZD&TwWU@^~A}f^zAb[Ru;CT(UA]c& User-Agent: Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.2 (i386-msvc-nt5.1.2600) Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.devel:9494 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:9494 --=-=-= I wrote: [...] > But with `xpm-create-image' hooked into `find-image' as a fall-back > for XPMs the image descriptor looks like this: > > (image :data "P6 32 32 255 ... ..." :type pbm ... ) [...] I guess, I should show my code. Attached is a patch to image.el. But I would like to test it more extensively. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=image.diff 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)) --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Oliver -- Oliver Scholz 27 Brumaire an 211 de la Révolution Taunusstr. 25 Liberté, Egalité, Fraternité! 60329 Frankfurt a. M. http://www.jungdemokratenhessen.de Tel. (069) 97 40 99 42 http://www.jdjl.org --=-=-=--