From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Juanma Barranquero Newsgroups: gmane.emacs.devel Subject: Re: display word wrapping Date: Fri, 04 Jun 2004 15:42:10 +0200 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <20040604151557.743D.JMBARRANQUERO@wke.es> References: <20040604110038.74A0.JMBARRANQUERO@wke.es> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1086356558 16392 80.91.224.253 (4 Jun 2004 13:42:38 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 4 Jun 2004 13:42:38 +0000 (UTC) Cc: Jason Rumney , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Fri Jun 04 15:42:26 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BWExm-00060O-00 for ; Fri, 04 Jun 2004 15:42:26 +0200 Original-Received: from lists.gnu.org ([199.232.76.165]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BWExm-0003q4-00 for ; Fri, 04 Jun 2004 15:42:26 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BWEy9-00058g-RZ for emacs-devel@quimby.gnus.org; Fri, 04 Jun 2004 09:42:49 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1BWEy7-00058b-9W for emacs-devel@gnu.org; Fri, 04 Jun 2004 09:42:47 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1BWEy6-00058P-Dj for emacs-devel@gnu.org; Fri, 04 Jun 2004 09:42:47 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BWEy6-00058M-Bk for emacs-devel@gnu.org; Fri, 04 Jun 2004 09:42:46 -0400 Original-Received: from [62.22.181.117] (helo=idefix.laley.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BWExX-0005Ez-QK; Fri, 04 Jun 2004 09:42:12 -0400 Original-Received: from [172.17.221.23] (JMBARRANQUERO [172.17.221.23]) by idefix.laley.net with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2655.55) id LSNJ58WS; Fri, 4 Jun 2004 15:41:43 +0200 Original-To: storm@cua.dk (Kim F. Storm) In-Reply-To: X-Mailer: Becky! ver. 2.08.01 [en] X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:24529 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:24529 On 04 Jun 2004 14:45:30 +0200 storm@cua.dk (Kim F. Storm) wrote: >> (setq image-library-alist '(t)) > Just init it to t, and let init-image-libraries test for that special value. OK. init-image-libraries does proceed as usual if image-library-alist is t (but it is responsability of the init_xxx_functions to get sure that everything's OK if they use image-library-alist in any way). > I'm sure you need Vimage_types internally, but I meant that you could > drop exporting the Vimage_types to lisp. It could be done easily, but, as you say, is useful for debugging. > BTW, what happens if you compile emacs --without-x ? I *think* (but I haven't tested it, I don't have a non-Windows environment on which to try it) it should compile OK and just initialize the built-in image types (xbm and pbm). > Fsignal (Qwrong_type_argument, Fcons (dlls, Qnil)); Ah, I see, thanks. I've done instead wrong_type_argument (Qstringp, dlls); so the message mentions that a string was expected. Attached is the current iteration of the patch. Could you (or anyone) try it on non-Windows environments? Juanma --- lisp/term/w32-win.el.orig 2004-06-04 15:29:20.000000000 +0200 +++ lisp/term/w32-win.el 2004-06-04 02:15:48.000000000 +0200 @@ -1262,4 +1262,12 @@ (error "Font not found"))))) +;;; Set default known names for image libraries +(setq image-library-alist + '((xpm "libXpm-nox4.dll" "libxpm.dll") + (png "libpng13d.dll" "libpng13.dll" "libpng12d.dll" "libpng12.dll" "libpng.dll") + (jpeg "jpeg62.dll" "libjpeg.dll" "jpeg-62.dll" "jpeg.dll") + (tiff "libtiff3.dll" "libtiff.dll") + (gif "libungif.dll"))) + ;;; arch-tag: 69fb1701-28c2-4890-b351-3d1fe4b4f166 ;;; w32-win.el ends here --- lisp/image.el.orig 2004-06-04 15:28:50.000000000 +0200 +++ lisp/image.el 2004-06-04 15:19:33.000000000 +0200 @@ -49,4 +49,19 @@ a non-nil value, TYPE is the image's type.") +;;; + +;;;###autoload +(defvar image-library-alist t + "Alist of image types vs external libraries needed to display them. + +Each element is a list (IMAGE-TYPE LIBRARY...), where the car is a symbol +representing a supported image type, and the rest are strings giving +alternate filenames for the corresponding external libraries to load. +They are tried in the order they appear on the list; if none of them can +be loaded, the running session of Emacs won't display the image type. +No entries are needed for pbm and xbm images; they're always supported. + +This variable is reset to nil each time its entries are processed.") +;;;###autoload (put 'image-library-alist 'risky-local-variable t) (defun image-jpeg-p (data) @@ -112,6 +127,7 @@ "Value is non-nil if image type TYPE is available. Image types are symbols like `xbm' or `jpeg'." - (and (boundp 'image-types) (not (null (memq type image-types))))) - + (prog1 + (memq type (init-image-libraries image-library-alist)) + (setq image-library-alist nil))) ;;;###autoload --- src/image.c.orig 2004-06-04 15:27:59.000000000 +0200 +++ src/image.c 2004-06-04 15:12:20.000000000 +0200 @@ -646,11 +646,15 @@ struct image_type *type; { - /* Make a copy of TYPE to avoid a bus error in a dumped Emacs. - The initialized data segment is read-only. */ - struct image_type *p = (struct image_type *) xmalloc (sizeof *p); - bcopy (type, p, sizeof *p); - p->next = image_types; - image_types = p; - Vimage_types = Fcons (*p->type, Vimage_types); + /* Protect against accidental redefinion. */ + if (NILP (Fmemq (*type->type, Vimage_types))) + { + /* Make a copy of TYPE to avoid a bus error in a dumped Emacs. + The initialized data segment is read-only. */ + struct image_type *p = (struct image_type *) xmalloc (sizeof *p); + bcopy (type, p, sizeof *p); + p->next = image_types; + image_types = p; + Vimage_types = Fcons (*p->type, Vimage_types); + } } @@ -1789,4 +1793,30 @@ } +/* Load a DLL implementing an image type. + The `image-library-alist' variable associates a symbol, + identifying an image type, to a list of possible filenames. + The function returns NULL if no library could be loaded for + the given image type, or if the library was previously loaded; + else the handle of the DLL. */ +static HMODULE +w32_dynaload (Lisp_Object libraries, Lisp_Object library_id) +{ + HMODULE library = NULL; + + if (CONSP (libraries) && NILP (Fmemq (library_id, Vimage_types))) + { + Lisp_Object dlls = Fassq (library_id, libraries); + + if (CONSP (dlls)) + for (dlls = XCDR (dlls); !NILP (dlls); dlls = XCDR (dlls)) + if (!CONSP (dlls) || !STRINGP (XCAR (dlls))) + wrong_type_argument (Qstringp, dlls); + else if (library = LoadLibrary (SDATA (XCAR (dlls)))) + break; + } + + return library; +} + #endif /* HAVE_NTGUI */ @@ -3489,11 +3518,10 @@ DEF_IMGLIB_FN (XImageFree); - static int -init_xpm_functions (void) +init_xpm_functions (Lisp_Object libraries) { HMODULE library; - if (!(library = LoadLibrary ("libXpm.dll"))) + if (!(library = w32_dynaload (libraries, Qxpm))) return 0; @@ -5589,19 +5617,10 @@ static int -init_png_functions (void) +init_png_functions (Lisp_Object libraries) { HMODULE library; - /* Ensure zlib is loaded. Try debug version first. */ - if (!LoadLibrary ("zlibd.dll") - && !LoadLibrary ("zlib.dll")) - return 0; - /* Try loading libpng under probable names. */ - if (!(library = LoadLibrary ("libpng13d.dll")) - && !(library = LoadLibrary ("libpng13.dll")) - && !(library = LoadLibrary ("libpng12d.dll")) - && !(library = LoadLibrary ("libpng12.dll")) - && !(library = LoadLibrary ("libpng.dll"))) + if (!(library = w32_dynaload (libraries, Qpng))) return 0; @@ -6247,11 +6266,9 @@ static int -init_jpeg_functions (void) +init_jpeg_functions (Lisp_Object libraries) { HMODULE library; - if (!(library = LoadLibrary ("libjpeg.dll")) - && !(library = LoadLibrary ("jpeg-62.dll")) - && !(library = LoadLibrary ("jpeg.dll"))) + if (!(library = w32_dynaload (libraries, Qjpeg))) return 0; @@ -6684,9 +6701,9 @@ static int -init_tiff_functions (void) +init_tiff_functions (Lisp_Object libraries) { HMODULE library; - if (!(library = LoadLibrary ("libtiff.dll"))) + if (!(library = w32_dynaload (libraries, Qtiff))) return 0; @@ -7104,9 +7121,9 @@ static int -init_gif_functions (void) +init_gif_functions (Lisp_Object libraries) { HMODULE library; - if (!(library = LoadLibrary ("libungif.dll"))) + if (!(library = w32_dynaload (libraries, Qgif))) return 0; @@ -7881,4 +7898,63 @@ ***********************************************************************/ +#ifdef HAVE_NTGUI +/* Image types that rely on external libraries are loaded dynamically + if the library is available. */ +#define IF_LIB_AVAILABLE(init_lib_fn) if (init_lib_fn (libraries)) +#else +#define IF_LIB_AVAILABLE(init_func) /* Load unconditionally */ +#endif /* HAVE_NTGUI */ + +DEFUN ("init-image-libraries", Finit_image_libraries, Sinit_image_libraries, 1, 1, 0, + doc: /* Initialize image libraries. +Image types pbm and xbm are prebuilt; other types are loaded here. +Which libraries are loaded depends on LIBRARIES (usually, the value +of `image-library-alist'. */) + (libraries) +{ + if (EQ (libraries, Qt) || !NILP (libraries)) + { + +#if defined (HAVE_XPM) || defined (MAC_OS) + IF_LIB_AVAILABLE(init_xpm_functions) + define_image_type (&xpm_type); +#endif + +#if defined (HAVE_JPEG) || defined (MAC_OS) + IF_LIB_AVAILABLE(init_jpeg_functions) + define_image_type (&jpeg_type); +#endif + +#if defined (HAVE_TIFF) || defined (MAC_OS) + IF_LIB_AVAILABLE(init_tiff_functions) + define_image_type (&tiff_type); +#endif + +#if defined (HAVE_GIF) || defined (MAC_OS) + IF_LIB_AVAILABLE(init_gif_functions) + define_image_type (&gif_type); +#endif + +#if defined (HAVE_PNG) || defined (MAC_OS) + IF_LIB_AVAILABLE(init_png_functions) + define_image_type (&png_type); +#endif + +#ifdef HAVE_GHOSTSCRIPT + define_image_type (&gs_type); +#endif + +#ifdef MAC_OS + /* Animated gifs use QuickTime Movie Toolbox. So initialize it here. */ + EnterMovies (); +#ifdef MAC_OSX + init_image_func_pointer (); +#endif +#endif + } + + return Vimage_types; +} + void syms_of_image () @@ -7958,4 +8034,5 @@ #endif + defsubr (&Sinit_image_libraries); defsubr (&Sclear_image_cache); defsubr (&Simage_size); @@ -7985,13 +8062,4 @@ } - -#ifdef HAVE_NTGUI -/* Image types that rely on external libraries are loaded dynamically - if the library is available. */ -#define IF_LIB_AVAILABLE(init_lib_fn) if (init_lib_fn()) -#else -#define IF_LIB_AVAILABLE(init_func) /* Load unconditionally */ -#endif /* HAVE_NTGUI */ - void init_image () @@ -8002,41 +8070,4 @@ define_image_type (&xbm_type); define_image_type (&pbm_type); - -#if defined (HAVE_XPM) || defined (MAC_OS) - IF_LIB_AVAILABLE(init_xpm_functions) - define_image_type (&xpm_type); -#endif - -#if defined (HAVE_JPEG) || defined (MAC_OS) - IF_LIB_AVAILABLE(init_jpeg_functions) - define_image_type (&jpeg_type); -#endif - -#if defined (HAVE_TIFF) || defined (MAC_OS) - IF_LIB_AVAILABLE(init_tiff_functions) - define_image_type (&tiff_type); -#endif - -#if defined (HAVE_GIF) || defined (MAC_OS) - IF_LIB_AVAILABLE(init_gif_functions) - define_image_type (&gif_type); -#endif - -#if defined (HAVE_PNG) || defined (MAC_OS) - IF_LIB_AVAILABLE(init_png_functions) - define_image_type (&png_type); -#endif - -#ifdef HAVE_GHOSTSCRIPT - define_image_type (&gs_type); -#endif - -#ifdef MAC_OS - /* Animated gifs use QuickTime Movie Toolbox. So initialize it here. */ - EnterMovies (); -#ifdef MAC_OSX - init_image_func_pointer (); -#endif -#endif }