Files
memex/ellama-sessions/Moving org header to org-roam-dailies by creation date (Open AI).org
2026-03-15 14:37:05 -04:00

2.2 KiB

User:

(defun my/org-move-header-to-org-roam-dailies-by-created-date () "Move org header to its creation date in org-roam-dailies." (interactive) (if (org-at-heading-p) (let* ((created-prop (org-entry-get nil "CREATED")) (created-date (and created-prop (org-parse-time-string created-prop)))) (if created-date (progn (org-cut-subtree) (org-roam-dailies-visit-by-timestamp (apply 'encode-time created-date)) (goto-char (point-max)) (newline) (org-paste-subtree) (message "Moved org header to org-roam-dailies by its creation date.")) (message "No CREATED property found in current org header."))) (message "No org header found at point.")))

Ellama:

This Emacs Lisp function, my/org-move-header-to-org-roam-dailies-by-created-date, helps to transfer an Org header to its corresponding date in Org-roam-dailies. This function needs to be executed when your cursor is at an Org header with a "CREATED" property.

Overview of what the function does:

  • Checks if the current point in buffer is at an Org-mode header.
  • If yes, it:

    • Retrieves the "CREATED" property value of the header.
    • Parses the "CREATED" timestamp into a structure that Org-roam-dailies can use.
    • If "CREATED" property is found:

      • The entire subtree of the current header (i.e., the header and everything beneath it) is cut using org-cut-subtree.
      • Jumps to the corresponding daily note on the "CREATED" date in Org-roam-dailies by encoding the timestamp into format Org-roam-dailies can interpret.
      • Goes to the end of the note and inserts a newline.
      • Pastes the cut subtree into the note.
      • Provides a message that the operation of moving the org-header is successful.
    • If not, it prompts a message that the "CREATED" property was not found.
  • If not, it prompts a message that no Org header was found at the current point in the buffer.

Note: This function uses Org-mode and Org-roam-dailies, both of which are Emacs packages. Org-roam-dailies is part of the Org-roam suite of tools and offers the ability to work with daily notes.