aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Pluim2017-11-03 11:33:06 +0200
committerEli Zaretskii2017-11-03 11:33:06 +0200
commit620247ac205b80ceb142ee70500ab2c3ffa46fe2 (patch)
treedeb29eb58c456575d69b51f92decb8faab550c45
parent92b2cedec60f47faa896963b51bfd370eb3e71cb (diff)
downloademacs-620247ac205b80ceb142ee70500ab2c3ffa46fe2.tar.gz
emacs-620247ac205b80ceb142ee70500ab2c3ffa46fe2.zip
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.
-rw-r--r--doc/lispref/text.texi25
-rw-r--r--etc/NEWS8
-rw-r--r--src/emacs.c2
-rw-r--r--src/lisp.h2
-rw-r--r--src/xml.c37
5 files changed, 57 insertions, 17 deletions
diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi
index baa3c708e90..6094a41c473 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
4536@cindex symmetric cipher 4536@cindex symmetric cipher
4537@cindex cipher, symmetric 4537@cindex cipher, symmetric
4538 4538
4539If compiled with GnuTLS, Emacs offers built-in cryptographic support. 4539 If compiled with GnuTLS, Emacs offers built-in cryptographic
4540Following the GnuTLS API terminology, the available tools are digests, 4540support. Following the GnuTLS API terminology, the available tools
4541MACs, symmetric ciphers, and AEAD ciphers. 4541are digests, MACs, symmetric ciphers, and AEAD ciphers.
4542 4542
4543The terms used herein, such as IV (Initialization Vector), require 4543The terms used herein, such as IV (Initialization Vector), require
4544some familiarity with cryptography and will not be defined in detail. 4544some familiarity with cryptography and will not be defined in detail.
@@ -4556,7 +4556,7 @@ structure of the GnuTLS library.
4556@cindex format of gnutls cryptography inputs 4556@cindex format of gnutls cryptography inputs
4557@cindex gnutls cryptography inputs format 4557@cindex gnutls cryptography inputs format
4558 4558
4559The inputs to GnuTLS cryptographic functions can be specified in 4559 The inputs to GnuTLS cryptographic functions can be specified in
4560several ways, both as primitive Emacs Lisp types or as lists. 4560several ways, both as primitive Emacs Lisp types or as lists.
4561 4561
4562The list form is currently similar to how @code{md5} and 4562The list form is currently similar to how @code{md5} and
@@ -4723,8 +4723,15 @@ IV used.
4723@section Parsing HTML and XML 4723@section Parsing HTML and XML
4724@cindex parsing html 4724@cindex parsing html
4725 4725
4726When Emacs is compiled with libxml2 support, the following functions 4726 Emacs can be compiled with built-in libxml2 support.
4727are available to parse HTML or XML text into Lisp object trees. 4727
4728@defun libxml-available-p
4729This function returns non-@code{nil} if built-in libxml2 support is
4730available in this Emacs session.
4731@end defun
4732
4733When libxml2 support is available, the following functions can be used
4734to parse HTML or XML text into Lisp object trees.
4728 4735
4729@defun libxml-parse-html-region start end &optional base-url discard-comments 4736@defun libxml-parse-html-region start end &optional base-url discard-comments
4730This function parses the text between @var{start} and @var{end} as 4737This function parses the text between @var{start} and @var{end} as
@@ -4791,9 +4798,9 @@ about syntax).
4791@cindex DOM 4798@cindex DOM
4792@cindex Document Object Model 4799@cindex Document Object Model
4793 4800
4794The @acronym{DOM} returned by @code{libxml-parse-html-region} (and the 4801 The @acronym{DOM} returned by @code{libxml-parse-html-region} (and
4795other @acronym{XML} parsing functions) is a tree structure where each 4802the other @acronym{XML} parsing functions) is a tree structure where
4796node has a node name (called a @dfn{tag}), and optional key/value 4803each node has a node name (called a @dfn{tag}), and optional key/value
4797@dfn{attribute} list, and then a list of @dfn{child nodes}. The child 4804@dfn{attribute} list, and then a list of @dfn{child nodes}. The child
4798nodes are either strings or @acronym{DOM} objects. 4805nodes are either strings or @acronym{DOM} objects.
4799 4806
diff --git a/etc/NEWS b/etc/NEWS
index 9ae36bdb032..f9481405e4e 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -39,6 +39,14 @@ text.
39+++ 39+++
40** New function 'logcount' calculates an integer's Hamming weight. 40** New function 'logcount' calculates an integer's Hamming weight.
41 41
42+++
43** New function 'libxml-available-p'.
44This function returns non-nil if libxml support is both compiled in
45and available at run time. Lisp programs should use this function to
46detect built-in libxml support, instead of testing for that
47indirectly, e.g., by checking that functions like
48'libxml-parse-html-region' return nil.
49
42 50
43* Editing Changes in Emacs 27.1 51* Editing Changes in Emacs 27.1
44 52
diff --git a/src/emacs.c b/src/emacs.c
index 0fe7d9113b4..808abcd9aa2 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
1542#endif 1542#endif
1543#endif /* HAVE_X_WINDOWS */ 1543#endif /* HAVE_X_WINDOWS */
1544 1544
1545#ifdef HAVE_LIBXML2
1546 syms_of_xml (); 1545 syms_of_xml ();
1547#endif
1548 1546
1549#ifdef HAVE_LCMS2 1547#ifdef HAVE_LCMS2
1550 syms_of_lcms2 (); 1548 syms_of_lcms2 ();
diff --git a/src/lisp.h b/src/lisp.h
index 78843483edc..1ce32f33420 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -4391,9 +4391,9 @@ extern void syms_of_xterm (void);
4391extern char *x_get_keysym_name (int); 4391extern char *x_get_keysym_name (int);
4392#endif /* HAVE_WINDOW_SYSTEM */ 4392#endif /* HAVE_WINDOW_SYSTEM */
4393 4393
4394#ifdef HAVE_LIBXML2
4395/* Defined in xml.c. */ 4394/* Defined in xml.c. */
4396extern void syms_of_xml (void); 4395extern void syms_of_xml (void);
4396#ifdef HAVE_LIBXML2
4397extern void xml_cleanup_parser (void); 4397extern void xml_cleanup_parser (void);
4398#endif 4398#endif
4399 4399
diff --git a/src/xml.c b/src/xml.c
index d087a34a5e0..7afaa63c421 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/>. */
18 18
19#include <config.h> 19#include <config.h>
20 20
21#include "lisp.h"
22#include "buffer.h"
23
21#ifdef HAVE_LIBXML2 24#ifdef HAVE_LIBXML2
22 25
23#include <libxml/tree.h> 26#include <libxml/tree.h>
24#include <libxml/parser.h> 27#include <libxml/parser.h>
25#include <libxml/HTMLparser.h> 28#include <libxml/HTMLparser.h>
26 29
27#include "lisp.h"
28#include "buffer.h"
29
30 30
31#ifdef WINDOWSNT 31#ifdef WINDOWSNT
32 32
@@ -291,16 +291,43 @@ If DISCARD-COMMENTS is non-nil, all HTML comments are discarded. */)
291 return parse_region (start, end, base_url, discard_comments, false); 291 return parse_region (start, end, base_url, discard_comments, false);
292 return Qnil; 292 return Qnil;
293} 293}
294#endif /* HAVE_LIBXML2 */
294 295
295 296
297
298DEFUN ("libxml-available-p", Flibxml_available_p, Slibxml_available_p, 0, 0, 0,
299 doc: /* Return t if libxml2 support is available in this instance of Emacs.*/)
300 (void)
301{
302#ifdef HAVE_LIBXML2
303# ifdef WINDOWSNT
304 Lisp_Object found = Fassq (Qlibxml2, Vlibrary_cache);
305 if (CONSP (found))
306 return XCDR (found);
307 else
308 {
309 Lisp_Object status;
310 status = init_libxml2_functions () ? Qt : Qnil;
311 Vlibrary_cache = Fcons (Fcons (Qlibxml2, status), Vlibrary_cache);
312 return status;
313 }
314# else
315 return Qt;
316# endif /* WINDOWSNT */
317#else
318 return Qnil;
319#endif /* HAVE_LIBXML2 */
320}
321
296/*********************************************************************** 322/***********************************************************************
297 Initialization 323 Initialization
298 ***********************************************************************/ 324 ***********************************************************************/
299void 325void
300syms_of_xml (void) 326syms_of_xml (void)
301{ 327{
328#ifdef HAVE_LIBXML2
302 defsubr (&Slibxml_parse_html_region); 329 defsubr (&Slibxml_parse_html_region);
303 defsubr (&Slibxml_parse_xml_region); 330 defsubr (&Slibxml_parse_xml_region);
331#endif
332 defsubr (&Slibxml_available_p);
304} 333}
305
306#endif /* HAVE_LIBXML2 */