* What's the right way to detect libxml2? @ 2017-10-22 14:14 Clément Pit-Claudel 2017-10-22 16:27 ` Phillip Lord 0 siblings, 1 reply; 28+ messages in thread From: Clément Pit-Claudel @ 2017-10-22 14:14 UTC (permalink / raw) To: Emacs developers 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? Thanks! Clément. ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: What's the right way to detect libxml2? 2017-10-22 14:14 What's the right way to detect libxml2? Clément Pit-Claudel @ 2017-10-22 16:27 ` Phillip Lord 2017-10-24 13:38 ` Andy Moreton 0 siblings, 1 reply; 28+ messages in thread From: Phillip Lord @ 2017-10-22 16:27 UTC (permalink / raw) To: "Clément Pit-Claudel"; +Cc: Emacs developers 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. Phil ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: What's the right way to detect libxml2? 2017-10-22 16:27 ` Phillip Lord @ 2017-10-24 13:38 ` Andy Moreton 2017-10-24 14:01 ` Clément Pit-Claudel 2017-10-24 21:49 ` Richard Stallman 0 siblings, 2 replies; 28+ messages in thread From: Andy Moreton @ 2017-10-24 13:38 UTC (permalink / raw) To: emacs-devel 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 ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: What's the right way to detect libxml2? 2017-10-24 13:38 ` Andy Moreton @ 2017-10-24 14:01 ` Clément Pit-Claudel 2017-10-24 15:33 ` Andy Moreton 2017-10-24 21:49 ` Richard Stallman 1 sibling, 1 reply; 28+ messages in thread From: Clément Pit-Claudel @ 2017-10-24 14:01 UTC (permalink / raw) To: emacs-devel On 2017-10-24 09:38, Andy Moreton wrote: > For libxml2, try using (shr-render-buffer) on an HTML/XML buffer to get > the library loaded. Is that better than just calling libxml-parse-xml-region and checking for a nil return value? It sounds like shr-render-buffer would do a lot more — do we need that? ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: What's the right way to detect libxml2? 2017-10-24 14:01 ` Clément Pit-Claudel @ 2017-10-24 15:33 ` Andy Moreton 2017-10-24 17:04 ` Robert Pluim 0 siblings, 1 reply; 28+ messages in thread From: Andy Moreton @ 2017-10-24 15:33 UTC (permalink / raw) To: emacs-devel On Tue 24 Oct 2017, Clément Pit-Claudel wrote: > On 2017-10-24 09:38, Andy Moreton wrote: >> For libxml2, try using (shr-render-buffer) on an HTML/XML buffer to get >> the library loaded. > > Is that better than just calling libxml-parse-xml-region and checking for a > nil return value? It sounds like shr-render-buffer would do a lot more — do we > need that? No, it was just an example of doing something to force the library to be loaded. Your version is simpler, and having (libxml-available-p) would be even better. AndyM ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: What's the right way to detect libxml2? 2017-10-24 15:33 ` Andy Moreton @ 2017-10-24 17:04 ` Robert Pluim 2017-10-24 17:46 ` Andy Moreton 0 siblings, 1 reply; 28+ messages in thread From: Robert Pluim @ 2017-10-24 17:04 UTC (permalink / raw) To: Andy Moreton; +Cc: emacs-devel [-- Attachment #1: Type: text/plain, Size: 705 bytes --] Andy Moreton <andrewjmoreton@gmail.com> writes: > On Tue 24 Oct 2017, Clément Pit-Claudel wrote: > >> On 2017-10-24 09:38, Andy Moreton wrote: >>> For libxml2, try using (shr-render-buffer) on an HTML/XML buffer to get >>> the library loaded. >> >> Is that better than just calling libxml-parse-xml-region and checking for a >> nil return value? It sounds like shr-render-buffer would do a lot more — do we >> need that? > > No, it was just an example of doing something to force the library to be > loaded. Your version is simpler, and having (libxml-available-p) would > be even better. > > AndyM Like thus? Very lightly tested on GNU/Linux only. Might need a NEWS entry. [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-Provide-libxml-available-p.patch --] [-- Type: text/x-diff, Size: 2696 bytes --] From e74de0a485009918d71d0643bc03195b5fd01761 Mon Sep 17 00:00:00 2001 From: Robert Pluim <rpluim@gmail.com> Date: Tue, 24 Oct 2017 19:01:28 +0200 Subject: [PATCH] Provide libxml-available-p * src/emacs.c (main): Call syms_of_xml unconditionally * src/lisp.h: Provide syms_of_xml prototype even when HAVE_LIBXML2 is not defined * src/xml.c (Flibxml_available_p): New function, cloned from Fgnutls_available_p (syms_of_xml): Provide Slibxml_available_p --- src/emacs.c | 2 -- src/lisp.h | 2 +- src/xml.c | 31 +++++++++++++++++++++++++++++-- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/emacs.c b/src/emacs.c index 0fe7d9113b..808abcd9aa 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -1542,9 +1542,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem #endif #endif /* HAVE_X_WINDOWS */ -#ifdef HAVE_LIBXML2 syms_of_xml (); -#endif #ifdef HAVE_LCMS2 syms_of_lcms2 (); diff --git a/src/lisp.h b/src/lisp.h index 266370333f..cc8d90cbf1 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -4399,9 +4399,9 @@ extern void syms_of_xterm (void); extern char *x_get_keysym_name (int); #endif /* HAVE_WINDOW_SYSTEM */ -#ifdef HAVE_LIBXML2 /* Defined in xml.c. */ extern void syms_of_xml (void); +#ifdef HAVE_LIBXML2 extern void xml_cleanup_parser (void); #endif diff --git a/src/xml.c b/src/xml.c index d087a34a5e..825d5a0f64 100644 --- a/src/xml.c +++ b/src/xml.c @@ -291,16 +291,43 @@ If DISCARD-COMMENTS is non-nil, all HTML comments are discarded. */) return parse_region (start, end, base_url, discard_comments, false); return Qnil; } +#endif /* HAVE_LIBXML2 */ \f + +DEFUN ("libxml-available-p", Flibxml_available_p, Slibxml_available_p, 0, 0, 0, + doc: /* Return list of capabilities if LibXML2 is available in this instance of Emacs.*/) + (void) +{ +#ifdef HAVE_LIBXML2 +# ifdef WINDOWSNT + Lisp_Object found = Fassq (Qlibxml2, Vlibrary_cache); + if (CONSP (found)) + return XCDR (found); + else + { + Lisp_Object status; + status = init_libxml2_functions () ? Qt : Qnil; + Vlibrary_cache = Fcons (Fcons (Qlibxml2, status), Vlibrary_cache); + return status; + } +# else + return Qt; +# endif /* WINDOWSNT */ +#else + return Qnil; +#endif /* HAVE_LIBXML2 */ +} + /*********************************************************************** Initialization ***********************************************************************/ void syms_of_xml (void) { +#ifdef HAVE_LIBXML2 defsubr (&Slibxml_parse_html_region); defsubr (&Slibxml_parse_xml_region); +#endif + defsubr (&Slibxml_available_p); } - -#endif /* HAVE_LIBXML2 */ -- 2.15.0.rc1 ^ permalink raw reply related [flat|nested] 28+ messages in thread
* Re: What's the right way to detect libxml2? 2017-10-24 17:04 ` Robert Pluim @ 2017-10-24 17:46 ` Andy Moreton 2017-10-25 11:24 ` Robert Pluim 0 siblings, 1 reply; 28+ messages in thread From: Andy Moreton @ 2017-10-24 17:46 UTC (permalink / raw) To: emacs-devel On Tue 24 Oct 2017, Robert Pluim wrote: > Andy Moreton <andrewjmoreton@gmail.com> writes: > >> On Tue 24 Oct 2017, Clément Pit-Claudel wrote: >> >>> On 2017-10-24 09:38, Andy Moreton wrote: >>>> For libxml2, try using (shr-render-buffer) on an HTML/XML buffer to get >>>> the library loaded. >>> >>> Is that better than just calling libxml-parse-xml-region and checking for a >>> nil return value? It sounds like shr-render-buffer would do a lot more — do we >>> need that? >> >> No, it was just an example of doing something to force the library to be >> loaded. Your version is simpler, and having (libxml-available-p) would >> be even better. >> >> AndyM > > Like thus? Very lightly tested on GNU/Linux only. Might need a NEWS > entry. > Works for me on a 64bit MinGW64/MSYS2 build of emacs-26 on Windows 10. I don't think you need to remove the HAVE_LIBXML2 conditionals, as lisp code can check (fboundp 'libxml-available-p) before calling it, and it may break builds without libxml2 support. Also, the libxml-available-p doc string claims it returns a list of capabilities (which is true for gnutls-available-p), but it only returns nil or t. Thanks for working on this, AndyM ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: What's the right way to detect libxml2? 2017-10-24 17:46 ` Andy Moreton @ 2017-10-25 11:24 ` Robert Pluim 2017-10-28 9:10 ` Eli Zaretskii 0 siblings, 1 reply; 28+ messages in thread From: Robert Pluim @ 2017-10-25 11:24 UTC (permalink / raw) To: Andy Moreton; +Cc: emacs-devel [-- Attachment #1: Type: text/plain, Size: 1001 bytes --] Andy Moreton <andrewjmoreton@gmail.com> writes: > On Tue 24 Oct 2017, Robert Pluim wrote: >> Like thus? Very lightly tested on GNU/Linux only. Might need a NEWS >> entry. >> > Works for me on a 64bit MinGW64/MSYS2 build of emacs-26 on Windows 10. OK. > I don't think you need to remove the HAVE_LIBXML2 conditionals, as lisp > code can check (fboundp 'libxml-available-p) before calling it, and it > may break builds without libxml2 support. I'm following the gnutls model, where gnutls-available-p is always available, so you don't have to do (and (fboundp 'libxml-available-p) (libxml-available-p)) If a build without libxml2 support breaks, then we fix the code in emacs. Actually, my patch breaks --without-xml2 :-) > Also, the libxml-available-p doc string claims it returns a list of > capabilities (which is true for gnutls-available-p), but it only returns > nil or t. Ah yes, too much cut & paste. Revised version attached. Compile and run-tested with and without xml2 on GNU/Linux. [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-Provide-libxml-available-p.patch --] [-- Type: text/x-diff, Size: 3668 bytes --] From 10fe04edc5adf942c2bf9806eea5dd81edd2c9a5 Mon Sep 17 00:00:00 2001 From: Robert Pluim <rpluim@gmail.com> Date: Tue, 24 Oct 2017 19:01:28 +0200 Subject: [PATCH] Provide libxml-available-p * src/emacs.c (main): Call syms_of_xml unconditionally * src/lisp.h: Provide syms_of_xml prototype even when HAVE_LIBXML2 is not defined * src/xml.c (Flibxml_available_p): New function, cloned from Fgnutls_available_p (syms_of_xml): Provide Slibxml_available_p * doc/lispref/text.texi (Parsing HTML/XML): Document libxml-available-p --- doc/lispref/text.texi | 5 +++++ src/emacs.c | 2 -- src/lisp.h | 2 +- src/xml.c | 37 ++++++++++++++++++++++++++++++++----- 4 files changed, 38 insertions(+), 8 deletions(-) diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi index baa3c708e9..565d098069 100644 --- a/doc/lispref/text.texi +++ b/doc/lispref/text.texi @@ -4723,6 +4723,11 @@ Parsing HTML/XML @section Parsing HTML and XML @cindex parsing html +@defun libxml-available-p +This function returns non-@code{nil} if built-in libxml2 support is +available. +@end defun + When Emacs is compiled with libxml2 support, the following functions are available to parse HTML or XML text into Lisp object trees. diff --git a/src/emacs.c b/src/emacs.c index 0fe7d9113b..808abcd9aa 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -1542,9 +1542,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem #endif #endif /* HAVE_X_WINDOWS */ -#ifdef HAVE_LIBXML2 syms_of_xml (); -#endif #ifdef HAVE_LCMS2 syms_of_lcms2 (); diff --git a/src/lisp.h b/src/lisp.h index 266370333f..cc8d90cbf1 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -4399,9 +4399,9 @@ extern void syms_of_xterm (void); extern char *x_get_keysym_name (int); #endif /* HAVE_WINDOW_SYSTEM */ -#ifdef HAVE_LIBXML2 /* Defined in xml.c. */ extern void syms_of_xml (void); +#ifdef HAVE_LIBXML2 extern void xml_cleanup_parser (void); #endif diff --git a/src/xml.c b/src/xml.c index d087a34a5e..7afaa63c42 100644 --- a/src/xml.c +++ b/src/xml.c @@ -18,15 +18,15 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ #include <config.h> +#include "lisp.h" +#include "buffer.h" + #ifdef HAVE_LIBXML2 #include <libxml/tree.h> #include <libxml/parser.h> #include <libxml/HTMLparser.h> -#include "lisp.h" -#include "buffer.h" - \f #ifdef WINDOWSNT @@ -291,16 +291,43 @@ If DISCARD-COMMENTS is non-nil, all HTML comments are discarded. */) return parse_region (start, end, base_url, discard_comments, false); return Qnil; } +#endif /* HAVE_LIBXML2 */ \f + +DEFUN ("libxml-available-p", Flibxml_available_p, Slibxml_available_p, 0, 0, 0, + doc: /* Return t if libxml2 support is available in this instance of Emacs.*/) + (void) +{ +#ifdef HAVE_LIBXML2 +# ifdef WINDOWSNT + Lisp_Object found = Fassq (Qlibxml2, Vlibrary_cache); + if (CONSP (found)) + return XCDR (found); + else + { + Lisp_Object status; + status = init_libxml2_functions () ? Qt : Qnil; + Vlibrary_cache = Fcons (Fcons (Qlibxml2, status), Vlibrary_cache); + return status; + } +# else + return Qt; +# endif /* WINDOWSNT */ +#else + return Qnil; +#endif /* HAVE_LIBXML2 */ +} + /*********************************************************************** Initialization ***********************************************************************/ void syms_of_xml (void) { +#ifdef HAVE_LIBXML2 defsubr (&Slibxml_parse_html_region); defsubr (&Slibxml_parse_xml_region); +#endif + defsubr (&Slibxml_available_p); } - -#endif /* HAVE_LIBXML2 */ -- 2.15.0.rc1 ^ permalink raw reply related [flat|nested] 28+ messages in thread
* Re: What's the right way to detect libxml2? 2017-10-25 11:24 ` Robert Pluim @ 2017-10-28 9:10 ` Eli Zaretskii 2017-10-30 8:49 ` Robert Pluim 0 siblings, 1 reply; 28+ messages in thread From: Eli Zaretskii @ 2017-10-28 9:10 UTC (permalink / raw) To: Robert Pluim; +Cc: andrewjmoreton, emacs-devel > From: Robert Pluim <rpluim@gmail.com> > Date: Wed, 25 Oct 2017 13:24:34 +0200 > Cc: emacs-devel@gnu.org > > Ah yes, too much cut & paste. Revised version attached. Compile and > run-tested with and without xml2 on GNU/Linux. > > >From 10fe04edc5adf942c2bf9806eea5dd81edd2c9a5 Mon Sep 17 00:00:00 2001 > From: Robert Pluim <rpluim@gmail.com> > Date: Tue, 24 Oct 2017 19:01:28 +0200 > Subject: [PATCH] Provide libxml-available-p > > * src/emacs.c (main): Call syms_of_xml unconditionally > > * src/lisp.h: Provide syms_of_xml prototype even when > HAVE_LIBXML2 is not defined > > * src/xml.c (Flibxml_available_p): New function, cloned from > Fgnutls_available_p > (syms_of_xml): Provide Slibxml_available_p > > * doc/lispref/text.texi (Parsing HTML/XML): Document libxml-available-p This is okay for the master branch, but please also add a NEWS entry about the new function, and the fact that from now on the detection of libxml2 availability should use that. Thanks. ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: What's the right way to detect libxml2? 2017-10-28 9:10 ` Eli Zaretskii @ 2017-10-30 8:49 ` Robert Pluim 2017-10-30 18:07 ` Eli Zaretskii 2017-11-03 9:36 ` Eli Zaretskii 0 siblings, 2 replies; 28+ messages in thread From: Robert Pluim @ 2017-10-30 8:49 UTC (permalink / raw) To: Eli Zaretskii; +Cc: andrewjmoreton, emacs-devel [-- Attachment #1: Type: text/plain, Size: 369 bytes --] Eli Zaretskii <eliz@gnu.org> writes: > This is okay for the master branch, but please also add a NEWS entry > about the new function, and the fact that from now on the detection of > libxml2 availability should use that. Attached, as I don't have commit privileges, and I don't know whether my copyright assignment has finished being processed yet. Regards Robert [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-Provide-libxml-available-p.patch --] [-- Type: text/x-diff, Size: 4182 bytes --] From 7793e1feeac2714abee2bdf76ef7170e86821895 Mon Sep 17 00:00:00 2001 From: Robert Pluim <rpluim@gmail.com> Date: Tue, 24 Oct 2017 19:01:28 +0200 Subject: [PATCH] Provide libxml-available-p * src/emacs.c (main): Call syms_of_xml unconditionally * src/lisp.h: Provide syms_of_xml prototype even when HAVE_LIBXML2 is not defined * src/xml.c (Flibxml_available_p): New function, cloned from Fgnutls_available_p (syms_of_xml): Provide Slibxml_available_p * doc/lispref/text.texi (Parsing HTML/XML): Document libxml-available-p * etc/NEWS (libxml-available-p): Document it --- doc/lispref/text.texi | 5 +++++ etc/NEWS | 5 +++++ src/emacs.c | 2 -- src/lisp.h | 2 +- src/xml.c | 37 ++++++++++++++++++++++++++++++++----- 5 files changed, 43 insertions(+), 8 deletions(-) diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi index baa3c708e9..565d098069 100644 --- a/doc/lispref/text.texi +++ b/doc/lispref/text.texi @@ -4723,6 +4723,11 @@ Parsing HTML/XML @section Parsing HTML and XML @cindex parsing html +@defun libxml-available-p +This function returns non-@code{nil} if built-in libxml2 support is +available. +@end defun + When Emacs is compiled with libxml2 support, the following functions are available to parse HTML or XML text into Lisp object trees. diff --git a/etc/NEWS b/etc/NEWS index 9ae36bdb03..dfe1dcd0d9 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -39,6 +39,11 @@ text. +++ ** New function 'logcount' calculates an integer's Hamming weight. ++++ +** New function 'libxml-available-p' returns true if libxml support is + both compiled in and available. It is defined unconditionally and + can thus be used to detect libxml support. + \f * Editing Changes in Emacs 27.1 diff --git a/src/emacs.c b/src/emacs.c index 0fe7d9113b..808abcd9aa 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -1542,9 +1542,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem #endif #endif /* HAVE_X_WINDOWS */ -#ifdef HAVE_LIBXML2 syms_of_xml (); -#endif #ifdef HAVE_LCMS2 syms_of_lcms2 (); diff --git a/src/lisp.h b/src/lisp.h index 266370333f..cc8d90cbf1 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -4399,9 +4399,9 @@ extern void syms_of_xterm (void); extern char *x_get_keysym_name (int); #endif /* HAVE_WINDOW_SYSTEM */ -#ifdef HAVE_LIBXML2 /* Defined in xml.c. */ extern void syms_of_xml (void); +#ifdef HAVE_LIBXML2 extern void xml_cleanup_parser (void); #endif diff --git a/src/xml.c b/src/xml.c index d087a34a5e..7afaa63c42 100644 --- a/src/xml.c +++ b/src/xml.c @@ -18,15 +18,15 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ #include <config.h> +#include "lisp.h" +#include "buffer.h" + #ifdef HAVE_LIBXML2 #include <libxml/tree.h> #include <libxml/parser.h> #include <libxml/HTMLparser.h> -#include "lisp.h" -#include "buffer.h" - \f #ifdef WINDOWSNT @@ -291,16 +291,43 @@ If DISCARD-COMMENTS is non-nil, all HTML comments are discarded. */) return parse_region (start, end, base_url, discard_comments, false); return Qnil; } +#endif /* HAVE_LIBXML2 */ \f + +DEFUN ("libxml-available-p", Flibxml_available_p, Slibxml_available_p, 0, 0, 0, + doc: /* Return t if libxml2 support is available in this instance of Emacs.*/) + (void) +{ +#ifdef HAVE_LIBXML2 +# ifdef WINDOWSNT + Lisp_Object found = Fassq (Qlibxml2, Vlibrary_cache); + if (CONSP (found)) + return XCDR (found); + else + { + Lisp_Object status; + status = init_libxml2_functions () ? Qt : Qnil; + Vlibrary_cache = Fcons (Fcons (Qlibxml2, status), Vlibrary_cache); + return status; + } +# else + return Qt; +# endif /* WINDOWSNT */ +#else + return Qnil; +#endif /* HAVE_LIBXML2 */ +} + /*********************************************************************** Initialization ***********************************************************************/ void syms_of_xml (void) { +#ifdef HAVE_LIBXML2 defsubr (&Slibxml_parse_html_region); defsubr (&Slibxml_parse_xml_region); +#endif + defsubr (&Slibxml_available_p); } - -#endif /* HAVE_LIBXML2 */ -- 2.15.0.rc1 ^ permalink raw reply related [flat|nested] 28+ messages in thread
* Re: What's the right way to detect libxml2? 2017-10-30 8:49 ` Robert Pluim @ 2017-10-30 18:07 ` Eli Zaretskii 2017-10-30 18:10 ` Eli Zaretskii 2017-11-03 9:36 ` Eli Zaretskii 1 sibling, 1 reply; 28+ messages in thread From: Eli Zaretskii @ 2017-10-30 18:07 UTC (permalink / raw) To: Robert Pluim; +Cc: andrewjmoreton, emacs-devel > From: Robert Pluim <rpluim@gmail.com> > Cc: andrewjmoreton@gmail.com, emacs-devel@gnu.org > Date: Mon, 30 Oct 2017 09:49:45 +0100 > > > This is okay for the master branch, but please also add a NEWS entry > > about the new function, and the fact that from now on the detection of > > libxml2 availability should use that. > > Attached, as I don't have commit privileges Thanks. > and I don't know whether my copyright assignment has finished being > processed yet. It hasn't, so we will have to wait with pushing this until it is. ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: What's the right way to detect libxml2? 2017-10-30 18:07 ` Eli Zaretskii @ 2017-10-30 18:10 ` Eli Zaretskii 0 siblings, 0 replies; 28+ messages in thread From: Eli Zaretskii @ 2017-10-30 18:10 UTC (permalink / raw) To: rpluim; +Cc: andrewjmoreton, emacs-devel > Date: Mon, 30 Oct 2017 20:07:45 +0200 > From: Eli Zaretskii <eliz@gnu.org> > Cc: andrewjmoreton@gmail.com, emacs-devel@gnu.org > > > and I don't know whether my copyright assignment has finished being > > processed yet. > > It hasn't Oops, I see that it has just finished being processed. ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: What's the right way to detect libxml2? 2017-10-30 8:49 ` Robert Pluim 2017-10-30 18:07 ` Eli Zaretskii @ 2017-11-03 9:36 ` Eli Zaretskii 2017-11-03 17:17 ` Robert Pluim 1 sibling, 1 reply; 28+ messages in thread From: Eli Zaretskii @ 2017-11-03 9:36 UTC (permalink / raw) To: Robert Pluim; +Cc: emacs-devel > From: Robert Pluim <rpluim@gmail.com> > Cc: andrewjmoreton@gmail.com, emacs-devel@gnu.org > Date: Mon, 30 Oct 2017 09:49:45 +0100 > > > This is okay for the master branch, but please also add a NEWS entry > > about the new function, and the fact that from now on the detection of > > libxml2 availability should use that. > > Attached, as I don't have commit privileges, and I don't know whether > my copyright assignment has finished being processed yet. Thanks, pushed to the master branch. A comment for the future: please always end the log en tries with a period, to make them complete sentences. Like this: * src/emacs.c (main): Call syms_of_xml unconditionally. * src/lisp.h: Provide syms_of_xml prototype even when HAVE_LIBXML2 is not defined. * src/xml.c (Flibxml_available_p): New function, cloned from Fgnutls_available_p. (syms_of_xml): Provide Slibxml_available_p. ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: What's the right way to detect libxml2? 2017-11-03 9:36 ` Eli Zaretskii @ 2017-11-03 17:17 ` Robert Pluim 0 siblings, 0 replies; 28+ messages in thread From: Robert Pluim @ 2017-11-03 17:17 UTC (permalink / raw) To: Eli Zaretskii; +Cc: emacs-devel Eli Zaretskii <eliz@gnu.org> writes: >> From: Robert Pluim <rpluim@gmail.com> >> Cc: andrewjmoreton@gmail.com, emacs-devel@gnu.org >> Date: Mon, 30 Oct 2017 09:49:45 +0100 >> >> > This is okay for the master branch, but please also add a NEWS entry >> > about the new function, and the fact that from now on the detection of >> > libxml2 availability should use that. >> >> Attached, as I don't have commit privileges, and I don't know whether >> my copyright assignment has finished being processed yet. > > Thanks, pushed to the master branch. > > A comment for the future: please always end the log en tries with a > period, to make them complete sentences. Like this: > > * src/xml.c (Flibxml_available_p): New function, cloned from > Fgnutls_available_p. > (syms_of_xml): Provide Slibxml_available_p. I tend to use the full stop as a separator rather than a terminator, but I'll adjust for Emacs. Robert ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: What's the right way to detect libxml2? 2017-10-24 13:38 ` Andy Moreton 2017-10-24 14:01 ` Clément Pit-Claudel @ 2017-10-24 21:49 ` Richard Stallman 2017-10-24 22:32 ` John Wiegley ` (3 more replies) 1 sibling, 4 replies; 28+ messages in thread From: Richard Stallman @ 2017-10-24 21:49 UTC (permalink / raw) To: Andy Moreton; +Cc: emacs-devel [[[ To any NSA and FBI agents reading my email: please consider ]]] [[[ whether defending the US Constitution against all enemies, ]]] [[[ foreign or domestic, requires you to follow Snowden's example. ]]] Every time I see "Tramp", what enters into my mind is "Trump". I may not be the only one who reacts this way. Might we want to change its name? Does the name "Tramp" have a particular meaning? -- Dr Richard Stallman President, Free Software Foundation (gnu.org, fsf.org) Internet Hall-of-Famer (internethalloffame.org) Skype: No way! See stallman.org/skype.html. ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: What's the right way to detect libxml2? 2017-10-24 21:49 ` Richard Stallman @ 2017-10-24 22:32 ` John Wiegley 2017-10-25 1:45 ` Stefan Monnier 2017-10-25 4:39 ` Werner LEMBERG 2017-10-25 7:19 ` To Tramp or not to Tramp (was: What's the right way to detect libxml2?) Michael Albinus ` (2 subsequent siblings) 3 siblings, 2 replies; 28+ messages in thread From: John Wiegley @ 2017-10-24 22:32 UTC (permalink / raw) To: Richard Stallman; +Cc: Andy Moreton, emacs-devel >>>>> "RS" == Richard Stallman <rms@gnu.org> writes: RS> Every time I see "Tramp", what enters into my mind is "Trump". I may not RS> be the only one who reacts this way. Might we want to change its name? RS> Does the name "Tramp" have a particular meaning? I would argue against this, it will break everyone who uses the 'tramp-*' namespace, creating far more trouble than the trouble it saves. We only have to wait at most 7 more years. Until tomorrow in Emacs time scales.... -- John Wiegley GPG fingerprint = 4710 CF98 AF9B 327B B80F http://newartisans.com 60E1 46C4 BD1A 7AC1 4BA2 ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: What's the right way to detect libxml2? 2017-10-24 22:32 ` John Wiegley @ 2017-10-25 1:45 ` Stefan Monnier 2017-10-25 22:05 ` Paul Eggert 2017-10-26 3:42 ` Richard Stallman 2017-10-25 4:39 ` Werner LEMBERG 1 sibling, 2 replies; 28+ messages in thread From: Stefan Monnier @ 2017-10-25 1:45 UTC (permalink / raw) To: emacs-devel RS> Every time I see "Tramp", what enters into my mind is "Trump". I may not RS> be the only one who reacts this way. Might we want to change its name? Would we do this if some despicable character became famous under the name E.Max? Stefan ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: What's the right way to detect libxml2? 2017-10-25 1:45 ` Stefan Monnier @ 2017-10-25 22:05 ` Paul Eggert 2017-10-26 3:42 ` Richard Stallman 1 sibling, 0 replies; 28+ messages in thread From: Paul Eggert @ 2017-10-25 22:05 UTC (permalink / raw) To: Stefan Monnier, emacs-devel On 10/24/2017 06:45 PM, Stefan Monnier wrote: > Would we do this if some despicable character became famous under the > name E.Max? For what it's worth, our president's last name is indeed spelled "Tramp" in Serbocroatian. Here's a sample quote from Blic: "Američki predsednik Donald Tramp izjavio je danas da nije pozvan na razgovor sa specijalnim savetnikom Robertom Milerom, koji vodi federalnu istragu o navodnom mešanju Rusije u predsedničke izbore u SAD 2016. godine." http://www.blic.rs/vesti/svet/tramp-razgovor-o-istrazi-o-rusiji-niko-me-nije-zvao/0w7nxx6 Not that I think Emacs should change Tramp's name because of this. Tramp will outlive Trump. ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: What's the right way to detect libxml2? 2017-10-25 1:45 ` Stefan Monnier 2017-10-25 22:05 ` Paul Eggert @ 2017-10-26 3:42 ` Richard Stallman 1 sibling, 0 replies; 28+ messages in thread From: Richard Stallman @ 2017-10-26 3:42 UTC (permalink / raw) To: Stefan Monnier; +Cc: emacs-devel [[[ To any NSA and FBI agents reading my email: please consider ]]] [[[ whether defending the US Constitution against all enemies, ]]] [[[ foreign or domestic, requires you to follow Snowden's example. ]]] > Would we do this if some despicable character became famous under the > name E.Max? I don't know. Fortunately it is not likely. But there was someone at MIT that called himself "Electronic Max", pr "E Max" for short. I found out when someone told me he was a "friend of E Max". The idea of being a friend of Emacs struck me as slightly strange ;-). So I asked him to explain, and thus I found out about E Max. -- Dr Richard Stallman President, Free Software Foundation (gnu.org, fsf.org) Internet Hall-of-Famer (internethalloffame.org) Skype: No way! See stallman.org/skype.html. ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: What's the right way to detect libxml2? 2017-10-24 22:32 ` John Wiegley 2017-10-25 1:45 ` Stefan Monnier @ 2017-10-25 4:39 ` Werner LEMBERG 1 sibling, 0 replies; 28+ messages in thread From: Werner LEMBERG @ 2017-10-25 4:39 UTC (permalink / raw) To: johnw; +Cc: andrewjmoreton, rms, emacs-devel > RS> Every time I see "Tramp", what enters into my mind is "Trump". I > RS> be the only one who reacts this way. Might we want to change its > RS> name? > > RS> Does the name "Tramp" have a particular meaning? > > I would argue against this, it will break everyone who uses the > 'tramp-*' namespace, creating far more trouble than the trouble it > saves. We only have to wait at most 7 more years. Until tomorrow in > Emacs time scales.... Indeed. What comes to my mind first is the title of the famous song `The Lady is a Tramp'... Werner ^ permalink raw reply [flat|nested] 28+ messages in thread
* To Tramp or not to Tramp (was: What's the right way to detect libxml2?) 2017-10-24 21:49 ` Richard Stallman 2017-10-24 22:32 ` John Wiegley @ 2017-10-25 7:19 ` Michael Albinus 2017-10-25 10:56 ` Kaushal Modi 2017-10-26 7:56 ` To Tramp or not to Tramp martin rudalics 2017-10-25 22:29 ` What's the right way to detect libxml2? Richard Copley 2017-10-26 10:48 ` Marcin Borkowski 3 siblings, 2 replies; 28+ messages in thread From: Michael Albinus @ 2017-10-25 7:19 UTC (permalink / raw) To: Richard Stallman; +Cc: Andy Moreton, emacs-devel Richard Stallman <rms@gnu.org> writes: Hi Richard, > Every time I see "Tramp", what enters into my mind is "Trump". > I may not be the only one who reacts this way. > Might we want to change its name? Being the Tramp maintainer, I'm opposed to this. I do not want to let whomever dictate what we do, being the POTUS or not. And as John said, there are many external uses of the tramp-* namespace. As a practical matter, I ignore every message silently, which uses the "joke" to name Tramp Trump. > Does the name "Tramp" have a particular meaning? “Transparent Remote (file) Access, Multiple Protocol”. Best regards, Michael. ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: To Tramp or not to Tramp (was: What's the right way to detect libxml2?) 2017-10-25 7:19 ` To Tramp or not to Tramp (was: What's the right way to detect libxml2?) Michael Albinus @ 2017-10-25 10:56 ` Kaushal Modi 2017-10-26 7:56 ` To Tramp or not to Tramp martin rudalics 1 sibling, 0 replies; 28+ messages in thread From: Kaushal Modi @ 2017-10-25 10:56 UTC (permalink / raw) To: Michael Albinus; +Cc: Andy Moreton, Richard Stallman, emacs-devel [-- Attachment #1: Type: text/plain, Size: 449 bytes --] On Wed, Oct 25, 2017, 3:19 AM Michael Albinus <michael.albinus@gmx.de> wrote: > Richard Stallman <rms@gnu.org> writes: > > Hi Richard, > > > Every time I see "Tramp", what enters into my mind is "Trump". > > I may not be the only one who reacts this way. > > Might we want to change its name? > > Being the Tramp maintainer, I'm opposed to this. I do not want to let > whomever dictate what we do, being the POTUS or not. > +1 > -- Kaushal Modi [-- Attachment #2: Type: text/html, Size: 1066 bytes --] ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: To Tramp or not to Tramp 2017-10-25 7:19 ` To Tramp or not to Tramp (was: What's the right way to detect libxml2?) Michael Albinus 2017-10-25 10:56 ` Kaushal Modi @ 2017-10-26 7:56 ` martin rudalics 2017-10-27 2:44 ` Richard Stallman 1 sibling, 1 reply; 28+ messages in thread From: martin rudalics @ 2017-10-26 7:56 UTC (permalink / raw) To: Michael Albinus, Richard Stallman; +Cc: Andy Moreton, emacs-devel > Being the Tramp maintainer, I'm opposed to this. I do not want to let > whomever dictate what we do, being the POTUS or not. I do not recall a similar discussion about "Bash". Does anyone? martin ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: To Tramp or not to Tramp 2017-10-26 7:56 ` To Tramp or not to Tramp martin rudalics @ 2017-10-27 2:44 ` Richard Stallman 2017-10-27 4:01 ` John Wiegley 0 siblings, 1 reply; 28+ messages in thread From: Richard Stallman @ 2017-10-27 2:44 UTC (permalink / raw) To: martin rudalics; +Cc: andrewjmoreton, michael.albinus, emacs-devel [[[ To any NSA and FBI agents reading my email: please consider ]]] [[[ whether defending the US Constitution against all enemies, ]]] [[[ foreign or domestic, requires you to follow Snowden's example. ]]] > I do not recall a similar discussion about "Bash". Does anyone? I don't know of any problem with the name "Bash". It stands for "Bourne Again Shell", and I think it is a good joke. -- Dr Richard Stallman President, Free Software Foundation (gnu.org, fsf.org) Internet Hall-of-Famer (internethalloffame.org) Skype: No way! See stallman.org/skype.html. ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: To Tramp or not to Tramp 2017-10-27 2:44 ` Richard Stallman @ 2017-10-27 4:01 ` John Wiegley 2017-10-27 20:58 ` Richard Stallman 0 siblings, 1 reply; 28+ messages in thread From: John Wiegley @ 2017-10-27 4:01 UTC (permalink / raw) To: Richard Stallman Cc: martin rudalics, andrewjmoreton, michael.albinus, emacs-devel >>>>> "RS" == Richard Stallman <rms@gnu.org> writes: >> I do not recall a similar discussion about "Bash". Does anyone? RS> I don't know of any problem with the name "Bash". It stands for "Bourne RS> Again Shell", and I think it is a good joke. I think he means the nearness of it to "Bush". :) -- John Wiegley GPG fingerprint = 4710 CF98 AF9B 327B B80F http://newartisans.com 60E1 46C4 BD1A 7AC1 4BA2 ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: To Tramp or not to Tramp 2017-10-27 4:01 ` John Wiegley @ 2017-10-27 20:58 ` Richard Stallman 0 siblings, 0 replies; 28+ messages in thread From: Richard Stallman @ 2017-10-27 20:58 UTC (permalink / raw) To: John Wiegley; +Cc: rudalics, andrewjmoreton, michael.albinus, emacs-devel [[[ To any NSA and FBI agents reading my email: please consider ]]] [[[ whether defending the US Constitution against all enemies, ]]] [[[ foreign or domestic, requires you to follow Snowden's example. ]]] > I think he means the nearness of it to "Bush". :) Bush committed war crimes but he did not try to convert the US into a tyrannical regime of bigotry. As a result, the name "trump" triggers much more disgust than "bush". But I am not insisting on anything. I just raised the question. -- Dr Richard Stallman President, Free Software Foundation (gnu.org, fsf.org) Internet Hall-of-Famer (internethalloffame.org) Skype: No way! See stallman.org/skype.html. ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: What's the right way to detect libxml2? 2017-10-24 21:49 ` Richard Stallman 2017-10-24 22:32 ` John Wiegley 2017-10-25 7:19 ` To Tramp or not to Tramp (was: What's the right way to detect libxml2?) Michael Albinus @ 2017-10-25 22:29 ` Richard Copley 2017-10-26 10:48 ` Marcin Borkowski 3 siblings, 0 replies; 28+ messages in thread From: Richard Copley @ 2017-10-25 22:29 UTC (permalink / raw) To: Richard Stallman; +Cc: Andy Moreton, Emacs Development On 24 October 2017 at 22:49, Richard Stallman <rms@gnu.org> wrote: > [[[ To any NSA and FBI agents reading my email: please consider ]]] > [[[ whether defending the US Constitution against all enemies, ]]] > [[[ foreign or domestic, requires you to follow Snowden's example. ]]] > Does the name "Tramp" have a particular meaning? Transparent Remote Access, Multiple Protocols. (5 seconds' research.) ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: What's the right way to detect libxml2? 2017-10-24 21:49 ` Richard Stallman ` (2 preceding siblings ...) 2017-10-25 22:29 ` What's the right way to detect libxml2? Richard Copley @ 2017-10-26 10:48 ` Marcin Borkowski 3 siblings, 0 replies; 28+ messages in thread From: Marcin Borkowski @ 2017-10-26 10:48 UTC (permalink / raw) To: rms; +Cc: Andy Moreton, emacs-devel On 2017-10-24, at 23:49, Richard Stallman <rms@gnu.org> wrote: > [[[ To any NSA and FBI agents reading my email: please consider ]]] > [[[ whether defending the US Constitution against all enemies, ]]] > [[[ foreign or domestic, requires you to follow Snowden's example. ]]] > > Every time I see "Tramp", what enters into my mind is "Trump". > I may not be the only one who reacts this way. > Might we want to change its name? Why? While I'm not a bridge fan, I don't have any problem with the term. <off-topic> (Also, another nice association is with the USA regaining *some* reason after 8 years of insanity.) </off-topic> Best, -- Marcin Borkowski ^ permalink raw reply [flat|nested] 28+ messages in thread
end of thread, other threads:[~2017-11-03 17:17 UTC | newest] Thread overview: 28+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-10-22 14:14 What's the right way to detect libxml2? Clément Pit-Claudel 2017-10-22 16:27 ` Phillip Lord 2017-10-24 13:38 ` Andy Moreton 2017-10-24 14:01 ` Clément Pit-Claudel 2017-10-24 15:33 ` Andy Moreton 2017-10-24 17:04 ` Robert Pluim 2017-10-24 17:46 ` Andy Moreton 2017-10-25 11:24 ` Robert Pluim 2017-10-28 9:10 ` Eli Zaretskii 2017-10-30 8:49 ` Robert Pluim 2017-10-30 18:07 ` Eli Zaretskii 2017-10-30 18:10 ` Eli Zaretskii 2017-11-03 9:36 ` Eli Zaretskii 2017-11-03 17:17 ` Robert Pluim 2017-10-24 21:49 ` Richard Stallman 2017-10-24 22:32 ` John Wiegley 2017-10-25 1:45 ` Stefan Monnier 2017-10-25 22:05 ` Paul Eggert 2017-10-26 3:42 ` Richard Stallman 2017-10-25 4:39 ` Werner LEMBERG 2017-10-25 7:19 ` To Tramp or not to Tramp (was: What's the right way to detect libxml2?) Michael Albinus 2017-10-25 10:56 ` Kaushal Modi 2017-10-26 7:56 ` To Tramp or not to Tramp martin rudalics 2017-10-27 2:44 ` Richard Stallman 2017-10-27 4:01 ` John Wiegley 2017-10-27 20:58 ` Richard Stallman 2017-10-25 22:29 ` What's the right way to detect libxml2? Richard Copley 2017-10-26 10:48 ` Marcin Borkowski
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).