Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mrvdb
Created November 8, 2012 09:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrvdb/4037694 to your computer and use it in GitHub Desktop.
Save mrvdb/4037694 to your computer and use it in GitHub Desktop.
;;
;; 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)
(require 'org-capture)
(defadvice org-capture (after mrb/created-timestamp-advice activate)
"Insert a CREATED property using org-expiry.el for TODO entries"
; Test if the captured entry is a TODO, if so insert the created
; timestamp property, otherwise ignore
(when (member (org-get-todo-state) org-todo-keywords-1)
(mrb/insert-created-timestamp)))
(ad-activate 'org-capture)
;; Add feature to allow easy adding of tags in a capture window
(defun mrb/add-tags-in-capture()
(interactive)
"Insert tags in a capture window without losing the point"
(save-excursion
(org-back-to-heading)
(org-set-tags)))
;; Bind this to a reasonable key
(define-key org-capture-mode-map "\C-c\C-t" 'mrb/add-tags-in-capture)
@mrvdb
Copy link
Author

mrvdb commented Feb 8, 2024

the defadvice defines mrb/created-timestamp-advice there

see https://qua.name/mrb/an-org-babel-based-emacs-configuration#orgdaa7c19 for elaboration

edit: updated my code to simpler version, visible at the above link.

@anoduck thanks for the trigger

@anoduck
Copy link

anoduck commented Feb 10, 2024

the defadvice defines mrb/created-timestamp-advice there

see https://qua.name/mrb/an-org-babel-based-emacs-configuration#orgdaa7c19 for elaboration

edit: updated my code to simpler version, visible at the above link.

@anoduck thanks for the trigger

Thus, is why I deleted my original comment, as at the time my understanding was mistaken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment