From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id gF63LWWiP2YM0QAAe85BDQ:P1 (envelope-from ) for ; Sat, 11 May 2024 18:52:53 +0200 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id gF63LWWiP2YM0QAAe85BDQ (envelope-from ) for ; Sat, 11 May 2024 18:52:53 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=DqbPaZxV; 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=posteo.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1715446373; 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=BpG0zH3/3j7Akkj/2BT1AOca01ulX8vg2x4BxsuapEQ=; b=DaPaqnt0iB67/7dgp0Qf68+n8IDWVtTaoiUY//764EkOMR6AArr9PYTrh40WlQBAyxFc0k S5AIfhvUPSVDb8AxTa4yhhVvS/si8NTY3HASZgYqb8bAJfnJwfzp7LtINQsEwpR5/STZzt VUjKLBJiXVLOAx1rbqSKrAWIfFiuuvPSA3bSNeNiibDIrruMW5CLAxBq8cGC6tN44vMaes nagddmXCp0lqIb1kQYHLtSHGrLEPmHAZy7tN8j2v+1mqM1JGrZ+qJPmHw+tKSLnMZjfI6x PzwL0bG1ZbdqIhbVAfZrgz4jfy0mJbD3wsyxefIN1emN1hzzkSCS5VRfjdaiug== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=DqbPaZxV; 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=posteo.net ARC-Seal: i=1; s=key1; d=yhetil.org; t=1715446373; a=rsa-sha256; cv=none; b=LwT/wPlN6ns8rJPkIJ4DNBtyn9rj77CX2hxG4Xgu+QVQU4LLTUVuhpbKZ1Md3IjwESlpuF iiF5/ZHifc8KjjOs5O04OUIWGPcR1eLUUWoqMxGZx5LyPBxpq/ansf0pNYzRWK/scQnNyB hQQriyQqfk+3d0CKVUb9YS+IlbfA3OBZbZFmgLQqkbcXSYauWXf4fPQ4bzri/26qmmTkZs KSwIqvvHdgFMwGfHNRbGgQdkm0F40yhHiqueJZPFiZgEc0F9EUGv5yzCivcvIkxwmzqfAy Gi76a5wG+6qhtBq5DnS53J70NXoNw8AzZfAcPe2UMY+cq5HFjUq/Lp8L1G/aFg== 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 9208B508C3 for ; Sat, 11 May 2024 18:52:53 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s5px5-0007x2-RP; Sat, 11 May 2024 12:52:03 -0400 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 1s5px2-0007wk-RD for emacs-orgmode@gnu.org; Sat, 11 May 2024 12:52:01 -0400 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s5pwt-0002LY-9x for emacs-orgmode@gnu.org; Sat, 11 May 2024 12:52:00 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 08A01240101 for ; Sat, 11 May 2024 18:51:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1715446308; bh=xXJJp+nVFhGsDwqzLs86LOvrn7rTrRWVHdZKrXUM+zA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=DqbPaZxVsQGDhEFLQFX3vi5P8g2qLROlshIcMOUjZcUXekEI1l50Q0mGRSwiFHS0a mfaFYVF45CPE3JxLHTdB1cosTxs7G7i9tgRLnVMhCqeWi9E+GvnmGvxkIORKET51BH 2I+ZVnxzqDy+eHKMUJ7Om0kh0SOAgrjaLVTZh9p5fTgVFvBlR3LNOjPjKYnjAs+BYv uG2rlUZ2dMI1eG6UTpSB1JMGpj8gO5e+B/+JMdhQaPQD1DDogXJO9jt3m058yv8lLe fIiwCb7/qF2e2sPFOLtu/Nukf4M/2R2HS70Q/4mZItnabdq/fHT68POti0Bjd1R7rB J5K0nTOmiK9fQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4VcBc30x7Dz9rxB; Sat, 11 May 2024 18:51:46 +0200 (CEST) From: Ihor Radchenko To: Joris Caravati Cc: Emacs org-mode Subject: Re: [PATCH] Add org-after-note-stored-hook In-Reply-To: References: Date: Sat, 11 May 2024 16:53:16 +0000 Message-ID: <8734qouw77.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=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: , 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: -9.60 X-Spam-Score: -9.60 X-Migadu-Queue-Id: 9208B508C3 X-Migadu-Scanner: mx13.migadu.com X-TUID: OUjBzAjvIw1A Joris Caravati via "General discussions about Org-mode." writes: > 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. An easier way would be forcing note earlier by calling `org-add-log-note' from your hook. Although, removing heading from inside `org-after-todo-state-change-hook' is a bad idea - Org mode does not expect the heading to disappear from under the cursor when this hook is executed. I recommend using `org-trigger-hook' instead. So, your patch does not seem necessary to achieve what you want. That said, it does make sense to add a hook after storing a log note, but not at the very end, when point may not be at the note stored: > (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)) This will leave point in buffer where the note was invoked. For example, in agenda buffer. I doubt that the users of this hook will expect such a thing. It will probably be better to run such new hooks right before (message "Note stored") in `org-store-log-note'. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at