dotfiles/.config/emacs/modules/app/earnemod-elfeed.el

85 lines
2.6 KiB
EmacsLisp
Raw Normal View History

;;; earnemod-elfeed.el --- -*- lexical-binding: t; -*-
;; Copyright (C) 2020-2021 earnest ma
;; SPDX-License-Identifier: MIT
;; Author: earnest ma <me@earne.link>
;;; Code:
(use-package elfeed
:bind (:map elfeed-search-mode-map
("q" . bjm/elfeed-save-db-and-bury)
("w" . (lambda () (interactive) (elfeed-db-save)))
("m" . elfeed-toggle-star)
("b" . mz/elfeed-browse-url)
("B" . elfeed-search-browse-url))
:general
(earnemacs-spc-def "or" 'bjm/elfeed-load-db-and-open)
:hook
(elfeed-show-mode . visual-line-mode)
(elfeed-show-mode . olivetti-mode)
:config
;; Set the default state to Emacs
(evil-set-initial-state 'elfeed-search-mode 'emacs)
(evil-set-initial-state 'elfeed-show-mode 'emacs)
(defun elfeed-mark-all-as-read ()
"Mark the whole buffer as read."
(interactive)
(mark-whole-buffer)
(elfeed-search-untag-all-unread))
(defun bjm/elfeed-load-db-and-open ()
"Wrapper to load the elfeed db from disk before opening"
(interactive)
(elfeed-protocol-enable)
(elfeed-db-load)
(elfeed)
(elfeed-goodies/setup)
(elfeed-search-update--force))
(defun bjm/elfeed-save-db-and-bury ()
"Wrapper to save the elfeed db to disk before burying buffer"
(interactive)
(elfeed-db-save)
(quit-window))
;; Browse the URL at point without marking as read
;; https://github.com/zamansky/dot-emacs/blob/master/README.org
(defun mz/elfeed-browse-url (&optional use-generic-p)
"Visit the current entry in your browser using `browse-url'.
If there is a prefix argument, visit the current entry in the
browser defined by `browse-url-generic-program'."
(interactive "P")
(let ((entries (elfeed-search-selected)))
(cl-loop for entry in entries
do (if use-generic-p
(browse-url-generic (elfeed-entry-link entry))
(browse-url (elfeed-entry-link entry))))
(mapc #'elfeed-search-update-entry entries)
(unless (or elfeed-search-remain-on-entry (use-region-p)))))
;; Take advantage of curl if it is available
(if (executable-find "curl")
(setq
elfeed-use-curl t
elfeed-curl-max-connections 10))
;; Set the default search filter (space for convenience)
(setq-default elfeed-search-filter "@3-months-ago +unread "))
(use-package elfeed-protocol
:demand
:after elfeed)
(use-package elfeed-goodies
:demand
:after elfeed
:config
;; Make the feed source column width longer
(setq elfeed-goodies/feed-source-column-width 26))
(provide 'earnemod-elfeed)
;;; earnemod-elfeed.el ends here