~brettgilio/org-webring

Replace seq-map + append with mapcan v1 APPLIED

Ivan Sokolov: 1
 Replace seq-map + append with mapcan

 1 files changed, 16 insertions(+), 19 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~brettgilio/org-webring/patches/12046/mbox | git am -3
Learn more about email & git

[PATCH] Replace seq-map + append with mapcan Export this patch

---
 org-webring.el | 35 ++++++++++++++++-------------------
 1 file changed, 16 insertions(+), 19 deletions(-)

diff --git a/org-webring.el b/org-webring.el
index 396c8f7..083eff5 100644
--- a/org-webring.el
+++ b/org-webring.el
@@ -135,24 +135,21 @@ XML node."
		(url-insert-file-contents link)
		(xml-parse-region)))))

(defun org-webring--get-items-from-urls (urls)
  "Create a list of all the items contained in the URLS list of
RSS feed links."
  (apply 'append
	 (seq-map
	  (lambda (url)
	    (let* ((feed (org-webring--feed-parse url))
		   (source-link (org-webring--feed-text-prop feed 'link))
		   (source-title (org-webring--feed-text-prop feed 'title)))
	      (seq-map (lambda (item)
			 (append
			  '(item nil)
			  `((sourceLink nil ,source-link)
			    (sourceTitle nil ,source-title))
			  (xml-node-children item)))
		       (seq-take (org-webring--feed-items feed)
				 org-webring-items-per-source))))
	  urls)))
(defun org-webring--get-items-from-url (url)
  "Create a list of items container in the RSS feed at URL.
Produces at most `org-webring-items-per-source'."
  (let* ((feed (org-webring--feed-parse url))
         (source-link (org-webring--feed-text-prop feed 'link))
         (source-title (org-webring--feed-text-prop feed 'title)))
    (seq-map (lambda (item)
               `(item                   ; tag
                 nil                    ; class
                 ;; chilren
                 (sourceLink nil ,source-link)
                 (sourceTitle nil ,source-title)
                 ,@(xml-node-children item)))
             (seq-take (org-webring--feed-items feed)
                       org-webring-items-per-source))))

(defun org-webring--string-truncate (len s elipsis)
  "If S is longer than LEN, cut it down and add ELIPSIS at the
@@ -200,7 +197,7 @@ end. Taken from the s.el library."

(defun org-webring-generate-webring ()
  "Generate the entire webring and return it as HTML."
  (let* ((items (org-webring--get-items-from-urls org-webring-urls))
  (let* ((items (mapcan #'org-webring--get-items-from-url org-webring-urls))
         (sorted-items (cl-sort items #'time-less-p :key #'org-webring--pub-time))
         (most-recent (reverse (last sorted-items org-webring-items-total)))
         (articles (mapcar #'org-webring--article-instance most-recent)))
-- 
2.28.0