[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC] DOCT: Declarative Org Capture Templates (easier template synta

From: Mark Barton
Subject: Re: [RFC] DOCT: Declarative Org Capture Templates (easier template syntax)
Date: Sun, 20 Mar 2022 08:56:59 -0700

+1 as interested
I saw this project a while ago

I was concerned about long term support and if I would be left with templates I would have to rewrite again, plus I was too busy at the time to adopt it and it stays in my list of TODOs that are not scheduled. That being said, I use org capture daily, but to the points you raise, I avoid changing or adding to to my capture templates.

On Mar 20, 2022, at 3:19 AM, Ihor Radchenko <yantar92@gmail.com> wrote:

I am pinging this thread again because I believe that doct syntax is
much easier to write compared to current defaults. It should be added to
Org core.

Also, if anyone agrees with my arguments below, do not stay silent and
drop a "+1" email below. Otherwise, this whole thing will be stalled.
There is no point discussing technical aspects, if there is no interest.

Citing again an example illustrating the difference between a slightly
non-trivial capture template using current vs. doct syntax:

No Wayman <iarchivedmywholelife@gmail.com> writes:

Without DOCT:

;;rest of template configured elsewhere...
;;make sure you update this if you ever change the key for this
(defun my-org-template-hook ()
 (when (string= (org-capture-get :key t) "t")
   (message "Template \"t\" selected.")))

(add-hook 'org-capture-mode-hook 'my-org-template-hook)

With DOCT:

(doct `("Example" :keys "t" :file ""
       :hook (lambda () (message "Template %s selected."
       (doct-get :keys)))))

DOCT ensures that function is only run for that template without
having the user manually filter against `org-capture-plist's :key.
It also allows the user to do this inline with the rest of the
declaration vs spreading it out.

I believe that the right way to introduce this syntax is creating an
easy-to-use macro like (org-declare-capture-template ...), which takes
care about fiddling with org-capture-templates variable and its format.

The current format of a number of Org customisations is cumbersome. For
example, org-capture-templates and org-agenda-custom-commands often
become long list of lists with each element that must have a very
specific position. Every single time I need to write a new template, I
have to carefully consult the docstring; and every single time I an
reviewing my templates, I have to consult the docstring again simply to
understand the meaning of the first, second, ..., nth element of the
template. Having CL-style :keyword value plists is much more readable.

More generally, it would be useful to provide a doct-like functionality
for org-agenda-custom-commands and similar variables (like
org-agenda-custom-commands, or say, also org-latex-classes).


reply via email to

[Prev in Thread] Current Thread [Next in Thread]