3
使用org-get-scheduled-time获取schedule time时的注意事项
source link: https://www.lujun9972.win/blog/2018/10/19/%E4%BD%BF%E7%94%A8org-get-scheduled-time%E8%8E%B7%E5%8F%96schedule-time%E6%97%B6%E7%9A%84%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9/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-get-scheduled-time获取schedule time时的注意事项
当使用 org-get-scheduled-time
获取某个heading的 schedule time
时,请保证 SCHEDULED: xxxx
是放在标题的正下方第一行的位置上。
因为 org-get-scheduled-time
最终是通过 org-entry-properties
来获取属性值的(SCHEDULED,定义在 org-special-propereties
中,这些熟悉并不会放在properties drawer中,但依然是属性的一种).
而 org-entry-properties
中获取SCHEDULED的代码是下面这一段。
(when (or (not specific) (member specific '("CLOSED" "DEADLINE" "SCHEDULED"))) (forward-line) (when (looking-at-p org-planning-line-re) (end-of-line) (let ((bol (line-beginning-position)) ;; Backward compatibility: time keywords used to ;; be configurable (before 8.3). Make sure we ;; get the correct keyword. (key-assoc `(("CLOSED" . ,org-closed-string) ("DEADLINE" . ,org-deadline-string) ("SCHEDULED" . ,org-scheduled-string)))) (dolist (pair (if specific (list (assoc specific key-assoc)) key-assoc)) (save-excursion (when (search-backward (cdr pair) bol t) (goto-char (match-end 0)) (skip-chars-forward " \t") (and (looking-at org-ts-regexp-both) (push (cons (car pair) (match-string-no-properties 0)) props))))))) (when specific (throw 'exit props)))
注意看第三行和第四行
(forward-line) (when (looking-at-p org-planning-line-re) .....)
是的,它要求标题的下一行匹配 org-planning-line-re
的正则表达式.
而 org-planning-line-re
的值为
org-planning-line-re is a variable defined in ‘org.el’. Its value is "^[ ]*\\(\\(?:CLOSED\\|DEADLINE\\|SCHEDULED\\):\\)" This variable may be risky if used as a file-local variable. Documentation: Matches a line with planning info. Matched keyword is in group 1.
从上面可以看出,不仅仅是 scheduled-time,deadline-time和closed-time 也是一样的情况。
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK