emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What's the right way to detect libxml2?


From: Andy Moreton
Subject: Re: What's the right way to detect libxml2?
Date: Tue, 24 Oct 2017 14:38:33 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (windows-nt)

On Sun 22 Oct 2017, Phillip Lord wrote:

> On Sun, October 22, 2017 2:14 pm, Clément Pit-Claudel wrote:
>> Hi emacs-devel,
>>
>>
>> In Flycheck we use ``libxml-parse-region`` if available, and fall back to
>
>> ``xml-parse-region`` otherwise.  We recently realized that our libxml
>> detection code was wrong, however.
>>
>> We used to write ``(if (fboundp 'libxml-parse-region)
>> (libxml-parse-region …) (xml-parse-region …))``, but this isn't
>> sufficient on Windows, where ``fboundp`` succeeds if Emacs was compiled
>> with libxml support, even if the appropriate DLL isn't installed on the
>> user's system.
>>
>> What's the proper way to autodetect libxml? We're thinking of doing this
>> instead::
>>
>>
>> (if (and (fboundp 'libxml-parse-region)
>> (with-temp-buffer
>> (insert "<xml/>")
>> (libxml-parse-region (point-min) (point-max))))
>> (libxml-parse-region …)
>> (xml-parse-region …))
>>
>>
>> Do we have better options?
>
> We need a better option, as it happens. I have the same problem when
> building the windows binary package. I've got no way of testing whether
> libxml (or any of the other DLLs) are present or work.

M-x list-dynamic-libraries shows the loaded DLLs, but you still need to
perform some work that causes the relevant libraries to loaded
beforehand.

For libxml2, try using (shr-render-buffer) on an HTML/XML buffer to get
the library loaded.

For some other libraries there are helpers:
  (gnutls-available-p)
  (image-type-available-p 'gif)
  (image-type-available-p 'imagemagick)
  (image-type-available-p 'jpeg)
  (image-type-available-p 'png)
  (image-type-available-p 'svg)
  (image-type-available-p 'tiff)
  (image-type-available-p 'xpm)
  (lcms2-available-p)
  (zlib-available-p)

Adding predicates for the remaining dynamic libraries would be useful.

    AndyM






reply via email to

[Prev in Thread] Current Thread [Next in Thread]