Skip to content

Commit

Permalink
Use hardcoded timestamp format for CREATED properties in Org
Browse files Browse the repository at this point in the history
  • Loading branch information
alecigne committed Dec 27, 2022
1 parent a7b9353 commit e98023d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lisp/alc/alc-org.el
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,18 @@
(replace-match "\\1\\2"))
(org-align-tags))))

(setq alc-org-insert-created-timestamp-format "[%Y-%m-%d %a %H:%M]"
alc-org-insert-created-property "CREATED")

(defun alc-org-insert-created ()
"Insert a CREATED property with the current date."
(interactive)
(let* ((property-name "CREATED")
(existing-date (org-entry-get (point) property-name))
(time-format (concat "[" (cdr org-time-stamp-formats) "]")))
(let ((existing-date (org-entry-get (point) alc-org-insert-created-property))
(now (format-time-string alc-org-insert-created-timestamp-format)))
(when (null existing-date)
(save-excursion
(org-entry-put
(point) property-name (format-time-string time-format))))))
(point) alc-org-insert-created-property now)))))

(dolist (fn '(org-insert-heading org-toggle-heading))
(advice-add fn :after #'(lambda (&rest _) (alc-org-insert-created))))
Expand Down

0 comments on commit e98023d

Please sign in to comment.