[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC] DOCT: Declarative Org Capture Templates (easier template synta
From: |
Ihor Radchenko |
Subject: |
Re: [RFC] DOCT: Declarative Org Capture Templates (easier template syntax) |
Date: |
Mon, 21 Mar 2022 17:14:11 +0800 |
Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:
> I think there should be a direct mapping between Customize interface and
> values. Adding this macro as a band-aid to simply configuration is not,
> IMO, a solution.
I think that current customize interface for org-capture-template is
perfectly fine. doct aids users who set org-capture-templates
programatically. doct also does not break the mapping between customize
and the values - it converts the doct syntax into the default
org-capture-template format + adds a number of shorthands for
capture-related hooks + to capture contexts + provides easier definition
of similar templates (via inheritance).
For example the below doct definition provides two similar templates
without a need to duplicate them:
(defcustom org-capture-ref-capture-template `( :group "org-capture-ref template"
:type entry
,@org-capture-ref-capture-target
:fetch-bibtex (lambda ()
(org-capture-ref-process-capture)) ; this must run first
:link-type (lambda ()
(org-capture-ref-get-bibtex-field :type))
:extra (lambda () (if
(org-capture-ref-get-bibtex-field :journal)
(s-join "\n"
'("- [ ]
[[elisp:(browse-url (url-encode-url (format \"https://sci-hub.se/%s\"
(org-entry-get nil \"DOI\"))))][downlaod and attach pdf]]"
"- [ ]
[[elisp:org-attach-open][read paper capturing interesting references]]"
"- [ ]
[[elisp:(browse-url (url-encode-url (format
\"https://www.semanticscholar.org/search?q=%s\" (org-entry-get nil
\"TITLE\"))))][check citing articles]]"
"- [ ]
[[elisp:(browse-url (url-encode-url (format
\"https://www.connectedpapers.com/search?q=%s\" (org-entry-get nil
\"TITLE\"))))][check related articles]]"
"- [ ] check if
bibtex entry has missing fields"
"- [ ] Consider
subscribing to new citations"))
""))
:org-entry (lambda ()
(org-capture-ref-get-org-entry))
:template
("%{fetch-bibtex}* TODO %?%{space}%{org-entry}"
"%{extra}")
:children (("Interactive org-capture-ref
template"
:keys ,(car
org-capture-ref-capture-keys)
:space " ")
("Silent org-capture-ref template"
:keys ,(cadr
org-capture-ref-capture-keys)
:space ""
:immediate-finish t)))
"Default capture template. The template is a template defined using
`doct' syntax. See docstring of `doct' for details."
:type 'list
:group 'org-capture-ref)
> If capture templates values are too complicated, what about simplifying
> them, and possibly use this macro as a temporary solution to help
> transition?
Could you elaborate what you are referring to? doct is a simplification
of otherwise more complex templates. Without doct, users may need to
write addition Elisp to define complex templates. With doct, a number of
things can be done in a more compact form.
A bright example is defining a capture hook that will only be activated
for a specific template. doct allows to do it seamlessly, while vanilla
syntax will require user to set the hook manually and check the current
active template via elisp in a non-obvious ways that require knowing
org-capture internals.
Best,
Ihor
- Re: [RFC] DOCT: Declarative Org Capture Templates (easier template syntax), Ihor Radchenko, 2022/03/20
- Re: [RFC] DOCT: Declarative Org Capture Templates (easier template syntax), Nicolas Goaziou, 2022/03/20
- Re: [RFC] DOCT: Declarative Org Capture Templates (easier template syntax),
Ihor Radchenko <=
- Re: [RFC] DOCT: Declarative Org Capture Templates (easier template syntax), Nicolas Goaziou, 2022/03/23
- Re: [RFC] DOCT: Declarative Org Capture Templates (easier template syntax), Tim Cross, 2022/03/23
- Re: [RFC] DOCT: Declarative Org Capture Templates (easier template syntax), No Wayman, 2022/03/23
- Re: [RFC] DOCT: Declarative Org Capture Templates (easier template syntax), Ihor Radchenko, 2022/03/26
- Re: [RFC] DOCT: Declarative Org Capture Templates (easier template syntax), Ihor Radchenko, 2022/03/27
- Re: [RFC] DOCT: Declarative Org Capture Templates (easier template syntax), Matt Price, 2022/03/29
Re: [RFC] DOCT: Declarative Org Capture Templates (easier template syntax), Mark Barton, 2022/03/20
Re: [RFC] DOCT: Declarative Org Capture Templates (easier template syntax), João Pedro de Amorim Paula, 2022/03/23
Re: [RFC] DOCT: Declarative Org Capture Templates (easier template syntax), physiculus, 2022/03/24