~brettgilio/org-webring

8e1308dc8bee0e89f66b15967d0da7ca23c01f1d — Ivan Sokolov 15 days ago 763fb22
Deprecate org-webring--detect-duplicates, use seq-uniq.

* Remove org-webring--detect-duplicates.
* Unwrap org-webring-generate-webring, and use let-form to return
unique entries in list.
3 files changed, 30 insertions(+), 47 deletions(-)

M README.md
M README.org
M org-webring.el
M README.md => README.md +1 -2
@@ 135,8 135,7 @@ set for the header.

### **Function**: org-webring-generate-webring

When `org-webring--detect-duplicates` passes, generate the
entire webring and return it as HTML.
Generate the entire webring and return it as HTML.


### **Function**: org-webring-copy-css *&optional target-dir*

M README.org => README.org +1 -2
@@ 94,8 94,7 @@ set for the header.
- Default Value: ~t~

*** *Function*: org-webring-generate-webring
When ~org-webring--detect-duplicates~ passes, generate the
entire webring and return it as HTML.
Generate the entire webring and return it as HTML.

*** *Function*: org-webring-copy-css /&optional target-dir/
Interactive function which prompts for a location to copy

M org-webring.el => org-webring.el +28 -43
@@ 266,20 266,6 @@ was introduced in Emacs 27) isn't available."
	 (org-webring--feed-text-prop item 'updated))
     atom-p)))

(defun org-webring--detect-duplicates (&optional test)
  "Check `org-webring-urls' for the existence of duplicate
entries. Return ERROR when value is non-NIL."
  (let ((ht (make-hash-table
	     :test (or test #'equal))) ret)
    (dolist (x org-webring-urls)
      (incf (gethash x ht 0)))
    (maphash (lambda (key value)
               (when (> value 1)
		 (error "`org-webring-urls' contains a duplicate entry: %s"
			(push key ret))))
             ht)
    ret))

(defun org-webring--article-instance (item)
  "Generate the structure of a feed article from a given ITEM."
  (let ((desc-sanitized


@@ 313,35 299,34 @@ entries. Return ERROR when value is non-NIL."
					    "GMT"))))))

(defun org-webring-generate-webring ()
  "When `org-webring--detect-duplicates' passes, generate the
entire webring and return it as HTML."
  (unless (org-webring--detect-duplicates)
    (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)))
      (xmlgen
       `(section :class "org-webring"
		 ,(when org-webring-display-header
		    `(h4 ,(print org-webring-header)))
		 (section :class "org-webring-articles" ,@articles)
		 (p :class "org-webring-attribution"
		    ,@(when org-webring-display-generation-time
			(list
			 `(span :class "org-webring-timestamp"
				,(format-time-string
				  org-webring-timestamp-generate-format))
			 `(br)))
		    ,@(when org-webring-display-attribution
			(list
			 (print "Generated with ")
			 `(a :href ,org-webring-attribution-link
			     :target "_blank"
			     ,org-webring-attribution-name)
			 (when org-webring-display-version
			   (print (concat " -- v"
					  org-webring-version)))))))))))
  "Generate the entire webring and return it as HTML."
  (let* ((unique-urls (seq-uniq org-webring-urls))
         (items (mapcan #'org-webring--get-items-from-url unique-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)))
    (xmlgen
     `(section :class "org-webring"
	       ,(when org-webring-display-header
		  `(h4 ,(print org-webring-header)))
	       (section :class "org-webring-articles" ,@articles)
	       (p :class "org-webring-attribution"
		  ,@(when org-webring-display-generation-time
		      (list
		       `(span :class "org-webring-timestamp"
			      ,(format-time-string
				org-webring-timestamp-generate-format))
		       `(br)))
		  ,@(when org-webring-display-attribution
		      (list
		       (print "Generated with ")
		       `(a :href ,org-webring-attribution-link
			   :target "_blank"
			   ,org-webring-attribution-name)
		       (when org-webring-display-version
			 (print (concat " -- v"
					org-webring-version))))))))))

(defun org-webring-copy-css (&optional target-dir)
  "Interactive function which prompts for a location to