aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2018-04-14 17:14:01 +0200
committerLars Ingebrigtsen2018-04-14 17:14:01 +0200
commite20d7381ee85611f9e1d1e6bef4fe2d7e2ae7780 (patch)
tree9eb74901b854761d09426492e47de54f5e8e5ed4
parentdb71b3182778b66fad3865825777b06cc20b89a8 (diff)
downloademacs-e20d7381ee85611f9e1d1e6bef4fe2d7e2ae7780.tar.gz
emacs-e20d7381ee85611f9e1d1e6bef4fe2d7e2ae7780.zip
Make DISCARD-COMMENTS in `libxml-parse-{html,xml}-region' obsolete
* doc/lispref/text.texi (Parsing HTML/XML): Mention that discard-comments is obsolete. * lisp/xml.el (xml-remove-comments): New function (bug#27178). * src/xml.c (Flibxml_parse_html_region): Clarify what DISCARD-COMMENTS actually does, and say that the parameter is obsolete. (Flibxml_parse_xml_region): Ditto.
-rw-r--r--doc/lispref/text.texi5
-rw-r--r--etc/NEWS8
-rw-r--r--lisp/xml.el13
-rw-r--r--src/xml.c14
4 files changed, 37 insertions, 3 deletions
diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi
index 9769043b729..e89bd0b7ef7 100644
--- a/doc/lispref/text.texi
+++ b/doc/lispref/text.texi
@@ -4724,7 +4724,10 @@ The optional argument @var{base-url}, if non-@code{nil}, should be a
4724string specifying the base URL for relative URLs occurring in links. 4724string specifying the base URL for relative URLs occurring in links.
4725 4725
4726If the optional argument @var{discard-comments} is non-@code{nil}, 4726If the optional argument @var{discard-comments} is non-@code{nil},
4727then the parse tree is created without any comments. 4727any top-level comment is discarded. (This argument is obsolete and
4728will be removed in future Emacs versions. To remove comments, use the
4729@code{xml-remove-comments} utility function on the data before you
4730call the parsing function.)
4728 4731
4729In the parse tree, each HTML node is represented by a list in which 4732In the parse tree, each HTML node is represented by a list in which
4730the first element is a symbol representing the node name, the second 4733the first element is a symbol representing the node name, the second
diff --git a/etc/NEWS b/etc/NEWS
index 980a5b453a2..0bf5ba80b38 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -116,6 +116,14 @@ indirectly, e.g., by checking that functions like
116'libxml-parse-html-region' return nil. 116'libxml-parse-html-region' return nil.
117 117
118+++ 118+++
119** `libxml-parse-xml-region' and `libxml-parse-html' region take
120a parameter that's called DISCARD-COMMENTS, but it really only
121discards the top-level comment. Therefore this parameter is now
122obsolete, and the new utility function `xml-remove-comments' can be
123used to remove comments before calling the libxml functions to parse
124the data.
125
126+++
119** New function 'fill-polish-nobreak-p', to be used in 'fill-nobreak-predicate'. 127** New function 'fill-polish-nobreak-p', to be used in 'fill-nobreak-predicate'.
120It blocks line breaking after a one-letter word, also in the case when 128It blocks line breaking after a one-letter word, also in the case when
121this word is preceded by a non-space, but non-alphanumeric character. 129this word is preceded by a non-space, but non-alphanumeric character.
diff --git a/lisp/xml.el b/lisp/xml.el
index 3bc8c08cb7b..6ce944ccb82 100644
--- a/lisp/xml.el
+++ b/lisp/xml.el
@@ -1073,6 +1073,19 @@ The first line is indented with INDENT-STRING."
1073 (insert ?\n indent-string)) 1073 (insert ?\n indent-string))
1074 (insert ?< ?/ (symbol-name (xml-node-name xml)) ?>)))) 1074 (insert ?< ?/ (symbol-name (xml-node-name xml)) ?>))))
1075 1075
1076;;;###autoload
1077(defun xml-remove-comments (beg end)
1078 "Remove XML/HTML comments in the region between BEG and END.
1079All text between the <!-- ... --> markers will be removed."
1080 (save-excursion
1081 (save-restriction
1082 (narrow-to-region beg end)
1083 (goto-char beg)
1084 (while (search-forward "<!--" nil t)
1085 (let ((start (match-beginning 0)))
1086 (when (search-forward "-->" nil t)
1087 (delete-region start (point))))))))
1088
1076(provide 'xml) 1089(provide 'xml)
1077 1090
1078;;; xml.el ends here 1091;;; xml.el ends here
diff --git a/src/xml.c b/src/xml.c
index 42059d77131..fa88040597d 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -271,7 +271,12 @@ DEFUN ("libxml-parse-html-region", Flibxml_parse_html_region,
271 2, 4, 0, 271 2, 4, 0,
272 doc: /* Parse the region as an HTML document and return the parse tree. 272 doc: /* Parse the region as an HTML document and return the parse tree.
273If BASE-URL is non-nil, it is used to expand relative URLs. 273If BASE-URL is non-nil, it is used to expand relative URLs.
274If DISCARD-COMMENTS is non-nil, all HTML comments are discarded. */) 274
275If DISCARD-COMMENTS is non-nil, the top-level HTML comment is discarded.
276
277This parameter is obsolete as of 27.1, and you should use the
278`xml-remove-comments' function to strip comments before calling
279this function if you don't want comments. */)
275 (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, Lisp_Object discard_comments) 280 (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, Lisp_Object discard_comments)
276{ 281{
277 if (init_libxml2_functions ()) 282 if (init_libxml2_functions ())
@@ -284,7 +289,12 @@ DEFUN ("libxml-parse-xml-region", Flibxml_parse_xml_region,
284 2, 4, 0, 289 2, 4, 0,
285 doc: /* Parse the region as an XML document and return the parse tree. 290 doc: /* Parse the region as an XML document and return the parse tree.
286If BASE-URL is non-nil, it is used to expand relative URLs. 291If BASE-URL is non-nil, it is used to expand relative URLs.
287If DISCARD-COMMENTS is non-nil, all HTML comments are discarded. */) 292
293If DISCARD-COMMENTS is non-nil, the top-level XML comment is discarded.
294
295This parameter is obsolete as of 27.1, and you should use the
296`xml-remove-comments' function to strip comments before calling
297this function if you don't want comments. */)
288 (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, Lisp_Object discard_comments) 298 (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, Lisp_Object discard_comments)
289{ 299{
290 if (init_libxml2_functions ()) 300 if (init_libxml2_functions ())