[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:


<span style="color:#323232;">* [%] &lt;2023-11-10>
</span><span style="color:#323232;">** [ ] #[A] Some title for a task due today :work: 
</span><span style="color:#323232;">     DEADLINE: &lt;2023-11-10>
</span>

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:


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

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

RePierre,

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.

Take a look at the file+olp+datetree target for the capture templates orgmode.org/manual/Template-elements.html

I am not sure how to make it insert an active timestamp though.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • emacs@lemmy.ml
  • DreamBathrooms
  • ngwrru68w68
  • everett
  • magazineikmin
  • thenastyranch
  • rosin
  • Durango
  • InstantRegret
  • Youngstown
  • slotface
  • khanakhh
  • kavyap
  • mdbf
  • GTA5RPClips
  • JUstTest
  • osvaldo12
  • modclub
  • cisconetworking
  • Leos
  • provamag3
  • tacticalgear
  • ethstaker
  • normalnudes
  • tester
  • megavids
  • cubers
  • anitta
  • lostlight
  • All magazines