From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id mPxIO/TIAmK+gAAAgWs5BA (envelope-from ) for ; Tue, 08 Feb 2022 20:48:04 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id yIAyNPTIAmIESwAAG6o9tA (envelope-from ) for ; Tue, 08 Feb 2022 20:48:04 +0100 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 4FC9636CF4 for ; Tue, 8 Feb 2022 20:48:04 +0100 (CET) Received: from localhost ([::1]:52838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHWT4-0003Nk-Gq for larch@yhetil.org; Tue, 08 Feb 2022 14:48:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60500) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHWKD-00043i-Gh; Tue, 08 Feb 2022 14:38:54 -0500 Received: from [2607:f8b0:4864:20::934] (port=41869 helo=mail-ua1-x934.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nHWJu-000159-4U; Tue, 08 Feb 2022 14:38:36 -0500 Received: by mail-ua1-x934.google.com with SMTP id w18so148532uar.8; Tue, 08 Feb 2022 11:38:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=references:user-agent:from:to:cc:subject:date:in-reply-to :message-id:mime-version; bh=21HNP0JUylU9TINicRCEY2hzNKsfGR73NEl3A/Z66No=; b=eeIwiySSHXWMrP5RfJDBqt73JF0XK44ojiDfwDNCjRH8SHOGCpxK9Ra3CqLaBmRNU4 m9oGTx3ifiKkgfgWpuaHcRGa8gsr/OaM3gCtETYqjbMiyK5L3ZZMzj1CpbKrGVe0BYyt J9MczoBEuJk1xzNzT7Z/fZb88AQnKIPVTdhNQtOvAC1Isds882LB52hVqaFAR9Dnv5Wk Ds5njswOc1bHtV9z1JzRnbx/fj4HgEVvXHGI3Q+SELEQEKUSAbJSWXB7c3ojWC2KwDmB cu8LQJxfL+FuR04ov2wy0j3eSTqf6flPxVoH7HPK38DbTehq4rzz/tZLwobHU0VVpc+s WIbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:references:user-agent:from:to:cc:subject:date :in-reply-to:message-id:mime-version; bh=21HNP0JUylU9TINicRCEY2hzNKsfGR73NEl3A/Z66No=; b=y1LEUHkzzf94QrdDen111s0CuV77/ZhO/w/5GA4Oj0VNSiDBIBTYNA+J8dx37uM7Rr 18EtXSjQZinhhg8HBudNVY7043i79lWRUF9KoYBdM9vcrzbY7XH5c8/6XoiGW+vyIeJI rAch6uV/8b/IGJPWXr6DZBcUioTvbCyel512TsbiW91SI8B25vlriNGQX0q7+gUeubvd kpRGwneECuHGoc2qpMYDU5h9MnYU6vHrFryXXoZQPYHG6hhS7M4b7vTxqJHu0f8qnsQN Ftkm9TypE4DRnjbo0YaJsylONA26RDmB5A6QAHztlj6+87FW5mFLSIa+QO4N+RedPs3L BaWw== X-Gm-Message-State: AOAM530mMXkhPJ+9TN1oF1QNy9gGCu2lb/9GUKXkbPd/Aq+LK9QNkS3D kkikqp11JCCxsryFoFg7VenoRm+gzkw= X-Google-Smtp-Source: ABdhPJyCZF7AmhuzGnLjowljEvTCARcZb3EkjLcCjM8Xb/mvkyvsT771oWSSB3gGzcLfckgr3Hfk6w== X-Received: by 2002:ab0:5e9f:: with SMTP id y31mr2159487uag.64.1644349110805; Tue, 08 Feb 2022 11:38:30 -0800 (PST) Received: from arch ([2601:82:c200:166d:afae:ebe6:a0e2:409e]) by smtp.gmail.com with ESMTPSA id 187sm2822713vsi.12.2022.02.08.11.38.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 11:38:30 -0800 (PST) References: User-agent: mu4e 1.7.5; emacs 29.0.50 From: No Wayman To: emacs-orgmode@gnu.org Cc: emacs-orgmode-request@gnu.org Subject: Re: [PATCH] lisp/org-capture.el: Add hook & hook options to org-capture (Valentin Herrmann) Date: Tue, 08 Feb 2022 14:02:25 -0500 In-reply-to: Message-ID: <87a6f1no7e.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; format=flowed X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::934 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::934; envelope-from=iarchivedmywholelife@gmail.com; helo=mail-ua1-x934.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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_FROM=0.001, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1644349684; 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=21HNP0JUylU9TINicRCEY2hzNKsfGR73NEl3A/Z66No=; b=TTb7LcHxcAiqtyfZc8CJ3sBYfAj59rLsnRTgbhKRbTjn1QZzAolKR3FusFlq3aV1PaC65H x8eLwUP8BHHiKBs36jmFtiOzawuhe8B5fB11aH+vf6Y821JL9EguhMmSz6WrH71Gkl/2Ei RRaarAbZaM6WBlOqeAri0mh8Tl0myUrKLCjtWN5VHe4Ko1DhYMFlvnMgOnKhaNSkBov0Df 0NvubE5XoipWIVksgkD9NEkzuYdsvHq2TKipJ96jYhw3CvM9R6xzQ8DGHj9O1IgJ3+XOla r9ApLxiOKZjyDRHrNQAyOZoWX9hcLXKNAybHtKuDn+0mAw6Cl6+Wpbfu4aw9mg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1644349684; a=rsa-sha256; cv=none; b=GAWVL2SAkyTuaoFPNmlzlg0wHzyrb/mmF8evrvUi+JmLr0E84j7GqdKOPJq/m0W36GlAFC OhXWVtY8y4roo2INSAHhsjNk56BVGJVMdhpOs7qMKZP5BxKiIcdL8Ou8AgxEYUqWseMlPc LbewEeIViXTFihpwWDFl9r8FD++Tw7DxU3xAavMSD01jRhAxFaUY/vtA773FrrRT6+0zYV /Wl5c2/y5Er8QKBmE7mMtVYUA3c3woCx4YypC4WvF6u1vObK2myuoDxw9alx9tAFWgb//p JHBIU9grhiUiYfbvI1Y4EF4dOkCmOsToe4UsTmRKNlgjvC/L5AT13VD4hHWFUQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=eeIwiySS; 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: -4.33 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=eeIwiySS; 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: 4FC9636CF4 X-Spam-Score: -4.33 X-Migadu-Scanner: scn1.migadu.com X-TUID: 30zIF43nw4I9 I've implemented what you're proposing here (and much more) in a package you may find useful a couple years ago. I pitched adopting some of the ideas into org-mode proper and was willing to do the work. My proposal was met with enthusiastic silence: https://www.github.com/progfolio/doct > - :prepend Normally newly captured information will > be appended at > - the target location (last child, last > table line, > - last list item...). Setting this property > will > - change that. > + :prepend Normally newly captured information > will be appended at > + the target location (last child, last > table line, > + last list item...). Setting this > property will > + change that. Are the white space changes to unrelated properties necessary? > +(defcustom org-capture-before-view-hook nil > + "Hook that is run right after the capture buffer is made > current. > +The buffer is still narrowed." > + :group 'org-capture > + :version "28.1" > + :type 'hook) > + This functionality is already provided by `org-capture-mode-hook'. Instead of introducing another hook, that can be utilized. An illustration using doct's :hook keyword which runs functions during org-capture-mode-hook: Yodel[1] Report 2022-02-08 14:16:58 =================================== --8<---------------cut here---------------start------------->8--- (yodel :save "org-capture-mode-hook-example" :packages* doct :post* (require 'org-capture) (require 'doct) (let ((org-capture-templates (doct `("test" :keys "t" :file "/tmp/test.org" :template "* test" :immediate-finish t :hook (lambda nil (message "%S narrowed?: %S" (current-buffer) (buffer-narrowed-p))))))) (org-capture nil "t"))) --8<---------------cut here---------------end--------------->8--- STDOUT ====== > Loading > /tmp/org-capture-mode-hook-example/straight-bootstrap-snippet.el > (source)... > Clipboard pasted as level 1 subtree > # narrowed?: t Environment =========== - emacs version: GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.31, cairo version 1.17.4) of 2022-01-13 - system type: gnu/linux Packages ======== - doct https://github.com/progfolio/doct/commit/9ed9b8c7f7e2ea2d2fb739d65ae4626a1cf16b9f [1] https://www.github.com/progfolio/yodel > + > + (run-hooks 'org-capture-before-view-hook) > + (if-let ((bvh (org-capture-get :before-view-hook))) > + (funcall bvh)) This pattern implies that functions added via template keywords will be run after the equivalent global hooks. That should be documented. This pattern could be improved by let-binding each hook and adding the templates functions. e.g. >(let ((org-capture-mode-hook > (append org-capture-mode-hook (org-capture-get :hook t)))) > (run-hooks 'org-capture-mode-hook)) Note the use of the non-nil LOCAL argument in org-capture-get. You want to ensure you're accessing the correct plist in the case of overlapping capture processes. > ;; FIXME: This does not do the right thing, we need to remove > the > ;; new stuff by hand it is easy: undo, then kill the buffer > - (let ((org-note-abort t) > - (org-capture-before-finalize-hook nil)) > + (let ((org-note-abort t)) > (org-capture-finalize))) > > (defun org-capture-goto-last-stored () Why was org-capture-before-finalize-hook bound to nil here and what is the reason for changing that?