Skip Navigation

[Question] Creating a complex capture structure, need some guidance

Hey gang, so I've been attempting to create a more organized way to capture daily tasks in with org-capture and I'm having trouble figuring out the best way to do so.

The structure I want is the following:

* [%] <2023-11-10>
** [ ] #[A] Some title for a task due today :work: 
     DEADLINE: <2023-11-10>

The idea would be:

  1. If a top level heading for today's date doesn't exist, create it and create a subheading
  2. If a top level heading for today's date does exist, simply just add a subheading.

At first, I had a function I tried to use that didn't work the way I wanted when I first wrote it. In retrospect, I don't know why I thought it would.

Then I tried using capture templates but that doesn't meet the requirements.

In rewriting the function I linked to previously, this is what I have so far:

      (defun org-capture::today-task-tree ()
        "Create a task tree for tasks TODO today."
        (let* ((time-string (format-time-string "<%Y-%m-%d %a>" (current-time)))
               (heading-rx
                (rx (group "[" (0+ num) "%]") (0+ space)
                    (group (literal time-string))))
               (heading (concat "[%] " time-string)))
          (goto-char (point-max))
          (if-let (pnt (re-search-backward
                        heading-rx
                        nil t))
              (progn
                (goto-char pnt)
                (end-of-line)
                (insert "\n")
                (insert "** [ ] ")
                (beginning-of-line 0))
            (goto-char (point-max))
            (or (bolp) (insert "\n"))
            (insert "* " heading "\n")
            (beginning-of-line 0)))))))

Any suggestions? I just learned out the Org Mapping API but I'm not entirely sure if that'll suit my needs.

1
1 comments