94 lines
3.2 KiB
EmacsLisp
94 lines
3.2 KiB
EmacsLisp
;;; myfeed.el --- My RSS reader -*- lexical-binding: t; -*-
|
|
|
|
;; Author: iamtoaster
|
|
;; Version: 0.0.0
|
|
;; Package-Requires: ()
|
|
;; Homepage:
|
|
;; Keywords: rss, url
|
|
|
|
;; This file is not part of GNU Emacs
|
|
|
|
;; This program is free software: you can redistribute it and/or modify
|
|
;; it under the terms of the GNU General Public License as published by
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
;; (at your option) any later version.
|
|
|
|
;; This program is distributed in the hope that it will be useful,
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
;; GNU General Public License for more details.
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
;;; Commentary:
|
|
|
|
;; An RSS feed reader inspired by elfeed. Very early WIP.
|
|
|
|
;;; Code:
|
|
|
|
(defvar myreader-feeds '()
|
|
"Alist of the form (NAME . LINK) of RSS feeds.")
|
|
|
|
(defvar myreader--feed-buffers '()
|
|
"Alist of buffers in which the asynchronously retrieved pages are
|
|
written.")
|
|
|
|
(defvar myreader--feed-cache '()
|
|
"A list of retrieved entries.")
|
|
|
|
;; (defun myreader--eww-render-buffer ()
|
|
;; "Render the current buffer in EWW."
|
|
;; (interactive)
|
|
;; (let* ((html (buffer-substring-no-properties (point-min) (point-max)))
|
|
;; (source (buffer-name))
|
|
;; (buf (generate-new-buffer (concat "RSS: " source))))
|
|
;; (with-current-buffer buf
|
|
;; (insert html)
|
|
;; (goto-char (point-min))
|
|
;; (eww-display-html 'utf-8 source nil nil buf))
|
|
;; (switch-to-buffer buf)))
|
|
|
|
(defun myreader--render-entry ()
|
|
(with-current-buffer retr-buf
|
|
(message "%s" (buffer-substring (point-min) (point-max)))))
|
|
|
|
(defun myreader--update-feed (name)
|
|
(let ((buf (alist-get name myreader--feed-buffers)))
|
|
;; TODO figure out a good way to put the thing in cache and then use it
|
|
(message "Feed %s; Parsed %s" name (libxml-parse-html-region (point)))))
|
|
|
|
(setq myreader-feeds '((scour . "https://scour.ing/@DiToast/rss.xml")))
|
|
|
|
(defun myreader-update-feeds (&optional force)
|
|
"Goes through all the feeds defined in `myreader-feeds' and updates them
|
|
if necessary. If FORCE is non-nil, updates them unconditionally."
|
|
(dolist (entry myreader-feeds)
|
|
(let ((name (car entry))
|
|
(link (cdr entry)))
|
|
(let ((cache-entry (alist-get name myreader--feed-cache)))
|
|
;; TODO check if entry exists in cache -> check if ttl expired
|
|
;; (if (and cache-entry (alist-get ))
|
|
;; TODO if updating async retrieve the LINK through myreader--feed-buffers
|
|
(setq myreader--feed-buffers
|
|
(cons
|
|
(cons
|
|
name
|
|
(url-retrieve link (lambda (&rest keys) (myreader--update-feed name))))
|
|
myreader--feed-buffers))))))
|
|
|
|
(defun myreader-revert-item-buffer ()
|
|
"Reverts the buffer containing the list of RSS entry items from
|
|
`myreader--feed-cache'."
|
|
(interactive)
|
|
;; TODO go through cache -> check ttl -> update feed if necessary
|
|
;; TODO add the items to the tabulated list
|
|
())
|
|
|
|
;; (setq retr-buf (url-retrieve "https://scour.ing/@DiToast/rss.xml"
|
|
;; (lambda (&rest keys) (render-buff))))
|
|
|
|
(provide 'myfeed)
|
|
|
|
;;; myfeed.el ends here
|