commit a6fc6025a960ee9d98f49e05a0409e20204b0c95
parent 0fc05d4c99b46499d875918dff70f193d72e6511
Author: Yuval Langer <yuval.langer@gmail.com>
Date: Sun, 5 Nov 2023 01:28:52 +0200
Add some docstrings. Also, elfeed-nitter-update-random-instances works as expected.
Diffstat:
M | elfeed-nitter.el | | | 134 | +++++++++++++++++++++++++++++++++++++++++++++++++------------------------------ |
1 file changed, 83 insertions(+), 51 deletions(-)
diff --git a/elfeed-nitter.el b/elfeed-nitter.el
@@ -32,25 +32,35 @@
;;; Code:
-(require 'dash)
(require 'cl-lib)
+(require 'dash)
+(require 'elfeed)
-(defcustom en-tags
+(defcustom en-default-tags
'(elfeed-nitter)
- "Tags added by default to the elfeed-nitter entries.")
+ "Tags added by default to the elfeed-nitter entries."
+ :group 'elfeed-nitter
+ :type (repeat 'symbol))
-(defcustom en-domains
+(defcustom en-hosts
'("nitter.net")
- "Nitter instance domains used in making the elfeed-nitter entries.")
-
-(defcustom en-paths
- '(("emacs/rss" without_replies)
- ("emacs/with_replies/rss" with_replies))
- "Wanted Nitter feeds.")
+ "Nitter instance domains used in making the elfeed-nitter entries."
+ :group 'elfeed-nitter
+ :type (repeat 'string))
+
+(defcustom en-paths-and-tags
+ '(("/emacs/rss" without_replies)
+ ("/emacs/with_replies/rss" with_replies))
+ "Wanted Nitter feeds."
+ :group 'elfeed-nitter
+ :type (repeat (cons 'string
+ (repeat 'symbol))))
(defcustom en-wiki-url
"https://github.com/zedeus/nitter.wiki.git"
- "The URL of the wiki. For git clone-ing purposes.")
+ "The URL of the wiki. For git clone-ing purposes."
+ :group 'elfeed-nitter
+ :type 'string)
(defvar en-path
(locate-user-emacs-file "elfeed-nitter/"))
@@ -65,47 +75,70 @@
(defun en-make-random-feeds-alist ()
(cl-loop
- for entry in en-paths
+ with hosts-list =
+ (en-make-instances-hosts-list)
+
+ for entry in en-paths-and-tags
+
+ for host =
+ (nth (random (length hosts-list))
+ hosts-list)
+
+ for url =
+ (concat "https://"
+ host
+ (car entry))
+
+ for host-tag =
+ (intern (string-replace "."
+ "-"
+ host))
+
+ for rest-of-the-tags =
+ (cdr entry)
+
collect
- (let* ((nitter-domain (nth (random (length en-domains))
- en-domains))
- (url (concat "https://"
- nitter-domain
- "/"
- (car entry)))
- (nitter-domain-tag (intern (string-replace "."
- "-"
- nitter-domain)))
- (rest-of-the-tags (cdr entry)))
- (append (list url
- nitter-domain-tag)
- en-tags
- rest-of-the-tags))))
+ (append (list url
+ host-tag)
+ en-default-tags
+ rest-of-the-tags)))
(defun en-make-feeds-alist ()
- (apply 'append
- (cl-loop
- for nitter-domain in en-domains
- collect
- (cl-loop
- for entry in en-paths
- collect
- (let ((url (concat "https://"
- nitter-domain
- "/"
- (car entry)))
- (nitter-domain-tag (intern (string-replace "."
- "-"
- nitter-domain)))
- (rest-of-the-tags (cdr entry)))
- (append (list url
- nitter-domain-tag)
- en-tags
- rest-of-the-tags))))))
+ (cl-loop
+ for host in en-hosts
+
+ collect
+ (cl-loop
+ for entry in en-paths-and-tags
+
+ for url =
+ (concat "https://"
+ host
+ "/"
+ (car entry))
+
+ for host-tag =
+ (intern (string-replace "."
+ "-"
+ host))
+
+ for rest-of-the-tags =
+ (cdr entry)
+
+ append
+ (append (list url
+ host-tag)
+ en-default-tags
+ rest-of-the-tags))))
(defun en-update-random-instances ()
- (let* ((elfeed-feeds (en-make-random-feeds-alist)))
- (elfeed-update)))
+ (let (_)
+ (defvar elfeed-feeds)
+ (message (pp-to-string elfeed-feeds))
+ (let* ((elfeed-feeds (en-make-random-feeds-alist)))
+ (message (pp-to-string elfeed-feeds))
+ (elfeed-update))
+ (message (pp-to-string elfeed-feeds))))
(defun en--clone-nitter-wiki ()
(ignore-error 'file-already-exists
@@ -117,9 +150,9 @@
(defun en--update-nitter-wiki ()
(ignore-error 'file-already-exists
(make-directory en-path))
+ (defvar default-directory)
(let ((default-directory en-wiki-path))
- (shell-command-to-string (format "git pull --ff-only %s"
- en-wiki-url))))
+ (shell-command-to-string "git pull --ff-only")))
(defun en-make-instances-hosts-list ()
(cl-loop
@@ -149,8 +182,7 @@
url-generic-parse-url
url-host
;; XXX: Will this sanitise the URL thingimajig?
- url-hexify-string
- )))
+ url-hexify-string)))
(provide 'elfeed-nitter)