From: Robert Pluim <rpluim@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: andrewjmoreton@gmail.com, emacs-devel@gnu.org
Subject: Re: What's the right way to detect libxml2?
Date: Mon, 30 Oct 2017 09:49:45 +0100 [thread overview]
Message-ID: <87d155aul2.fsf@gmail.com> (raw)
In-Reply-To: <83wp3f63jk.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 28 Oct 2017 12:10:39 +0300")
[-- 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
next prev parent reply other threads:[~2017-10-30 8:49 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87d155aul2.fsf@gmail.com \
--to=rpluim@gmail.com \
--cc=andrewjmoreton@gmail.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.