org-mode: 获取日志注释
org-mode: Getting logbook notes
我想出了如何使用 org-agenda-get-day-entries
获取我想要的条目,但只有 returns 每个条目的标题及其属性。有没有办法访问相应条目的 LOGBOOK
,特别是存储在那里的任何注释?我也想知道每个笔记的制作日期,这样我就可以过滤它们。
关于元素 API 的文档不是很好,我什至不确定我是否可以在给定标题列表的情况下使用它。
您可以在 org-element-property-drawer-parser
:
点解析抽屉
(defun org-get-logbook-notes ()
(save-excursion
(unless (org-at-heading-p)
(outline-previous-heading))
(when (re-search-forward ":LOGBOOK:" (save-excursion
(outline-next-heading)
(point))
t)
(let* ((elt (org-element-property-drawer-parser nil))
(beg (org-element-property :contents-begin elt))
(end (org-element-property :contents-end elt)))
(buffer-substring-no-properties beg end)))))
接受的答案很好,但本着提供替代方案的精神,org-ml 项目提供了一个功能 API 在 org 元素 API 上实现的。
它包含许多使用 org 文件的便利,并且在惯用上类似于其他现代 Emacs 包,如 dash,用户可能已经熟悉了。在这种情况下,使用 org-ml-headline-get-logbook-items
函数可能比手动查找和解析日志更可取。
OTOH,默认情况下它不随 Emacs 一起提供,这可能是一个考虑因素。
我想出了如何使用 org-agenda-get-day-entries
获取我想要的条目,但只有 returns 每个条目的标题及其属性。有没有办法访问相应条目的 LOGBOOK
,特别是存储在那里的任何注释?我也想知道每个笔记的制作日期,这样我就可以过滤它们。
关于元素 API 的文档不是很好,我什至不确定我是否可以在给定标题列表的情况下使用它。
您可以在 org-element-property-drawer-parser
:
(defun org-get-logbook-notes ()
(save-excursion
(unless (org-at-heading-p)
(outline-previous-heading))
(when (re-search-forward ":LOGBOOK:" (save-excursion
(outline-next-heading)
(point))
t)
(let* ((elt (org-element-property-drawer-parser nil))
(beg (org-element-property :contents-begin elt))
(end (org-element-property :contents-end elt)))
(buffer-substring-no-properties beg end)))))
接受的答案很好,但本着提供替代方案的精神,org-ml 项目提供了一个功能 API 在 org 元素 API 上实现的。
它包含许多使用 org 文件的便利,并且在惯用上类似于其他现代 Emacs 包,如 dash,用户可能已经熟悉了。在这种情况下,使用 org-ml-headline-get-logbook-items
函数可能比手动查找和解析日志更可取。
OTOH,默认情况下它不随 Emacs 一起提供,这可能是一个考虑因素。