Skip to content

Instantly share code, notes, and snippets.

@DivineDominion
Created April 5, 2024 10:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DivineDominion/a29203ace19a339f972b2c5b83e68ebd to your computer and use it in GitHub Desktop.
Save DivineDominion/a29203ace19a339f972b2c5b83e68ebd to your computer and use it in GitHub Desktop.
(defvar ct/org-created-property-name "CREATED"
"The name of the org-mode property that stores the creation date of the entry")
(defun ct/org-set-created-property (&optional active NAME)
"Set a property on the entry giving the creation time.
By default the property is called CREATED. If given the `NAME'
argument will be used instead. If the property already exists, it
will not be modified."
(interactive)
(let* ((created (or NAME ct/org-created-property-name))
(fmt (if active "<%s>" "[%s]"))
(now (format fmt (format-time-string "%Y-%m-%d %a %H:%M"))))
(unless (org-entry-get (point) created nil)
(org-set-property created now))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment