From: Juanma Barranquero <jmbarranquero@wke.es>
Cc: Jason Rumney <jasonr@gnu.org>, emacs-devel@gnu.org
Subject: Re: display word wrapping
Date: Fri, 04 Jun 2004 15:42:10 +0200 [thread overview]
Message-ID: <20040604151557.743D.JMBARRANQUERO@wke.es> (raw)
In-Reply-To: <m3vfi7trth.fsf@kfs-l.imdomain.dk>
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
}
next prev parent reply other threads:[~2004-06-04 13:42 UTC|newest]
Thread overview: 174+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-26 10:02 display word wrapping Miles Bader
2004-05-26 10:53 ` Kai Grossjohann
2004-05-26 11:29 ` Kim F. Storm
2004-05-26 12:54 ` Miles Bader
2004-05-26 14:50 ` David Kastrup
2004-05-26 15:06 ` Kim F. Storm
2004-05-26 19:16 ` David Kastrup
2004-05-26 19:50 ` Miles Bader
2004-05-26 21:43 ` i-search face-cache crash [was Re: display word wrapping] Kim F. Storm
2004-05-27 0:12 ` Miles Bader
2004-05-27 8:33 ` Kim F. Storm
2004-05-27 4:48 ` i-search face-cache crash Miles Bader
2004-05-27 23:54 ` Richard Stallman
2004-05-26 20:58 ` display word wrapping Kim F. Storm
2004-05-27 7:31 ` Jason Rumney
2004-05-26 22:21 ` Luc Teirlinck
2004-05-27 5:59 ` Miles Bader
2004-05-26 19:45 ` Miles Bader
2004-05-26 21:01 ` Kim F. Storm
2004-05-26 21:33 ` Miles Bader
2004-05-26 21:55 ` Kim F. Storm
2004-05-27 0:38 ` Miles Bader
2004-05-26 21:52 ` Stefan Monnier
2004-05-27 23:53 ` Richard Stallman
2004-05-27 9:08 ` Juanma Barranquero
2004-05-27 10:41 ` Kim F. Storm
2004-05-27 11:15 ` Juanma Barranquero
2004-05-28 7:57 ` Jason Rumney
2004-05-28 8:24 ` Kim F. Storm
2004-05-28 9:36 ` Juanma Barranquero
2004-05-29 20:54 ` Juanma Barranquero
2004-05-30 1:38 ` Juanma Barranquero
2004-05-30 6:12 ` Eli Zaretskii
2004-05-30 16:50 ` Juanma Barranquero
2004-05-30 18:27 ` Eli Zaretskii
2004-05-31 0:40 ` Juanma Barranquero
2004-05-31 7:34 ` Eli Zaretskii
2004-05-31 14:40 ` Juanma Barranquero
2004-05-31 15:28 ` Andreas Schwab
2004-05-31 17:41 ` Eli Zaretskii
2004-06-01 7:14 ` Juanma Barranquero
2004-06-01 20:32 ` Eli Zaretskii
2004-06-01 20:53 ` Andreas Schwab
2004-06-01 23:50 ` Juanma Barranquero
2004-06-02 7:58 ` Kim F. Storm
2004-06-02 8:25 ` Juanma Barranquero
2004-06-02 4:55 ` Eli Zaretskii
2004-06-02 7:27 ` Juanma Barranquero
2004-05-31 17:55 ` Eli Zaretskii
2004-05-31 18:39 ` Juanma Barranquero
2004-05-31 19:03 ` Juanma Barranquero
2004-05-31 20:19 ` Andreas Schwab
2004-05-31 21:36 ` Juanma Barranquero
2004-05-31 19:18 ` Miles Bader
2004-05-31 20:02 ` Juanma Barranquero
2004-05-31 19:09 ` Jason Rumney
2004-05-31 15:27 ` Andreas Schwab
2004-05-31 18:33 ` Juanma Barranquero
2004-05-31 19:05 ` Jason Rumney
2004-05-31 22:19 ` Juanma Barranquero
2004-06-01 4:43 ` Eli Zaretskii
2004-06-01 7:16 ` Juanma Barranquero
2004-05-28 9:15 ` Benjamin Riefenstahl
2004-05-28 9:48 ` Juanma Barranquero
2004-05-28 9:24 ` Eli Zaretskii
2004-05-28 9:46 ` Juanma Barranquero
2004-05-29 1:43 ` Richard Stallman
2004-05-29 11:37 ` Eli Zaretskii
2004-05-29 15:07 ` Juanma Barranquero
2004-05-30 14:30 ` Richard Stallman
2004-05-30 16:58 ` Juanma Barranquero
2004-05-31 18:39 ` Richard Stallman
2004-05-31 18:55 ` Jason Rumney
2004-06-02 17:36 ` Richard Stallman
2004-05-31 21:05 ` David Kastrup
2004-05-27 21:32 ` W32 image support (was Re: display word wrapping) Jason Rumney
2004-05-28 15:54 ` display word wrapping Peter Lee
2004-05-28 21:48 ` Jason Rumney
2004-05-29 3:19 ` Juanma Barranquero
2004-05-29 23:10 ` Kim F. Storm
2004-05-29 23:23 ` Juanma Barranquero
2004-05-30 19:41 ` Richard Stallman
2004-05-31 19:12 ` Jason Rumney
2004-05-31 20:18 ` Kim F. Storm
2004-06-02 15:04 ` Juanma Barranquero
2004-06-02 22:17 ` Jason Rumney
2004-06-02 22:43 ` Juanma Barranquero
2004-06-03 7:49 ` Jason Rumney
2004-06-03 8:40 ` Juanma Barranquero
2004-06-03 9:00 ` David Kastrup
2004-06-03 9:16 ` Juanma Barranquero
2004-06-03 9:26 ` David Kastrup
2004-06-03 10:02 ` Juanma Barranquero
2004-06-03 12:04 ` Kim F. Storm
2004-06-03 13:52 ` Juanma Barranquero
2004-06-03 20:43 ` Kim F. Storm
2004-06-04 1:39 ` Juanma Barranquero
2004-06-04 8:07 ` Kim F. Storm
2004-06-04 9:09 ` Juanma Barranquero
2004-06-04 9:29 ` Juanma Barranquero
2004-06-04 12:40 ` Kim F. Storm
2004-06-04 12:45 ` Kim F. Storm
2004-06-04 13:42 ` Juanma Barranquero [this message]
2004-06-04 14:16 ` Kim F. Storm
2004-06-05 1:20 ` Juanma Barranquero
2004-06-07 12:55 ` Juanma Barranquero
2004-06-07 13:34 ` Kim F. Storm
2004-06-07 16:00 ` Juanma Barranquero
2004-06-07 23:11 ` Kim F. Storm
2004-06-08 0:33 ` Juanma Barranquero
2004-06-08 6:38 ` David Kastrup
2004-06-08 8:06 ` Kim F. Storm
2004-06-08 8:23 ` David Kastrup
2004-06-08 9:33 ` Kim F. Storm
2004-06-08 9:54 ` David Kastrup
2004-06-08 10:02 ` Juanma Barranquero
2004-06-08 10:10 ` David Kastrup
2004-06-08 10:24 ` Juanma Barranquero
2004-06-08 10:43 ` David Kastrup
2004-06-08 11:17 ` Juanma Barranquero
2004-06-08 12:08 ` Kim F. Storm
2004-06-08 12:22 ` Miles Bader
2004-06-08 12:31 ` David Kastrup
2004-06-08 11:31 ` Juanma Barranquero
2004-06-08 11:39 ` David Kastrup
2004-06-08 12:11 ` Juanma Barranquero
2004-06-08 12:05 ` Kim F. Storm
2004-06-08 12:13 ` Juanma Barranquero
2004-06-08 10:00 ` Juanma Barranquero
2004-06-08 8:14 ` Juanma Barranquero
2004-06-02 23:47 ` Juanma Barranquero
2004-06-03 7:43 ` Jason Rumney
2004-06-03 7:54 ` Juanma Barranquero
2004-06-03 9:37 ` Benjamin Riefenstahl
2004-06-03 9:54 ` Juanma Barranquero
2004-06-07 11:13 ` Benjamin Riefenstahl
2004-06-07 13:29 ` Juanma Barranquero
2004-06-07 16:37 ` Benjamin Riefenstahl
2004-06-01 16:34 ` Peter Lee
2004-06-01 20:43 ` Eli Zaretskii
2004-06-02 0:05 ` Juanma Barranquero
2004-05-29 17:02 ` Richard Stallman
2004-05-29 18:19 ` Juanma Barranquero
2004-05-30 19:41 ` Richard Stallman
2004-05-31 18:42 ` Jason Rumney
2004-06-01 4:51 ` Eli Zaretskii
2004-06-01 7:18 ` Juanma Barranquero
2004-06-01 20:40 ` Eli Zaretskii
2004-06-03 0:19 ` Juanma Barranquero
2004-06-02 3:44 ` Richard Stallman
2004-05-27 12:28 ` Kai Grossjohann
2004-05-27 23:53 ` Luc Teirlinck
2004-05-28 14:21 ` Richard Stallman
2004-05-29 1:43 ` Luc Teirlinck
2004-05-26 17:51 ` Eli Zaretskii
2004-05-26 19:39 ` David Kastrup
2004-05-27 8:14 ` Eli Zaretskii
2004-05-26 12:57 ` Henrik Enberg
2004-05-26 16:15 ` David Kastrup
2004-05-27 23:54 ` Richard Stallman
2004-05-28 8:37 ` Kim F. Storm
2004-05-28 9:52 ` Miles Bader
2004-05-29 10:33 ` Kai Grossjohann
2004-05-29 1:44 ` Richard Stallman
2004-05-29 8:28 ` Karl Eichwalder
2004-05-30 14:30 ` Richard Stallman
2004-05-30 16:50 ` Kai Grossjohann
2004-05-31 18:39 ` Richard Stallman
2004-05-29 9:46 ` Jason Rumney
2004-05-30 3:11 ` Stefan Monnier
2004-05-30 6:08 ` Eli Zaretskii
2004-05-30 14:30 ` Richard Stallman
2004-05-28 9:07 ` Eli Zaretskii
2004-05-29 1:43 ` Richard Stallman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040604151557.743D.JMBARRANQUERO@wke.es \
--to=jmbarranquero@wke.es \
--cc=emacs-devel@gnu.org \
--cc=jasonr@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).