From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id j6lKHXspo16aGAAA0tVLHw (envelope-from ) for ; Fri, 24 Apr 2020 18:01:31 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id WMXtNYEpo14WVAAAB5/wlQ (envelope-from ) for ; Fri, 24 Apr 2020 18:01:37 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 9BDD29429D4 for ; Fri, 24 Apr 2020 18:01:36 +0000 (UTC) Received: from localhost ([::1]:47176 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jS2ds-0001HX-7U for larch@yhetil.org; Fri, 24 Apr 2020 14:01:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59256) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jS2dP-0001HP-6R for emacs-orgmode@gnu.org; Fri, 24 Apr 2020 14:01:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jS2dO-00084y-HE for emacs-orgmode@gnu.org; Fri, 24 Apr 2020 14:01:06 -0400 Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f]:46380) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jS2dO-00083j-4W for emacs-orgmode@gnu.org; Fri, 24 Apr 2020 14:01:06 -0400 Received: by mail-qt1-x82f.google.com with SMTP id x8so8632499qtp.13 for ; Fri, 24 Apr 2020 11:01:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:cc:subject:in-reply-to:message-id :date:mime-version; bh=OfW52KrUtIqZKdFjVx3698mOghF//JGC9XrI7ADTd30=; b=J31KwbqA+BBkwn9Rdyzh/1RakcRb/dhN3C0XOccl6fRRJwRR86YAdzteGuo84RFuKW LtuOFDf3yYzZo0Dw5QdGOf8Qx1LZTsfm+AwL7MA0YA5IZ57HLU2PHEvxB6Q0RwEgCiBk dWC1zN8/2wfZ+Z1ejJByjGogZc4Ztk6nchXcUgKi05ITQgn6KyHDR8rlfcdqyaQPTct0 OHjUSiVkD5thKpRntZFy6lRVtzc0GhaQqwuZzHfZfd0OJLgi44GvC2N1SYIhN53obJcf ++w+78uXYknHwIm68Z26rq2f1t53IkZmOMB9wru7O2unUqCn85pvQ7nF1yBLvqeMdcdX AcRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:message-id:date:mime-version; bh=OfW52KrUtIqZKdFjVx3698mOghF//JGC9XrI7ADTd30=; b=Y6QYICwVaKYIFklWERO1SIaABeOV2Vgnqk/9qH/9VHVsooZ31J+hc2k4EKAmy5LTBk nXw7g7g2UA1xY/zwTq7bnn68t7UqU87RczVq6gn4KvhmbhSoZETQKxfIXAKEbEbtJ+Sz gTUW8ZgwgjrYhjMNg0AThYsA7Uh+Rk7FutDNk9DOZJccw95AOq4cMMPR5zMLcQtAXQqE kRBaXS59XwX1p6wr+cVB/wC0vp5A9Yxqg3UjieH+fK3TkZU6xngkf+KtLAIH5BWCON7l W9KHDX/bD73NY7OCO3RGdQuGq1K1dX13Y6JqbSGi3IcAxIYRFywfSI5VGWWXAsydyi1z jsSg== X-Gm-Message-State: AGi0PuYL77Kbuo3OV+KTUAICX4thNV9CqlLvCziIKT0DExLQq25BeW7b cGU5rs4z2eCjKMmF9+cxTJRiQQTW X-Google-Smtp-Source: APiQypIJCkRtjXaoGS7BGSWhAv5Xn4WasFmeb0dhLrLqzUte6R42DTRsZqi1GrFmjP49BJFM6FQ/NQ== X-Received: by 2002:ac8:690c:: with SMTP id e12mr10823788qtr.357.1587751263560; Fri, 24 Apr 2020 11:01:03 -0700 (PDT) Received: from arch ([2601:8b:c300:1024:a8ca:869c:245a:8f19]) by smtp.gmail.com with ESMTPSA id t15sm4557760qtc.64.2020.04.24.11.01.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 11:01:02 -0700 (PDT) References: <87wo66t8i7.fsf@gmail.com> <87y2qlgq33.fsf@nicolasgoaziou.fr> User-agent: mu4e 1.3.10; emacs 28.0.50 From: No Wayman To: Nicolas Goaziou Subject: Re: [RFC] DOCT: Declarative Org Capture Templates In-reply-to: <87y2qlgq33.fsf@nicolasgoaziou.fr> Message-ID: <87d07wkbkz.fsf@gmail.com> Date: Fri, 24 Apr 2020 14:01:01 -0400 MIME-Version: 1.0 Content-Type: text/plain; format=flowed Received-SPF: pass client-ip=2607:f8b0:4864:20::82f; envelope-from=iarchivedmywholelife@gmail.com; helo=mail-qt1-x82f.google.com X-detected-operating-system: by eggs.gnu.org: Error: [-] PROGRAM ABORT : Malformed IPv6 address (bad octet value). Location : parse_addr6(), p0f-client.c:67 X-Received-From: 2607:f8b0:4864:20::82f X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 X-Spam-Score: -1.81 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=J31KwbqA; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Scan-Result: default: False [-1.81 / 13.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; GENERIC_REPUTATION(0.00)[-0.56121412585655]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:209.51.188.0/24:c]; FREEMAIL_FROM(0.00)[gmail.com]; DWL_DNSWL_BLOCKED(0.00)[209.51.188.17:from]; IP_REPUTATION_HAM(0.00)[asn: 22989(0.21), country: US(-0.00), ip: 209.51.188.17(-0.56)]; DKIM_TRACE(0.00)[gmail.com:+]; RCPT_COUNT_TWO(0.00)[2]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; MX_GOOD(-0.50)[cached: eggs.gnu.org]; MAILLIST(-0.20)[mailman]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_IN_DNSWL_LOW(-0.10)[209.51.188.17:from]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; TAGGED_FROM(0.00)[larch=yhetil.org]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; FROM_NEQ_ENVFROM(0.00)[iarchivedmywholelife@gmail.com,emacs-orgmode-bounces@gnu.org]; FROM_HAS_DN(0.00)[]; ASN(0.00)[asn:22989, ipnet:209.51.188.0/24, country:US]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[emacs-orgmode@gnu.org]; HAS_LIST_UNSUB(-0.01)[]; URIBL_BLOCKED(0.00)[nicolasgoaziou.fr:email]; RCVD_COUNT_SEVEN(0.00)[7]; FORGED_SENDER_MAILLIST(0.00)[] X-TUID: 7fd0kqipASNM Nicolas Goaziou writes: > Hello, > > No Wayman writes: > >> * [RFC] DOCT: Declarative Org Capture Templates > > Thank you for your work. Thank you for taking the time to respond. > Disclaimer: I am only using very basic capture templates. So, I > cannot > comment realistically on the new syntax you suggest. In > particular, the > example you give is way too complex for me to understand the > benefits of > your syntax. I suggest to start out with showing simple > use-cases. Apologies, it's hard to strike a balance between showing something practical and over-writing. > - Is it compatible with the current syntax? If it isn't, is > there a way > to ease transition to the new syntax? My package translates DOCT's syntax into the current syntax. I have written a separate package that does basic translation from the current syntax to DOCT's as well. It is not optimal yet, but does work for simple cases. There are a few features of DOCT (property inheritance, management of hooks/contexts) that make it more difficult than just a syntax swap. I could come up with something more fully featured, but in my experience thus far, it does not take long to translate from one syntax to the other manually. > - Is it simple to use on simple use-cases? I would say so. There is a single function that does the translation. For example: (doct '("Example" :keys "e" :file "")) Returns: (("e" "Example" entry (file "") nil :doct (:doct-name "Example" :keys "e" :file ""))) Part of my frustration of writing templates was always having to look up the structure of the template list. Keys, description, type, target (with its variations) and template-string (with its variations) is a lot to remember. Whereas, with: (doct '("Example" :keys "e" :file "")) I need only remember that the description comes first. The keywords are more self-describing as well. There's an inherent complexity to the flexibility that org-capture offers, but this makes templates easier to write/read. > - Is it more capable than the current syntax, i.e., does it > handle > situations that are not possible, even in a convoluted way, > currently? >> - DOCT validates templates before runtime execution. >> >> For exmaple, you have a template with an entry type of `'entry' >> and you forget the leading star in the template string. >> Days later you go to use that template. It's borked. > > This is different from introducing a new syntax for capture > templates. > > Actually, `org-insert-place-item' and > `org-capture-place-table-line' > both try to fix misshaped templates already. OTOH > `org-capture-place-entry' merely calls `org-capture-verify-tree' > on the > template, i.e., it barfs if the template is ill-defined. It is > a discrepancy we could fix independently on your new syntax. > > I invite you to propose a patch for `org-capture-place-entry' so > it does > a better job at fixing the initial template, if needed. I'll > gladly > apply it. `org-capture-place-entry' is run after `org-capture' is invoked, so while I agree a patch could improve the error, the user still hits that error when they are using their capture template (defeating the point of org-capture letting you take a quick note without losing your current context). DOCT checks while converting declarations to templates, so the error is thrown before org-capture is used (almost like linting for templates). Aside from that, most of what DOCT does is sugar for common use patterns I've observed in others' org-capture-templates. For example, adding per-declaration hooks: Without DOCT: ;;rest of template configured elsewhere... ;;make sure you update this if you ever change the key for this template! (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.