From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:700:3204::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id edxqCH+PlGUvxwAAkFu2QA (envelope-from ) for ; Tue, 02 Jan 2024 23:34:39 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id 8PztAX+PlGUL0gAAe85BDQ (envelope-from ) for ; Tue, 02 Jan 2024 23:34:39 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=none; 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"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1704234878; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=4raoULbwC9S9FdWWoOA+mIQN4VWzMKhyzrfu4TDfNFw=; b=rgAYVMvaukrGI4CfTeLKRUmwtY9i5s5YJKcG9bJeONX2ExbP6CrXHUAzKWKxEb4rkr7cdA cdm4hIGodFsSJGBdeBgd+IFMifbdh+QAGIP1PZ2ArfsmeRAjvEXiPq6gGnQnpQ6a0Rlr6E qfjWLkPkuDXeQ1c7fwO5RbubFlaVGe0On4l4+gNQOy6otfyqNaiHQsZeX9A8sPciASW+L6 RuW3fQn3ZvUfyzr9b8LvoQhe7zu8Oh4eWz7TDJ4NVg0vZaHMqLN1PHXmuWmxludV8PwlPk nLR4Qxwqcat0igcWh/oKb3ez/J3OQEfrvai/aJw2h26Z+m5vfSFj+BIgqFqk1w== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1704234878; a=rsa-sha256; cv=none; b=rUPcxL/3C4OXphnDKdoYJ/WO3HAJDIkGnl8QLoJbbsWELfkT9Wi3red+jUtASXLDo7tleu t0cCA6K+UVI4lyYULn/CJbYlot5Rx+0xRQpzBAM8Sc6ZGzwWOeYCAzNIStdM+DwPJkrf49 UOV9swT2QyGhVgHTmzN+RAA8unne/pEGx+H+mztuOPMU84ZrF4D6fnX0jGm8KBQ3JL4O9w GDT8G3m4XLpDXVdUSQv3RYKQUaKJ604tjn23Q+mmG+8uIg4wrdlVmNCN2H3nXPErYHc+7P wnSm0k2fJzDKBNkmrmlJe0GfwXSLYPoAPI7xGLIOEhxhop2MAZ6Ur3Xe2AMyFQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; 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"; dmarc=pass (policy=none) header.from=gnu.org 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 D306A18059 for ; Tue, 2 Jan 2024 23:34:38 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKnKW-0007lN-Lj; Tue, 02 Jan 2024 17:33:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rKnKV-0007l8-2L for emacs-orgmode@gnu.org; Tue, 02 Jan 2024 17:33:47 -0500 Received: from 62-210-209-184.rev.poneytelecom.eu ([62.210.209.184] helo=sula.io) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rKnKT-0005XF-CQ for emacs-orgmode@gnu.org; Tue, 02 Jan 2024 17:33:46 -0500 Received: from localhost (anancy-653-1-9-249.w92-138.abo.wanadoo.fr [92.138.227.249]) by sula.io (Postfix) with ESMTPSA id 47F575D41C65 for ; Tue, 2 Jan 2024 23:25:59 +0100 (CET) User-agent: mu4e 1.10.8; emacs 29.1 To: Emacs org-mode Subject: [PATCH] Add org-after-note-stored-hook Date: Tue, 02 Jan 2024 23:13:06 +0100 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=62.210.209.184; envelope-from=tyx+org@sula.io; helo=sula.io X-Spam_score_int: -8 X-Spam_score: -0.9 X-Spam_bar: / X-Spam_report: (-0.9 / 5.0 requ) BAYES_00=-1.9, RDNS_DYNAMIC=0.982, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, TVD_RCVD_IP=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: , Reply-to: Joris Caravati From: Joris Caravati via "General discussions about Org-mode." Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -6.78 X-Spam-Score: -6.78 X-Migadu-Queue-Id: D306A18059 X-Migadu-Scanner: mx12.migadu.com X-TUID: Nb/B4GzyHIOp --=-=-= Content-Type: text/plain Hello, I've been archiving tasks automatically using `org-after-todo-state-change-hook' but I've been recently bit with a note (entering a todo state configured with '@') being placed where the task was before its archival. This patch aims to offer a way to defer the archival after the note is stored. Actually, I am using it like this: #+begin_src elisp (add-to-list 'org-after-todo-state-change-hook (lambda () ;; States configured without mandatory note (when (member org-state '("DONE")) (my/org-roam-archive-to-today)) ;; States configured with mandatory note (when (member org-state '("CANCELLED" "READ")) (add-to-list 'org-after-note-stored-hook 'my/org-roam-archive-to-today)))) #+end_src With `my/org-roam-archive-to-today' removing itself from `org-after-note-stored-hook'. Hopefully I did not miss an existing way to do this. Regards, Joris --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-org-after-note-stored-hook.patch >From 18de09a3aa08e3d06f180165530cbaeeccdf3ccf Mon Sep 17 00:00:00 2001 From: Joris Caravati Date: Tue, 2 Jan 2024 22:50:32 +0100 Subject: [PATCH] lisp/org.el: Add `org-after-note-stored-hook' * lisp/org.el: Add `org-after-note-stored-hook' which is called at the end of the `org-store-log-note' function. * etc/ORG-NEWS: Document the new hook. This change allows customization after a note is taken. One case where it is useful is when one wants to move a task after a state change but cannot do so in `org-after-todo-state-change' because the new state is configured to take a note (with '@' in `org-todo-keywords'). Setting this hook in `org-after-todo-state-change' allows to defer the move after the note is taken and prevents the note to be placed where the task was before being moved. TINYCHANGE --- etc/ORG-NEWS | 4 ++++ lisp/org.el | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index c54473f55..911e8ffeb 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -742,6 +742,10 @@ Completion is enabled for links to man pages added using ~org-insert-link~: =C-c C-l man RET emacscl TAB= to get =emacsclient=. Of course, the ~ol-man~ library should be loaded first. +*** New hook [[doc::org-after-note-stored-hook][org-after-note-stored-hook]] + +This new hook runs when a note has been stored. + ** New functions and changes in function arguments *** ~org-fold-hide-drawer-all~ is now interactive diff --git a/lisp/org.el b/lisp/org.el index 6e6e075b4..fad21d8ba 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -1944,6 +1944,9 @@ Lisp variable `org-state'." :group 'org-todo :type 'hook) +(defcustom org-after-note-stored-hook nil + "Hook which is run after a note was stored") + (defvar org-blocker-hook nil "Hook for functions that are allowed to block a state change. @@ -10729,7 +10732,8 @@ items are State notes." (with-current-buffer (marker-buffer org-log-note-return-to) (goto-char org-log-note-return-to)) (move-marker org-log-note-return-to nil) - (when org-log-post-message (message "%s" org-log-post-message))) + (when org-log-post-message (message "%s" org-log-post-message)) + (run-hooks 'org-after-note-stored-hook)) (defun org-remove-empty-drawer-at (pos) "Remove an empty drawer at position POS. -- 2.38.5 --=-=-=--