emacs-opml-to-elfeed-feeds

A package for retrieving OPML files and updating Elfeed's elfeed-feeds with the feeds of those OPMLs.
git clone https://kaka.farm/~git/emacs-opml-to-elfeed-feeds/
Log | Files | Refs | README | LICENSE

commit b33df30566180c9e04bc6ae1bafa445e15afc8f6
parent c651b6b0061995e1acbfc0c253f63813a9baa46d
Author: Yuval Langer <yuval.langer@gmail.com>
Date:   Sat, 29 Jun 2024 23:32:31 +0300

Use (pcase (assq 'outline outlines) ...) instead of a cond.

Diffstat:
Mopml-to-elfeed-feeds.el | 69++++++++++++++++++++++++++++++++++-----------------------------------
1 file changed, 34 insertions(+), 35 deletions(-)

diff --git a/opml-to-elfeed-feeds.el b/opml-to-elfeed-feeds.el @@ -120,40 +120,40 @@ The optional named arguments: (outlines (o2e--xml-to-opml-outlines xml))) (named-let loop ((outlines outlines) (accumulator '())) - (cond - ((null outlines) - accumulator) - ((and (consp (car outlines)) - (eq (caar outlines) - 'outline)) - (let* ((outline-values (cadar outlines)) - (rest-of-outlines (cdr outlines)) - ;; XXX: In Craftering OPML uses to represent the name - ;; of the author. - (text (cdr (assq 'text - outline-values))) - (xml-url (cdr (assq 'xmlUrl - outline-values))) - (all-tags (elfeed-normalize-tags - ;; If user provided a "text" munging - ;; function, use it to create a tag. - (when text-element-value-to-tag - (list (funcall text-element-value-to-tag - text))) - tags)) - (elfeed-feed-entry (append (list xml-url) - all-tags))) - (cond - ((string-empty-p xml-url) - (loop rest-of-outlines - accumulator)) - (t - (loop rest-of-outlines - (cons elfeed-feed-entry - accumulator)))))) - ((stringp (car outlines)) - (loop (cdr outlines) - accumulator)))))) + (pcase (assq 'outline outlines) + ('() + accumulator) + (`(outline . (,outline-values)) + (let* (;; XXX: In Craftering OPML uses to represent the name + ;; of the author. + (text (cdr (assq 'text outline-values))) + (xml-url (cdr (assq 'xmlUrl outline-values))) + (all-tags (elfeed-normalize-tags + ;; If user provided a "text" munging + ;; function, use it to create a tag. + (when (and text-element-value-to-tag text) + (list (funcall text-element-value-to-tag + text))) + tags)) + (elfeed-feed-entry (append (list xml-url) + all-tags))) + (cond + ((string-empty-p xml-url) + (loop (cdr outlines) + accumulator)) + (t + (loop (cdr outlines) + (cons elfeed-feed-entry + accumulator)))))) + ;; XXX: I've only added this clause because when using + ;; xml-parse-region it would return big chunks of whitespaces + ;; between the outlines when parsing the Debian planet OPML. + ;; Let's see if it still works without it? + ;; + ;; ((pred (lambda (x) (stringp (car x)))) + ;; (loop (cdr outlines) + ;; accumulator)) + )))) (defun o2e--elfeed-feeds-entry-url (elfeed-feeds-entry) "Return the URL of ELFEED-FEEDS-ENTRY. @@ -262,7 +262,6 @@ ordered according to the optional named argument ORDP." (o2e--response-buffer-to-elfeed-feed response-buffer :tags tags))) o2e-opml-list)))) - (message "%S" new-elfeed-feeds) (customize-save-variable 'o2e-elfeed-feeds (o2e--normalise-elfeed-feeds (append new-elfeed-feeds