Function: nnatom--read-feed

nnatom--read-feed is a byte-compiled function defined in nnatom.el.gz.

Signature

(nnatom--read-feed FEED _)

Documentation

Return a list structure representing FEED, or nil.

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/nnatom.el.gz
(defun nnatom--read-feed (feed _)
  "Return a list structure representing FEED, or nil."
  (if (string-match-p "\\`https?://" feed)
      (nnheader-report
       nnatom-backend
       "Address shouldn't start with \"http://\" or \"https://\"")
    (with-temp-buffer
      (condition-case e
          (if (file-name-absolute-p feed)
              (insert-file-contents feed)
            (mm-url-insert-file-contents (concat "https://" feed)))
        (file-error (nnheader-report nnatom-backend (cdr e)))
        (:success (when-let* ((data (if (libxml-available-p)
                                        (libxml-parse-xml-region
                                         (point-min) (point-max))
                                      (car (xml-parse-region
                                            (point-min) (point-max)))))
                              (authors (list 'authors)))
                    (when (eq (car data) 'top)
                      (setq data (assq 'feed data)))
                    (dom-add-child-before data authors)
                    (let ((all (dom-children data)))
                      (while-let ((rest (cdr all))
                                  (child (car-safe rest))
                                  (type (car-safe child))
                                  ((not (eq type 'entry))))
                        (and (or (eq type 'author)
                                 (eq type 'contributor))
                             (dom-add-child-before authors child))
                        (setq all rest))
                      ;; Order of entries is reversed as most Atom feeds
                      ;; list only the "most recent" entries, in reverse
                      ;; chronological order.
                      (setcdr all (nreverse (cdr all))))
                    data))))))