elfeed-org
使用 Orgmode 文件配置 Elfeed RSS 阅读器
问题
使用常规的扁平列表来维护所有 RSS 订阅源的标签非常繁琐,因为该列表没有层级结构,且标签名称大量重复。例如, 这就是 Elfeed 用户通常配置其订阅源的方式。
(defvar elfeed-feeds-alist
'(("http://threesixty360.wordpress.com/feed/" blog math)
("http://www.50ply.com/atom.xml" blog dev)
("http://blog.cryptographyengineering.com/feeds/posts/default" blog)
("http://abstrusegoose.com/feed.xml" comic)
("http://accidental-art.tumblr.com/rss" image math)
("http://english.bouletcorp.com/feed/" comic)
("http://curiousprogrammer.wordpress.com/feed/" blog dev)
("http://feeds.feedburner.com/amazingsuperpowers" comic)
("http://amitp.blogspot.com/feeds/posts/default" blog dev)
("http://pages.cs.wisc.edu/~psilord/blog/rssfeed.rss" blog)
("http://www.anticscomic.com/?feed=rss2" comic)
("http://feeds.feedburner.com/blogspot/TPQSS" blog dev)))
如果你想为 feed 添加自定义标题,那会更加繁琐……
解决方案
Org-mode 使标签和 feed 的记录管理变得更加简单。标签会从父级标题继承,因此无需为每个 feed 单独指定标签。
* Blogs :elfeed:
** entry-title: \(linux\|linus\|ubuntu\|kde\|gnome\) :linux:
** http://git-annex.branchable.com/design/assistant/blog/index.rss :mustread:
** http://feeds.feedburner.com/InformationIsBeautiful
** [[http://orgmode.org][Org Mode Links supported as well]]
** Software Development :dev:
*** Emacs :emacs:mustread:
**** http://www.terminally-incoherent.com/blog/feed
**** http://nullprogram.com/feed
**** entry-title: \(emacs\|org-mode\)
**** http://planet.emacsen.org/atom.xml
**** [[toobnix:154][EmacsConf]]
*** Web Development :web:
**** http://planet.phpunit.de/atom.xml
**** http://feeds.feedburner.com/symfony/blog
**** http://feeds.feedburner.com/qooxdoo/blog/content
*** Eclipse :eclipse:
**** http://blog.eclipse-tips.com/feeds/posts/default?alt=rss
**** http://ed-merks.blogspot.com/feeds/posts/default
A description of a feed can be written under any headline.
The text will be ignored by elfeed.
**** http://feeds.feedburner.com/eclipselive :ignore:
**** http://www.fosslc.org/drupal/rss.xml :video:
#+link: toobnix https://toobnix.org/feeds/videos.xml?videoChannelId=
一些亮点:
[[http://orgmode.org][Org Mode Links supported as well]]如果你选择使用 org-mode 链接,链接描述将用作 Elfeed 中订阅源的标题。这对于标题较长的订阅源非常有用。entry-title: \(emacs\|org-mode\)根据给定的标签和继承的标签,为标题中包含 "emacs" 或 "org-mode" 的任何博客文章添加标签(在上面的示例中为 "emacs"、"mustread" 和 "dev")。http://feeds.feedburner.com/eclipselive :ignore:"ignore" 会将订阅源完全排除在你的已检查订阅之外。你可以通过自定义rmh-elfeed-org-ignore-tag为 "ignore" 使用其他名称。如果rmh-elfeed-org-auto-ignore-invalid-feeds设置为t,elfeed-org 会在订阅源出错时(例如 URL 错误或订阅源重命名)自动设置这些 "ignore" 标签。
导入/导出 OPML
使用 elfeed-org-export-opml 将订阅源的树结构导出为 OPML 格式到一个临时缓冲区。这将允许你在保存之前进行编辑。你可能希望这样做,因为大多数阅读器不允许超过 2 个层级,而 elfeed-org 没有限制。
使用 elfeed-org-import-opml 将 OPML 文件导入到 elfeed-org 结构的树中。
配置树
你可以使用多个树。这些树可以在同一个文件中,也可以分布在
rmh-elfeed-org-files 列表中指定的多个文件中。为什么我要使用多个树?
你可以在一个文件中拥有一个树,你可能希望与你的
emacs.d 在 GitHub 上共享,并将你的个人订阅源保存在一个单独的私有
仓库中。
在此包的初始版本中,树是通过将 ID 属性设置为 rmh-elfeed-org-tree-id
(默认为 "elfeed")的值来识别的,但该属性被证明是特殊的(参见
org mode 手册)
我不应该使用它。为了不破坏任何现有用户的
配置,这仍然被允许,但我建议现在使用 rmh-elfeed-org-tree-id 的值来标记树。
因此,而不是
* Blogs
:PROPERTIES:
:ID: elfeed
:END:
我建议使用
* Blogs :elfeed:
提示
关于 org-mode 源配置的几个提示:
- 树中应有一个与变量
rmh-elfeed-org-tree-id中指定的字符串匹配的标签。 - 源必须以
http开头,或者位于 org-mode 链接格式(URL 仍应以http开头)。 - 标签规则必须以
entry-title:开头,并以正则表达式结尾。 - 标签规则使用带有
elfeed-make-tagger的“标签钩子”为标题中匹配正则表达式的所有帖子添加标签。 更多信息请参阅 https://github.com/skeeto/elfeed - 您可以在带有 URL 的标题下方添加文本,以描述 源或添加注释。这些内容将被忽略。
- 不以
http或entry-title:开头的标题将被忽略。
安装
要求
运行于 .github/workflows/ci.yml 中指定的 emacs 版本
如果您使用 emacs-24 发行版,此包需要 org-mode 8.2.7 才能正常运行。需要该 org-mode 版本的原因是 org-mode 8.2.6 - 至少在与 GNU Emacs 24.4.50.1 结合使用时 - 会导致错误 (error "recenter'ing a window that does not display current-buffer.")。
最低运行所需的 org-mode 最低版本是 org-mode 8.1,因为这是首次定义了对此包至关重要的函数 org-element-map 的版本。
Spacemacs
此包是出色的 Spacemacs 的一部分。请参阅 Elfeed Layer Documentation 获取安装说明。
通过 MELPA
;; Install through package manager
M-x package-install <ENTER>
elfeed-org <ENTER>
手册
下载 elfeed-org
$ cd ~/.emacs.d/lisp
$ wget https://github.com/remyhonig/elfeed-org/blob/master/elfeed-org.el
在 Emacs 中安装该包
C-x C-f ~/.emacs.d/lisp/elfeed-org.el <ENTER>
M-x package-install-from-buffer <ENTER>
初始化
在你的初始化脚本中添加以下内容:
;; Load elfeed-org
(require 'elfeed-org)
;; Initialize elfeed-org
;; This hooks up elfeed-org to read the configuration when elfeed
;; is started with =M-x elfeed=
(elfeed-org)
;; Optionally specify a number of files containing elfeed
;; configuration. If not set then the location below is used.
;; Note: The customize interface is also supported.
(setq rmh-elfeed-org-files (list "~/.emacs.d/elfeed.org"))
功能请求与错误修复
我感谢大家提供的功能请求和用于修复问题的代码片段,但我现在确实没有太多空闲时间。如果您想添加功能或修复错误,请提交一个 pull request,如果包含相应的测试以及(如适用)README 的更新,我会立即合并。我刚刚将 CI 从 Travis(已不再可用)迁移到 Github Action,因此现在这个过程应该会更快。最后:非常感谢所有 PR 作者和问题提交者!