On 2026-10-20 08:06, Richard Lawrence wrote:
Looking more closely at how org-capture works, I see I can't expect to
put stuff into org-capture-plist myself, because that's overwritten by
the capture template entry at the beginning of org-capture.  But there
are a variety of variables I can let-bind, e.g. org-capture-initial,
org-overriding-default-time, and org-capture-link-is-already-stored.  So
that's probably the right approach...?

I don't know if it is the right way, but I have some examples in my config [1] where I abuse the usage of org-capture to do what I want. Just in case that inspires you, if not, sorry the noise.


I have some org-capture templates that I call "hybrid", that means that they can be interactive, or they can be filled automatically.

For example, for appointments, this is the non-interactive version, that I define in a function (which is useful to schedule the regular week appointments/tasks [1.5]):

    (my/fappt :appt-type "presencial" :title "yoga"        :date "Mon 09:15" :tag "body" :effort "1:00" :location "yoga center")

And that calls the org-capture definition:

    (";a" "Noninteractive Agenda Appointment" entry (file+function my/diary-file-fp my/prepare-appt) (file "~/org/org-capture-templates/appointment_hybrid.org") :empty-lines 1 :prepend t :jump-to-captured nil :immediate-finish t)

So in the template appointment_hybrid.org [2] I have custom vars, m/p is a short-simple function to ensure that custom vars are inserted in the template

For the non interactive one, the function my/fappt writes a global var that says this is batch mode, and routes to mapping the arguments of the function to the variables of the template, and then calls the ;a template (org-capture nil ";a")

Later calls `my/prepare-appt`, detects is batch-mode (non interactive), hence skips the interactive part

The org-capture definition for the interactive one is:

    ("a" "Agenda Appointment" entry (file+function my/diary-file-fp my/prepare-appt) (file "~/org/org-capture-templates/appointment_hybrid.org") :empty-lines 1 :prepend t)

Gets directly into my/prepare-appt, detects is interactive, then you go into some functions to fill data using org-read, completion-read, etc.

For some of the org-captures, and this is the case, I have post-hooks, in this case, my/post-appt; for things that for some reason, I need to wait all org-capture machinery to finish and then do something

Cheers,
pinmacs

[1] see the var org-capture-templates https://codeberg.org/pedroberg/pinmacs-emacs-config/raw/branch/main/emacs-config.org

[1.5] I don't know how I end up doing this but "works for me"

[2] https://codeberg.org/pedroberg/pinmacs-emacs-config/raw/branch/main/org-capture-templates/appointment_hybrid.org

Reply via email to