RSS
阅读 RSS 使用的是 elfeed,下面两个插件搭配起来使用,体验会更流程:
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
| (use-package elfeed
:custom ((elfeed-use-curl t)
(elfeed-db-directory "~/Downloads/elfeed/")
(elfeed-curl-timeout 20)
(elfeed-curl-extra-arguments `("-x" ,socks-proxy)))
:bind (:map elfeed-show-mode-map
("8" . my/elfeed-toggle-star)
("9" . my/elfeed-show-images)
("g" . elfeed-show-refresh)
:map elfeed-search-mode-map
("SPC" . scroll-up-command)
("DEL" . scroll-down-command)
("f" . my/elfeed-search-by-title)
("b" . my/elfeed-browse)
("8" . my/elfeed-toggle-star))
:init
(progn
(defun my/elfeed-browse ()
(interactive)
(let ((entries (elfeed-search-selected)))
(elfeed-untag entries 'unread)
(mapc #'elfeed-search-update-entry entries))
(elfeed-search-browse-url))
(defun my/elfeed-add-title-tag (entry)
(when-let* ((feed (elfeed-entry-feed entry))
(title (cl-destructuring-bind (&key title &allow-other-keys)
(elfeed-feed-meta feed)
title)))
(elfeed-tag entry (intern title))))
(add-hook 'elfeed-new-entry-hook 'my/elfeed-add-title-tag 1)
(defun my/elfeed-hook ()
;; (variable-pitch-mode)
;; (setq-local shr-inhibit-images nil)
(setq-local line-spacing 0.5)
(setq-local shr-width 85))
(defun my/elfeed-search-print-entry (entry)
(let* ((date (elfeed-search-format-date (elfeed-entry-date entry)))
(title (or (elfeed-meta entry :title) (elfeed-entry-title entry) ""))
(title-faces (elfeed-search--faces (elfeed-entry-tags entry)))
(feed (elfeed-entry-feed entry))
(feed-title (when feed
(or (elfeed-meta feed :title) (elfeed-feed-title feed))))
(tags (seq-filter
(lambda (tag) (not (string-equal feed-title tag)))
(mapcar #'symbol-name (elfeed-entry-tags entry))))
(tags-str (mapconcat
(lambda (s) (propertize s 'face 'elfeed-search-tag-face))
tags ","))
(title-width (- (window-width) 10 elfeed-search-trailing-width))
(title-column (elfeed-format-column
title (elfeed-clamp
elfeed-search-title-min-width
title-width
elfeed-search-title-max-width)
:left)))
(insert (propertize date 'face 'elfeed-search-date-face) " ")
(insert (propertize title-column 'face title-faces 'kbd-help title) " ")
(when feed-title
(insert (propertize feed-title 'face 'elfeed-search-feed-face) " "))
(when tags
(insert "(" tags-str ")"))))
(setq elfeed-search-print-entry-function 'my/elfeed-search-print-entry))
:hook ((elfeed-search-mode elfeed-show-mode) . my/elfeed-hook)
:config
(progn
(setq elfeed-search-filter "@1-months-ago +unread #100")
(evil-add-hjkl-bindings elfeed-show-mode-map)
(evil-add-hjkl-bindings elfeed-search-mode-map)
(defun my/elfeed-clear-queue ()
"Sometime elfeed update will end with pending task, which popup at minibuffer, this fix the annoying message"
(interactive)
(setq elfeed-curl-queue-active 0))
(defun my/elfeed-show-images ()
(interactive)
(let ((shr-inhibit-images nil))
(elfeed-show-refresh)))
;;functions to support syncing .elfeed between machines
;;makes sure elfeed reads index from disk before launching
(defun my/elfeed-open-db-and-load ()
"Wrapper to load the elfeed db from disk before opening"
(interactive)
(elfeed-db-load)
(elfeed)
(elfeed-search-update--force))
;;write to disk when quiting
(defun my/elfeed-close-db-and-save ()
"Wrapper to save the elfeed db to disk before burying buffer"
(interactive)
(elfeed-db-save)
;; (quit-window)
)
(defun my/elfeed-toggle-star ()
(interactive)
(let* ((entry (or elfeed-show-entry
(first (elfeed-search-selected))))
(tag (intern "starred"))
(taggged (elfeed-tagged-p tag entry)))
(if taggged
(elfeed-untag entry tag)
(elfeed-tag entry tag))
(message "Starred: %s" (not taggged))))
(defun my/elfeed-search-star ()
(interactive)
(let ((tag (intern "starred"))
(entries (elfeed-search-selected)))
(cl-loop for entry in entries do (elfeed-tag entry tag))
(mapc #'elfeed-search-update-entry entries)
(unless (use-region-p) (forward-line))))
(defun my/elfeed-search-unstar ()
"Remove starred tag from all selected entries."
(interactive)
(let ((tag (intern "starred"))
(entries (elfeed-search-selected)))
(cl-loop for entry in entries do (elfeed-untag entry tag))
(mapc #'elfeed-search-update-entry entries)
(unless (use-region-p) (forward-line))))
(setq my/elfeed-export-dir (expand-file-name "~/Sync/"))
(defun my/elfeed-export (dir)
(interactive (list (read-directory-name "Export dir: " my/elfeed-export-dir)))
(require 'f)
(let* ((sf (elfeed-search-parse-filter "+starred"))
(uf (elfeed-search-parse-filter "-unread"))
(starred-entries '())
(read-entries '())
(hash-table (make-hash-table))
(output (expand-file-name (format-time-string "elfeed-%Y-%m-%d.el" (current-time))
dir)))
(with-elfeed-db-visit (entry feed)
(let ((title-and-link (cons (elfeed-entry-title entry)
(elfeed-entry-link entry))))
(when (elfeed-search-filter sf entry feed)
(add-to-list 'starred-entries title-and-link))
(when (elfeed-search-filter uf entry feed)
(add-to-list 'read-entries title-and-link))))
(puthash :starred starred-entries hash-table)
(puthash :read read-entries hash-table)
(f-write-text (prin1-to-string hash-table) 'utf-8 output)
(message "Export to %s. starred: %d, read: %d" output (length starred-entries) (length read-entries))))
(defun my/elfeed-import (f)
(interactive (list (read-file-name "Backup file: " my/elfeed-export-dir)))
(require 'f)
(let* ((hash-table (read (f-read-text f)))
(starred-entries (thread-last (gethash :starred hash-table)
(mapcar 'cdr)))
(read-entries (thread-last (gethash :read hash-table)
(mapcar 'cdr))))
(with-elfeed-db-visit (entry feed)
(let* ((link (elfeed-entry-link entry)))
(when (member link starred-entries)
(elfeed-tag entry (intern "starred")))
(when (member link read-entries)
(elfeed-untag entry (intern "unread")))))
(message "Import starred: %d, read: %d" (length starred-entries) (length read-entries))))
(defun my/elfeed-search-by-title (title)
(interactive (list (or (when-let* ((entry (car (elfeed-search-selected)))
(feed (elfeed-entry-feed entry)))
(or (cl-destructuring-bind (&key title &allow-other-keys)
(elfeed-feed-meta feed)
title)
(elfeed-feed-title feed)))
(read-from-minibuffer "Feed Title: "))))
(unwind-protect
(let ((elfeed-search-filter-active :live))
(setq elfeed-search-filter (concat "+" title)))
(elfeed-search-update :force)))
(custom-set-faces
'(elfeed-search-unread-title-face ((((class color) (background light)) (:foreground "#000" :weight normal :strike-through nil))
(((class color) (background dark)) (:foreground "#fff" :weight normal :strike-through nil))))
'(elfeed-search-title-face ((((class color) (background light)) (:foreground "grey" :strike-through t))
(((class color) (background dark)) (:foreground "grey" :strike-through t)))))
;; face for starred articles
(defface elfeed-search-starred-title-face
'((t :foreground "#f77" :strike-through nil))
"Marks a starred Elfeed entry.")
(push '(starred elfeed-search-starred-title-face) elfeed-search-face-alist)))
(use-package elfeed-dashboard
:ensure nil
:commands (elfeed-dashboard)
:bind (:map elfeed-dashboard-mode-map
("/" . my/feed-choose-by-tag)
:map elfeed-search-mode-map
("/" . my/feed-choose-by-tag))
:config
(setq elfeed-dashboard-file (no-littering-expand-etc-file-name "elfeed-dashboard.org"))
;; Disable this update, it cost too much cpu when there are many feeds
;; Update feed counts on elfeed-quit
;; (advice-add 'elfeed-search-quit-window :after #'elfeed-dashboard-update-links)
(defun my/feed-choose-by-tag ()
(interactive)
(ivy-read "Tag: " (elfeed-db-get-all-tags)
:action (lambda (tag)
(elfeed-dashboard-query (format "+unread +%s" tag))))))
(use-package elfeed-org
:ensure nil
:custom ((rmh-elfeed-org-files `(,(no-littering-expand-etc-file-name "elfeed-feeds.org"))))
:hook (elfeed-dashboard-mode . elfeed-org)
:init
(progn
(defun my/reload-org-feeds ()
(interactive)
(rmh-elfeed-org-process rmh-elfeed-org-files rmh-elfeed-org-tree-id))
(advice-add 'elfeed-dashboard-update :before #'my/reload-org-feeds)))
|
下面阐述 elfeed 核心配置:
查询语句 | 含义 |
---|
@6-months-ago +unread | 6 个月内的未读文章 |
-unread +youtube #10 | 已读的与 youtube 相关的前 10 篇文章 |
+emacs =http://example.org/feed | 指定 feed 内,与 emacs 有关的文章 |
常用快捷键
elfeed-search
s
在 minibuffer 重新输入搜索词y
yank 当前行文章的 URL,并去掉 unread 标签b
调用外部浏览器打开所选行文章g
刷新当前 feed 列表G
重新抓取 feed 记录
elfeed-show
TAB
切换到下一个超链接处g
刷新b
调用外部浏览器打开文章