2017-06-08 11:47:56 +02:00
|
|
|
;;; app/rss/autoload.el -*- lexical-binding: t; -*-
|
2017-03-06 22:01:37 -05:00
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun =rss ()
|
|
|
|
"Activate (or switch to) `elfeed' in its workspace."
|
|
|
|
(interactive)
|
2017-04-08 01:31:09 -04:00
|
|
|
(call-interactively 'elfeed))
|
2017-03-06 22:01:37 -05:00
|
|
|
|
2017-04-10 15:54:40 -04:00
|
|
|
;;;###autoload
|
|
|
|
(defun +rss/quit ()
|
|
|
|
(interactive)
|
|
|
|
(doom-kill-matching-buffers "^\\*elfeed")
|
|
|
|
(dolist (file +rss-elfeed-files)
|
|
|
|
(when-let (buf (get-file-buffer (expand-file-name file +rss-org-dir)))
|
|
|
|
(kill-buffer buf))))
|
|
|
|
|
2017-03-06 22:01:37 -05:00
|
|
|
;;;###autoload
|
|
|
|
(defun +rss|elfeed-wrap ()
|
|
|
|
"Enhances an elfeed entry's readability by wrapping it to a width of
|
|
|
|
`fill-column' and centering it with `visual-fill-column-mode'."
|
|
|
|
(let ((inhibit-read-only t)
|
|
|
|
(inhibit-modification-hooks t))
|
|
|
|
(setq-local truncate-lines nil)
|
|
|
|
(setq-local shr-width 85)
|
|
|
|
(set-buffer-modified-p nil)))
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun +rss/delete-pane ()
|
|
|
|
"Delete the *elfeed-entry* split pane."
|
|
|
|
(interactive)
|
|
|
|
(let* ((buff (get-buffer "*elfeed-entry*"))
|
|
|
|
(window (get-buffer-window buff)))
|
|
|
|
(kill-buffer buff)
|
|
|
|
(delete-window window)))
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun +rss-popup-pane (buf)
|
|
|
|
"Display BUF in a popup."
|
|
|
|
(doom-popup-buffer buf
|
|
|
|
:align +rss-split-direction
|
|
|
|
:size 0.75
|
|
|
|
:select t
|
2017-05-14 10:12:41 +02:00
|
|
|
:autokill t
|
|
|
|
:autoclose t))
|
2017-03-06 22:01:37 -05:00
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun +rss/open (entry)
|
|
|
|
"Display the currently selected item in a buffer."
|
|
|
|
(interactive (list (elfeed-search-selected :ignore-region)))
|
|
|
|
(when (elfeed-entry-p entry)
|
|
|
|
(elfeed-untag entry 'unread)
|
|
|
|
(elfeed-search-update-entry entry)
|
|
|
|
(elfeed-show-entry entry)))
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun +rss/next ()
|
|
|
|
"Show the next item in the elfeed-search buffer."
|
|
|
|
(interactive)
|
|
|
|
(funcall elfeed-show-entry-delete)
|
|
|
|
(with-current-buffer (elfeed-search-buffer)
|
|
|
|
(forward-line)
|
|
|
|
(call-interactively '+rss/open)))
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun +rss/previous ()
|
|
|
|
"Show the previous item in the elfeed-search buffer."
|
|
|
|
(interactive)
|
|
|
|
(funcall elfeed-show-entry-delete)
|
|
|
|
(with-current-buffer (elfeed-search-buffer)
|
|
|
|
(forward-line -1)
|
|
|
|
(call-interactively '+rss/open)))
|
2017-04-05 15:05:40 -04:00
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun +rss-dead-feeds (&optional years)
|
|
|
|
"Return a list of feeds that haven't posted anything in YEARS."
|
|
|
|
(let* ((years (or years 1.0))
|
|
|
|
(living-feeds (make-hash-table :test 'equal))
|
|
|
|
(seconds (* years 365.0 24 60 60))
|
|
|
|
(threshold (- (float-time) seconds)))
|
|
|
|
(with-elfeed-db-visit (entry feed)
|
|
|
|
(let ((date (elfeed-entry-date entry)))
|
|
|
|
(when (> date threshold)
|
|
|
|
(setf (gethash (elfeed-feed-url feed) living-feeds) t))))
|
|
|
|
(cl-loop for url in (elfeed-feed-list)
|
|
|
|
unless (gethash url living-feeds)
|
|
|
|
collect url)))
|