emacs - 在组织模式下将CREATED date属性添加到TODO

标签 emacs elisp org-mode

我阅读了组织模式手册,但找不到简单的方法将CREATED字段添加到新创建的TODO中。然后结合org-log-done可以计算出关闭特定TODO所需的时间。在使用存档文件时,这尤其有用。

例:

* TODO Do something
  CREATED:  [2012-09-02 Sun 23:02]
* DONE Do something else
  CREATED: [2012-09-02 Sun 20:02]
  CLOSED: [2012-09-02 Sun 22:02]


每当文件保存时,我希望CREATED字段会添加到新任务(没有该字段的任务)中。

关于如何实现这一目标的任何建议?使用Git之类的方法并不是跟踪TODOS创作的解决方案。

最佳答案

我使用org-expiry来实现该功能,该功能位于org的contrib目录中。

我使用的基本配置是:

;; Allow automatically handing of created/expired meta data.
(require 'org-expiry)
;; Configure it a bit to my liking
(setq
  org-expiry-created-property-name "CREATED" ; Name of property when an item is created
  org-expiry-inactive-timestamps   t         ; Don't have everything in the agenda view
)

(defun mrb/insert-created-timestamp()
  "Insert a CREATED property using org-expiry.el for TODO entries"
  (org-expiry-insert-created)
  (org-back-to-heading)
  (org-end-of-line)
  (insert " ")
)

;; Whenever a TODO entry is created, I want a timestamp
;; Advice org-insert-todo-heading to insert a created timestamp using org-expiry
(defadvice org-insert-todo-heading (after mrb/created-timestamp-advice activate)
  "Insert a CREATED property using org-expiry.el for TODO entries"
  (mrb/insert-created-timestamp)
)
;; Make it active
(ad-activate 'org-insert-todo-heading)


如果您使用的是捕获功能,它将无法自动运行,并且需要一点胶水。我已经在此处发布了完整的配置:https://gist.github.com/4037694

关于emacs - 在组织模式下将CREATED date属性添加到TODO,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12262220/

相关文章:

emacs - Elisp破坏性操作警告?

emacs - org-mode 不喜欢 c++-mode

emacs - 无法在 emacs 组织模式下打开链接

Emacs 组织模式 : How can i fold everything but the current headline?

linux - 如何从汇编语言生成可执行文件?(在 emacs 中)

emacs - 在 Emacs 中哪里输入一段代码?

email - 如何使用 w3m 呈现 EMAIL 消息中的 HTML 内容?

python - 我想要一个 elisp 脚本在光标下执行 Python 单行代码

regex - 对 Emacs Regex 感到困惑

emacs - 是否有 Emacs 变量来关闭具有特定扩展名的文件的备份?