refactor: moved org-agent to its own repository as a submodule
This commit is contained in:
28
projects/org-gtd-archive-roam-daily/README.org
Normal file
28
projects/org-gtd-archive-roam-daily/README.org
Normal file
@@ -0,0 +1,28 @@
|
||||
#+title: Org-GTD Archive Roam Daily Project
|
||||
#+author: Amero Garcia
|
||||
#+created: [2026-03-16 Mon 14:05]
|
||||
#+begin_comment
|
||||
Project documentation for Org-GTD Archive Roam Daily Project
|
||||
#+end_comment
|
||||
|
||||
* Org-GTD Archive Roam Daily Project
|
||||
|
||||
*Goal:** To develop a feature for `org-gtd` that enables archiving of Org-mode headings to `org-roam-dailies` based on the `:CREATED:` property of the heading being archived. This will ensure chronological and contextually relevant archiving.
|
||||
|
||||
*Initial Scope:**
|
||||
- Understanding the current `org-gtd` archiving mechanisms.
|
||||
- Investigating `org-roam-dailies` structure and API for programmatic interaction.
|
||||
- Designing a function that extracts the `:CREATED:` property from an Org heading.
|
||||
- Implementing logic to move/copy the heading content to the correct daily note based on its creation date.
|
||||
- Considering how to handle headings without a `:CREATED:` property.
|
||||
|
||||
*Information Needed from Amr:**
|
||||
- Specific `org-gtd` setup details (e.g., how archiving is currently triggered/configured).
|
||||
- Desired behavior if a `:CREATED:` property is missing.
|
||||
- Preferred method for integration (e.g., new command, modification of existing archiving function).
|
||||
- Any existing thoughts on error handling or edge cases.
|
||||
|
||||
*Next Steps:**
|
||||
1. Gather Amr's specific usage patterns and requirements.
|
||||
2. Dive into `org-gtd` and `org-roam` documentation/source code.
|
||||
3. Propose a design for the new archiving function.
|
||||
@@ -0,0 +1,74 @@
|
||||
;;; org-gtd-archive-roam-daily.el --- Archive Org headings to Org-roam dailies
|
||||
;;; Commentary:
|
||||
;; This file provides an Elisp function to archive an Org-mode heading
|
||||
;; at point to an Org-roam daily file based on its :CREATED: property.
|
||||
;;; Code:
|
||||
|
||||
(require 'org-roam-dailies)
|
||||
(require 'org-element)
|
||||
(require 'org-time)
|
||||
|
||||
(defun amero-get-org-heading-created-property ()
|
||||
"Extract the :CREATED: property from the current Org heading.
|
||||
Returns a time string or nil if not found."
|
||||
(interactive)
|
||||
(save-excursion
|
||||
(org-back-to-heading t)
|
||||
(org-entry-get (point) "CREATED")))
|
||||
|
||||
(defun amero-parse-created-timestamp (timestamp-string)
|
||||
"Parse an Org-mode timestamp string like '[2026-03-16 Mon 14:05]'
|
||||
into an Emacs internal time object.
|
||||
Returns nil if parsing fails."
|
||||
(ignore-errors
|
||||
(org-time-string-to-time timestamp-string)))
|
||||
|
||||
(defun amero-get-daily-note-file (time-object)
|
||||
"Get the Org-roam daily note file for a given Emacs TIME-OBJECT.
|
||||
Creates the file if it doesn't exist. Returns the file path."
|
||||
(let* ((date-string (format-time-string org-roam-dailies-capture-templates-date-format time-object))
|
||||
(file-path (expand-file-name (concat date-string ".org")
|
||||
(expand-file-name org-roam-dailies-directory org-roam-directory))))
|
||||
;; Ensure the directory exists
|
||||
(unless (file-exists-p (file-name-directory file-path))
|
||||
(make-directory (file-name-directory file-path) t))
|
||||
;; Create file if it doesn't exist (org-roam-dailies-goto-date handles this,
|
||||
;; but we need to ensure it's created and accessible for append)
|
||||
(unless (file-exists-p file-path)
|
||||
(with-temp-buffer
|
||||
(insert (format "#+title: %s\n" date-string))
|
||||
(write-file file-path)))
|
||||
file-path))
|
||||
|
||||
(defun org-gtd-archive-roam-daily ()
|
||||
"Archive the current Org heading to an Org-roam daily file
|
||||
based on its :CREATED: property.
|
||||
Signals an error if :CREATED: property is missing."
|
||||
(interactive)
|
||||
(unless (org-before-first-heading-p (point))
|
||||
(user-error "Point is not on an Org heading or within an Org file."))
|
||||
|
||||
(let* ((created-timestamp-string (amero-get-org-heading-created-property))
|
||||
(created-time-object (and created-timestamp-string
|
||||
(amero-parse-created-timestamp created-timestamp-string)))
|
||||
(heading-start (save-excursion (org-back-to-heading t) (point)))
|
||||
(heading-end (save-excursion (org-end-of-subtree t) (point)))
|
||||
(heading-content (buffer-substring-no-properties heading-start heading-end))
|
||||
daily-file-path)
|
||||
|
||||
(unless created-time-object
|
||||
(user-error "No date error: Heading is missing a valid :CREATED: property."))
|
||||
|
||||
(setq daily-file-path (amero-get-daily-note-file created-time-object))
|
||||
|
||||
(with-current-buffer (find-file-noselect daily-file-path)
|
||||
(goto-char (point-max))
|
||||
(insert "\n\n" heading-content)
|
||||
(save-buffer))
|
||||
|
||||
;; Remove the original heading
|
||||
(delete-region heading-start heading-end)
|
||||
(message "Archived heading to %s" daily-file-path)))
|
||||
|
||||
(provide 'org-gtd-archive-roam-daily)
|
||||
;;; org-gtd-archive-roam-daily.el ends here
|
||||
Reference in New Issue
Block a user