emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Cc: emacs-orgmode@gnu.org, No Wayman <iarchivedmywholelife@gmail.com>
Subject: Re: [RFC] DOCT: Declarative Org Capture Templates (easier template syntax)
Date: Mon, 21 Mar 2022 17:14:11 +0800	[thread overview]
Message-ID: <87bkxzd5wc.fsf@localhost> (raw)
In-Reply-To: <875yo8u5kj.fsf@nicolasgoaziou.fr>

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



  reply	other threads:[~2022-03-21  9:14 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-23 17:30 [RFC] DOCT: Declarative Org Capture Templates No Wayman
2020-04-24 10:01 ` Nicolas Goaziou
2020-04-24 18:01   ` No Wayman
2022-03-20 10:19     ` [RFC] DOCT: Declarative Org Capture Templates (easier template syntax) Ihor Radchenko
2022-03-20 13:17       ` Nicolas Goaziou
2022-03-21  9:14         ` Ihor Radchenko [this message]
2022-03-23 16:31           ` Nicolas Goaziou
2022-03-23 21:28             ` Tim Cross
2022-03-24  0:39             ` No Wayman
2022-03-26  8:30               ` Ihor Radchenko
2022-03-27 14:46                 ` Ihor Radchenko
2022-03-29 14:19                 ` Matt Price
2022-03-20 15:56       ` Mark Barton
2022-03-21  8:51         ` Ihor Radchenko
2022-03-23 14:32       ` João Pedro de Amorim Paula
2022-03-24 18:43       ` physiculus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bkxzd5wc.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=iarchivedmywholelife@gmail.com \
    --cc=mail@nicolasgoaziou.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).