3

org module之org-feed

 2 years ago
source link: https://www.lujun9972.win/blog/2020/02/11/org-module%E4%B9%8Borg-feed/index.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

org module之org-feed

该module能让你将RSS feed中的内容保存到Org文件指定的标题下,还是蛮好玩的。

  1. 设置 org-feed-alist

    从名字上就能看出,这是一个alist,每个entry的格式为 (feed名称 URL 存储的Org文件路径 存储的标题),比如

    (push '("科学松鼠会" "https://songshuhui.net/feed" "~/我的GTD/Note.org" "Feeds/科学松鼠会") org-feed-alist)
    
  2. 执行 M-x org-feed-update-all

此外, org-feed-alist 还支持在每个entry后面加上多个 keyword-value 对 的参数,用来对feed中的每篇文章进行自定义的处理,详情可以参见它的doc-string说明:

:drawer drawer-name存储feed信息的drawer名称,默认为FEEDSTATUS :filter filter-function过滤item的函数,若通过则返回该entry,否则返回nil :template template-string组建Org entry的模板 :formatter formatter-function格式化feed item成Org entry的函数 :new-handler function处理新增feed item的函数 :changed-handler function处理更新 feed item 的函数 :parse-feed function解析feed的函数 :parse-entry function解析feed item的函数

默认情况下,每个feed item都会被解析为一个plist,其中feed item中的域名都对应一个property,此外为了方便处理,还有两个特殊的property:

:item-full-text<item> 标签内的全文本 guid-permalink当guid 属性为 permalink 是设置为 t

理论上跟org-eww连用,我们完全可以把feed中的内容摘录到Org文件中保存起来,像这样:

(defun org-eww-save-by-url (url &optional timeout)
  (let ((url (replace-regexp-in-string "\\[\\|\\]" "" url))
        (timeout (or timeout 5)))
        (message "URL is %s" url)
        (save-excursion 
          (eww url)
          (sit-for timeout)
          (eww-readable)
          (org-eww-copy-for-org-mode)
          (pop kill-ring))))


(setq org-feed-alist '(("科学松鼠会" "https://songshuhui.net/feed" "~/我的GTD/Note.org" "科学松鼠会"
                        :template "* %h
%t
from %a
%(org-eww-save-by-url \"%a\")")))

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK