Skip to content

Instantly share code, notes, and snippets.

@jonkri
Created June 27, 2021 14:08
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 jonkri/ed6a54b2e5e704574680ae60afba47e3 to your computer and use it in GitHub Desktop.
Save jonkri/ed6a54b2e5e704574680ae60afba47e3 to your computer and use it in GitHub Desktop.
(defun today-anchor ()
"Find or create an anchor for today's date"
;; (org-time-stamp-format) for an active time stamp
(setq date (format-time-string (org-time-stamp-format nil t) (current-time)))
(goto-char (point-min))
(if (re-search-forward (format org-complex-heading-regexp-format (regexp-quote date)) nil t)
(goto-char (line-beginning-position))
(goto-char (point-min))
(next-line)
(or (bolp) (insert "\n"))
(insert "* " date "\n")
(beginning-of-line 0)
(org-end-of-subtree)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment