[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 620247a: New function 'libxml-available-p'
From: |
Eli Zaretskii |
Subject: |
[Emacs-diffs] master 620247a: New function 'libxml-available-p' |
Date: |
Fri, 3 Nov 2017 05:34:31 -0400 (EDT) |
branch: master
commit 620247ac205b80ceb142ee70500ab2c3ffa46fe2
Author: Robert Pluim <address@hidden>
Commit: Eli Zaretskii <address@hidden>
New function '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.
(GnuTLS Cryptography, Format of GnuTLS Cryptography Inputs)
(Document Object Model): Fix indentation of the first paragraph.
* etc/NEWS (libxml-available-p): Mention libxml-available-p.
---
doc/lispref/text.texi | 25 ++++++++++++++++---------
etc/NEWS | 8 ++++++++
src/emacs.c | 2 --
src/lisp.h | 2 +-
src/xml.c | 37 ++++++++++++++++++++++++++++++++-----
5 files changed, 57 insertions(+), 17 deletions(-)
diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi
index baa3c70..6094a41 100644
--- a/doc/lispref/text.texi
+++ b/doc/lispref/text.texi
@@ -4536,9 +4536,9 @@ It should be somewhat more efficient on larger buffers
than
@cindex symmetric cipher
@cindex cipher, symmetric
-If compiled with GnuTLS, Emacs offers built-in cryptographic support.
-Following the GnuTLS API terminology, the available tools are digests,
-MACs, symmetric ciphers, and AEAD ciphers.
+ If compiled with GnuTLS, Emacs offers built-in cryptographic
+support. Following the GnuTLS API terminology, the available tools
+are digests, MACs, symmetric ciphers, and AEAD ciphers.
The terms used herein, such as IV (Initialization Vector), require
some familiarity with cryptography and will not be defined in detail.
@@ -4556,7 +4556,7 @@ structure of the GnuTLS library.
@cindex format of gnutls cryptography inputs
@cindex gnutls cryptography inputs format
-The inputs to GnuTLS cryptographic functions can be specified in
+ The inputs to GnuTLS cryptographic functions can be specified in
several ways, both as primitive Emacs Lisp types or as lists.
The list form is currently similar to how @code{md5} and
@@ -4723,8 +4723,15 @@ IV used.
@section Parsing HTML and XML
@cindex parsing html
-When Emacs is compiled with libxml2 support, the following functions
-are available to parse HTML or XML text into Lisp object trees.
+ Emacs can be compiled with built-in libxml2 support.
+
address@hidden libxml-available-p
+This function returns address@hidden if built-in libxml2 support is
+available in this Emacs session.
address@hidden defun
+
+When libxml2 support is available, the following functions can be used
+to parse HTML or XML text into Lisp object trees.
@defun libxml-parse-html-region start end &optional base-url discard-comments
This function parses the text between @var{start} and @var{end} as
@@ -4791,9 +4798,9 @@ about syntax).
@cindex DOM
@cindex Document Object Model
-The @acronym{DOM} returned by @code{libxml-parse-html-region} (and the
-other @acronym{XML} parsing functions) is a tree structure where each
-node has a node name (called a @dfn{tag}), and optional key/value
+ The @acronym{DOM} returned by @code{libxml-parse-html-region} (and
+the other @acronym{XML} parsing functions) is a tree structure where
+each node has a node name (called a @dfn{tag}), and optional key/value
@dfn{attribute} list, and then a list of @dfn{child nodes}. The child
nodes are either strings or @acronym{DOM} objects.
diff --git a/etc/NEWS b/etc/NEWS
index 9ae36bd..f948140 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -39,6 +39,14 @@ text.
+++
** New function 'logcount' calculates an integer's Hamming weight.
++++
+** New function 'libxml-available-p'.
+This function returns non-nil if libxml support is both compiled in
+and available at run time. Lisp programs should use this function to
+detect built-in libxml support, instead of testing for that
+indirectly, e.g., by checking that functions like
+'libxml-parse-html-region' return nil.
+
* Editing Changes in Emacs 27.1
diff --git a/src/emacs.c b/src/emacs.c
index 0fe7d91..808abcd 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 7884348..1ce32f3 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -4391,9 +4391,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 d087a34..7afaa63 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"
-
#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 */
+
+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 */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 620247a: New function 'libxml-available-p',
Eli Zaretskii <=