8 个赞
最近加了两个函数,实现自定义 tag 的导出与导入,方便备份。目前导出的两个 tag。(依赖:https://github.com/rejeep/f.el)
-
+starred
加星的 -
-unread
已经读过的
(defun my/elfeed-export (output)
(interactive "fOutput: ")
(let* ((sf (elfeed-search-parse-filter "+starred"))
(uf (elfeed-search-parse-filter "-unread"))
(starred-entries '())
(read-entries '())
(hash-table (make-hash-table)))
(with-elfeed-db-visit (entry feed)
(when (elfeed-search-filter sf entry feed)
(add-to-list 'starred-entries (elfeed-entry-link entry)))
(when (elfeed-search-filter uf entry feed)
(add-to-list 'read-entries (elfeed-entry-link entry))))
(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 "fInput: ")
(let* ((hash-table (read (f-read-text f)))
(starred-entries (gethash :starred hash-table))
(read-entries (gethash :read hash-table)))
(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))))
1 个赞
最近又更新了一小节,将 Emacs 设置为 macOS 上的默认邮件客户端,这样点击 mailto 的链接就可以在 mu4e 中去编辑了。
发现一个导致 elfeed update 时卡的问题,问题好久了,一直懒得去找原因,今天搜了下,竟然是 flycheck 的锅。
好奇 elfeed-export-opml
和 elfeed-load-opml
为什么不记录 tag
信息呢?
(defun eli/elfeed-overview ()
"Get an overview of all feeds."
(interactive)
(with-current-buffer (elfeed-search-buffer)
(elfeed-save-excursion
(let* ((inhibit-read-only t)
(standard-output (current-buffer)))
(erase-buffer)
(eli/elfeed-overview--update-list)
(dolist (entry elfeed-search-entries)
(funcall elfeed-search-print-entry-function entry)
(insert "\n"))
(setf elfeed-search-last-update (float-time))))
(when (zerop (buffer-size))
;; If nothing changed, force a header line update
(force-mode-line-update))
(run-hooks 'elfeed-search-update-hook)))
(defun eli/elfeed-overview--update-list ()
"Update `elfeed-search-filter' list."
(let* ((head (list nil))
(tail head)
(count 0))
(dolist (feed elfeed-feeds)
(let* ((lexical-binding t)
(filter (elfeed-search-parse-filter
(concat "=" (or (car-safe feed)
feed))))
(func (byte-compile (elfeed-search-compile-filter filter))))
(with-elfeed-db-visit (entry feed)
(when (funcall func entry feed count)
(setf (cdr tail) (list entry)
tail (cdr tail)
count (1+ count))
(elfeed-db-return)))))
(let ((entries (cdr head))
(elfeed-search-sort-function
(lambda (a b)
(let ((a-date (elfeed-entry-date a))
(b-date (elfeed-entry-date b)))
(> a-date b-date)))))
(setf entries (sort entries elfeed-search-sort-function))
(setf elfeed-search-entries
entries))))
Eli 的这两个函数挺好用的,展示自己的订阅列表(最近更新的文章以及更新时间)
1 个赞