]> gitweb.fperrin.net Git - atom.el.git/blobdiff - atom.el
Stop requiring 'cl
[atom.el.git] / atom.el
diff --git a/atom.el b/atom.el
index d19bb3c82edc1e5cc06b0b957fff662f54ca42fd..d57334794612fa7484d291df97902cf5570a4ce7 100644 (file)
--- a/atom.el
+++ b/atom.el
@@ -1,4 +1,4 @@
-;;; atom.el --- Create an Atom feed
+;;; atom.el --- Create an Atom feed  -*- lexical-binding: t -*-
 
 ;; Copyright (C) 2011  Frédéric Perrin
 
@@ -47,7 +47,7 @@
 ;;
 ;;   (atom-print my-atom-feed)
 ;;   ;; If you prefer RSS feeds:
-;;   (atom-to-rss-print my-atom-feed))
+;;   (atom-print-as-rss my-atom-feed))
 
 ;; Full documentation is available at <http://tar-jx.bz/code/atom.html>.
 
@@ -55,7 +55,6 @@
 
 (require 'xml)
 (require 'url-parse)
-(require 'cl) ; for setf in url-canonalize
 
 (defun atom-create (title link &optional subtitle self id author updated)
   "Create a new atom structure.
@@ -123,7 +122,7 @@ probably not a very good default.
 ID defaults to LINK, which is not optimal; see `atom-generate-id'
 for a way to create good identifiers. For a given entry, it must
 not change between successive generations of the atom feed, even
-when the content of the entry ."
+when the content of the entry changes."
   (let ((entry (list (list 'title nil title))))
     (atom-modify-entry entry 'link  (list (list (cons 'href link))))
     (atom-modify-entry entry 'id (or id link))
@@ -172,7 +171,7 @@ are no longer relative to LINK."
   "Writes the feed ATOM to FILENAME."
   (with-temp-buffer
     (atom-print atom)
-    (write-region (point-min) (point-max) filename)))
+    (write-file filename)))
 
 \f
 (defun atom-to-rss (atom)
@@ -246,7 +245,7 @@ format used by RSS."
   "Saves ATOM as a RSS feed into FILENAME."
   (with-temp-buffer
     (atom-print-as-rss atom)
-    (write-region nil nil filename)))
+    (write-file filename)))
 
 \f
 (defvar atom-time-format-string "%Y-%m-%dT%T%z"
@@ -276,14 +275,17 @@ Atom feed. CONTENT must be a string."
 
 (defun atom-string-to-xml (string)
   "Convert STRING into a Lisp structure as used by `xml.el'."
-  (with-temp-buffer
-    (insert "<div xmlns=\"" atom-xhtml-namespace "\">")
-    (insert string)
-    (insert "</div>")
-    ;; `xml-parse-region' doesn't require that the XML parsed be enclosed in a
-    ;; root node, and accordingly, returns a list of elements. We are only
-    ;; interested in the first one, the DIV we just inserted.
-    (car (xml-parse-region (point-min) (point-max)))))
+  (require 'xml-xhtml-entities)
+  (let ((xml-entity-alist xml-xhtml-entities)
+       (xml-validating-parser t))
+    (with-temp-buffer
+      (insert "<div xmlns=\"" atom-xhtml-namespace "\">")
+      (insert string)
+      (insert "</div>")
+      ;; `xml-parse-region' returns a list of elements, even though it
+      ;; requires an only root node. We are only interested in the first
+      ;; one, the DIV we just inserted.
+      (car (xml-parse-region (point-min) (point-max))))))
 
 (defun atom-massage-xhtml (content)
   "Massage CONTENT so it can be used as an XHTML fragment in an