summary refs log tree commit diff
path: root/emacs/custom/my-elfeed.el
blob: 92eacea4300e1c5dc5c59a204ebbc87777c2071c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
;;; my-elfeed.el --- Configure elfeed -*- lexical-binding: t -*-

;;; Commentary:

;;; Code:

(require 'elfeed)
(require 'elfeed-org)

(with-eval-after-load 'elfeed-search
  '(define-key elfeed-search-mode-map (kbd "*") 'elfeed-toggle-star))

(add-hook 'after-init-hook 'elfeed-org)

(customize-set-variable 'elfeed-search-filter "@4-months-ago +unread")
(customize-set-variable 'rmh-elfeed-org-files (list (expand-file-name "etc/elfeed.org" user-emacs-directory)))

(defalias 'elfeed-toggle-star
  (elfeed-expose #'elfeed-search-toggle-all 'star))

;; set colors for some specific tags
(defface elfeed-face-tag-mustread
  '((t :foreground "#f00"))
  "This is a custom font face for the `mustread' tag in Elfeed."
  :group 'elfeed)

(with-eval-after-load 'elfeed
  (setq elfeed-search-face-alist
        '((mustread elfeed-face-tag-mustread)
          (unread elfeed-search-unread-title-face))))

(defun my/elfeed-show-visit-eww ()
  "Visit the current entry in eww."
  (interactive)
  (let ((link (elfeed-entry-link elfeed-show-entry)))
    (when link
      (eww link))))

;; disable proportional fonts when displaying HTML content.
(advice-add #'elfeed-insert-html
              :around
              (lambda (fun &rest r)
                (let ((shr-use-fonts nil))
                  (apply fun r))))

;; (defun copy-elfeed-link-title-to-org (entry)
;;   "Copy the ENTRY title and URL as org link to the clipboard."
;;   (interactive)
;;   (let* ((link (elfeed-entry-link entry))
;;          (title (elfeed-entry-title entry))
;;          (titlelink (concat "[[" link "][" title "]]")))
;;     (when titlelink
;;       (kill-new titlelink)
;;       (x-set-selection 'PRIMARY titlelink)
;;       (message "Yanked: %s" titlelink))))

;; (defun elfeed-show-quick-url-note ()
;;   "Fastest way to capture entry link to org agenda from elfeed show mode"
;;   (interactive)
;;   (copy-elfeed-link-title-to-org elfeed-show-entry)
;;   (org-capture nil "n")
;;   (yank)
;;   (org-capture-finalize))

;; (defun elfeed-search-quick-url-note ()
;;   "In search mode, capture the title and link for the selected
;; entry or entries in org aganda."
;;   (interactive)
;;   (let ((entries (elfeed-search-selected)))
;;     (cl-loop for entry in entries
;;              do (elfeed-untag entry 'unread)
;;              when (elfeed-entry-link entry)
;;              do (copy-elfeed-link-title-to-org entry)
;;              do (org-capture nil "f")
;;              do (yank)
;;              do (org-capture-finalize)
;;              (mapc #'elfeed-search-update-entry entries))
;;     (unless (use-region-p) (forward-line))))


;; (defun my/elfeed-eww-open (&optional use-generic-p)
;;   "open with eww"
;;   (interactive "P")
;;   (let ((entries (elfeed-search-selected)))
;;     (cl-loop for entry in entries
;;              do (elfeed-untag entry 'unread)
;;              when (elfeed-entry-link entry)
;;              do (eww-browse-url it))
;;     (mapc #'elfeed-search-update-entry entries)
;;     (unless (use-region-p) (forward-line))))


;; (defun my/yt-dlp-it (url)
;;   "Downloads the URL in an async shell."
;;   (let ((default-directory "~/media/videos"))
;;     (async-shell-command (format "yt-dlp %s" (shell-quote-argument url)))))

;; (defun my/elfeed-youtube-dl (&optional use-generic-p)
;;   "Youtube-DL link."
;;   (interactive "P")
;;   (let ((entries (elfeed-search-selected)))
;;     (cl-loop for entry in entries
;;              do (elfeed-untag entry 'unread)
;;              when (elfeed-entry-link entry)
;;              do (my/yt-dlp-it it))
;;     (mapc #'elfeed-search-update-entry entries)
;;     (unless (use-region-p) (forward-line))))

(provide 'my-elfeed)

;;; my-elfeed.el ends here