[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: 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
                                :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 () 
                                ("%{fetch-bibtex}* TODO %?%{space}%{org-entry}"
                                :children (("Interactive org-capture-ref 
                                            :keys ,(car 
                                            :space " ")
                                           ("Silent org-capture-ref template"
                                            :keys ,(cadr 
                                            :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.


reply via email to

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