From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id iA67HLnYZGJzNAEAbAwnHQ (envelope-from ) for ; Sun, 24 Apr 2022 06:57:29 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id cDa1HLnYZGI2DQAA9RJhRA (envelope-from ) for ; Sun, 24 Apr 2022 06:57:29 +0200 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 08090EAB0 for ; Sun, 24 Apr 2022 06:57:28 +0200 (CEST) Received: from localhost ([::1]:57450 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1niUJL-0002q6-E6 for larch@yhetil.org; Sun, 24 Apr 2022 00:57:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53018) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1niUIX-0002px-FM for emacs-orgmode@gnu.org; Sun, 24 Apr 2022 00:56:37 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:33443) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1niUIV-0000RD-Pu for emacs-orgmode@gnu.org; Sun, 24 Apr 2022 00:56:37 -0400 Received: by mail-pl1-x62a.google.com with SMTP id c23so19898843plo.0 for ; Sat, 23 Apr 2022 21:56:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=5WmX3NARmPzilbvI576vVy42sAAEpMUYn0HOicqs/i0=; b=EGYPnvFdKlC1pFkGBzrh8RTMd+RX8hIU7k5b9F/8IGNtUayHm3LFk8iXsSG5CPRH2t 1AjBN6Mf3/+j6k3qKCMJpN3vS/3hqmiaL8aZQC0lj+MorfI5TWYAvucrq6eMM0CmWW/l GkOhEjzzpSGWzrf0MmnkPISQhe0T34z6qa5y9r4N5rKT/R0ubAYp/ZwYklYmnrkF2EP+ 8AkXCk+CilqaG50qkQBJ1GlBorXVkdE4nBivhcdr+aw5J4eciFcJgLKREX1XY4YugCyj z0K8ZgKEcOTjdOLzA8Zjup1d/WG8NasFPEnDyQGManfwnoqYl82kw9ZTDBekcUdPZYKF 0OnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=5WmX3NARmPzilbvI576vVy42sAAEpMUYn0HOicqs/i0=; b=7UP3nWcm6XK3Lz1v8/yOVKmmFZ1Qd+nrfY/KuOQBkmnPo3D140moC32SqQ9A7Vo6X1 oW7gqBuRFtInMAdomihaXefH4wMb+nEpB2h+R9xuslpJWezeUUWjceKpyxu6YWRrjEgn JDtqY6Czc3OKZsTqWpGyuU0r8OJDXMxsC91Q4GyZPrn9MNoiFqVUHGG2IX5kVWeuhWP3 bshNPwTSfljL8tROQRON3gNi8MmbcDSpVx+BLxfI9jefPqa6meUBEvjx6Y0EFr2WejSv 6IQfSzDHRD+E6zJY5D8FcjPpy/zSkLoVBew01U54S8QZSZpAFXLLqqKCh3iams1Gryxq xTwQ== X-Gm-Message-State: AOAM533aG9uxh5HuZ8H1uoxJK1L6qLw2/IKgradfuLFkSrT5QNvnHpVh Uu9SatgzW2CRC9afBg1cPT0= X-Google-Smtp-Source: ABdhPJyqOs/Si7VJzwxAEEpu8w0ObNU9nRieUNnkw7HgvpPC/qhrtjhyoXTNlLIXLeN6rH0g0OWWSg== X-Received: by 2002:a17:90a:9a3:b0:1d8:cca1:6f47 with SMTP id 32-20020a17090a09a300b001d8cca16f47mr9659594pjo.220.1650776193974; Sat, 23 Apr 2022 21:56:33 -0700 (PDT) Received: from localhost ([50.7.251.66]) by smtp.gmail.com with ESMTPSA id 19-20020aa79113000000b00505d5d15d80sm7360223pfh.14.2022.04.23.21.56.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Apr 2022 21:56:33 -0700 (PDT) From: Ihor Radchenko To: Valentin Herrmann Subject: Re: [PATCH] lisp/org-capture.el: Add hook & hook options to org-capture In-Reply-To: <20220206140551.1263130-1-herr.valentin.mann@gmail.com> References: <20220206140551.1263130-1-herr.valentin.mann@gmail.com> Date: Sun, 24 Apr 2022 12:57:23 +0800 Message-ID: <87fsm313kc.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=yantar92@gmail.com; helo=mail-pl1-x62a.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 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-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1650776249; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=5WmX3NARmPzilbvI576vVy42sAAEpMUYn0HOicqs/i0=; b=FuFESinHFE+oxxtFs1/BDVZfY4uq1n4lduUmvtpBDBx3FJv5CtTyXXo0q+THMH1Ft3kTuW SoiE1pzIXh0FRxRa0tpAs3K+3694paE0CZkFhBISg/TbR7ZvKneVTvtyB96VnZqn6ZrlSq 3J7FdFBjHsH9weyzf3vaIHaDCrvvZxtMC0clpPvlfIXv4dvt4oIR4ar/zDPK3FXngubM8d OC+2/NAebj3R7YJXJfJ6x9x8r9NNcgsDAQibs+o8J2OoiFvWb8W3GZium78Z/4gpjaLID2 B44z4qI+l5S2hsVBlqozdJTghjT6ltGjsnFvovUDUuEVEXUjRQbcnaqNpVJipg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1650776249; a=rsa-sha256; cv=none; b=CAvDDQkUFDHl5f+I4yUcmC+/aZyKdDRGiQRWDHO1ezDxfHRiTgVZ6yO2C8FoGdzKxrP4oo +sIM67Gu0aGsCpK6FYlDXb2rX9ZcamMTEPDhruNqu4NbXaOBTZDNDad1kop+JKosTOiEwL d6br3Hxe6qedgGDAlQWSgdf2jMrhXkqKvlC3UUB3D1llCRA7So3xhDHm7t10QMf3h76kvV tNNrVYbJdLfmBBLjuJAWwlVthjoPRvYYPDMW51AL5pyOHUG+BmPSmKrt/fM9fsNehzA93d koCYWJs/MHMMwpyEJijx+MuFp3RKd5rIjpsIFD3jJswOXQ+xzqtGxaQPXC4jzw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=EGYPnvFd; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.51 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=EGYPnvFd; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 08090EAB0 X-Spam-Score: -3.51 X-Migadu-Scanner: scn1.migadu.com X-TUID: CBJuFpS4txkG Valentin Herrmann writes: > * lisp/org-capture.el: > (org-capture-templates): Document the new template options. > (org-capture-before-view-hook): Add new hook for parity with the > template options. > (org-capture): Implement the new template options. > (org-capture-finalize): Implement the new template options. > (org-capture-kill): Remove unneeded line. > * doc/org-manual.org (Template elements): Document the new template options > This change comes from my personal config, where I use e.g. the option > `:before-finalize-hook' to capture an task automatically, whenever I > capture using a certain template. Thanks! This addition looks reasonable. > + (if-let ((bvh (org-capture-get :before-view-hook))) > + (funcall bvh)) > ... > + (when-let ((pfh (org-capture-get :prepare-finalize-hook))) > + (funcall pfh)) > ... > + (when-let ((bfh (org-capture-get :before-finalize-hook))) > + (funcall bfh)))) > ... > + (when-let ((afh (org-capture-get :after-finalize-hook))) > + (funcall afh)) You should use run-hooks, not funcall. Hook must be a list of functions, not a single function. By definition. Also, do not use if-let/when-let. They are not loaded by default in Emacs 26, which is still supported. > - (run-hooks 'org-capture-before-finalize-hook)) > + (unless org-note-abort > + (run-hooks 'org-capture-before-finalize-hook) > ... > - (let ((org-note-abort t) > - (org-capture-before-finalize-hook nil)) > + (let ((org-note-abort t)) > (org-capture-finalize))) > (org-capture-finalize): Implement the new template options. > (org-capture-kill): Remove unneeded line. This change looks reasonable, but please document the rationale better in the commit message. The current message is not clear. Best, Ihor