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 mHoBBUeQSGZGagEAe85BDQ:P1 (envelope-from ) for ; Sat, 18 May 2024 13:25:59 +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 mHoBBUeQSGZGagEAe85BDQ (envelope-from ) for ; Sat, 18 May 2024 13:25:59 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=lRz5x0yc; 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=1716031559; 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=KtfTPu0AecDywcXZDSzexwxoa6rZoNcLJbS6rpALlKY=; b=NJvVaso7sRx+PKw5tF5qfZBXicXKjD4hS8NB/DmfNPiJ2qnvEfX+gMBsZOII1sBKRMwk89 yKzYOE81WlMQwsLwO/UM5huBl30ioKJQBnG9BsdK5u/kNhtmicUG4GjCx0B80B8D24zDrY 8S1gJ/qHKJmeb1o6Mxy8FYY/k3k3HvHSe9v/VjSzEyb0/Uk6HFmAJa8zXd7CHU0GO6l9cL J3/b0l053olBB4tloSKKIs6dbIMWMh35xavVZBjc9awSJHI1eymkoVz4nQqKM21tA6opkI oDuuPVbJ//GWDSKrvLvsu2Z1JXHxE1gftxN9XmI1gJQW0H2v//WXFOqbBgkycw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=lRz5x0yc; 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=1716031559; a=rsa-sha256; cv=none; b=OQFRYBHKQWnEbUnf6yipfgaYomRJPV45V/z6u/B7lLC5j5TNdU7FvjdytoPliSY0QW8kld ivZDEEstarVNRoxZt3kphDyN7zEUEIxqslAPXt/ux4m8UKn77UMI3t+GRvRhjQ5JwIYkyj WBV8MVSaSLcgNT9qU4sg4j2kxJDJxHKWgbFDre4D+i9tFwsTiwmTE3As+C5AE+G1j82LsX xcDU1jzjgs/RdM5tdFXCnwlpLK3we4q5BKNNjFaZOxSof9nOkuEhCXjDELJ0eQw19G+M0I HffsY+fxtDgQLBCzbDuUuOEeb8pkmBVNM1ghLRl2ZC2XCZU9pLkoBYVPmKU/8Q== 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 A371811CFD for ; Sat, 18 May 2024 13:25:58 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s8IBK-0001n5-N9; Sat, 18 May 2024 07:24:54 -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 1s8IBG-0001kk-2l for emacs-orgmode@gnu.org; Sat, 18 May 2024 07:24:51 -0400 Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s8IBD-0001Gg-JR for emacs-orgmode@gnu.org; Sat, 18 May 2024 07:24:49 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id BD4F1240027 for ; Sat, 18 May 2024 13:24:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1716031482; bh=TG/0rJIHf7QtAgoVuXGoZ/91r2OUkfTSIAMESFoeLLE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=lRz5x0ycd/W+RjRmvrvTlDYB26kXmVBHdQXr5HY1QClberrNrvw8qC4p0UTF0jCSj 6Q1IdndlUMZ2MtgDxvaT5awvU3pro3hyMBCeOIAnSqsmMPB68yrbRe8v8DGHIvgTeL 28p0ObSl7Ip35/LVgUIQecoNnbpP2UZlxNRyBKGQxflRZVP36miMZlV/Q6aFS1nGYS 18h2piRYAxv/2QUn8oyPHjnQdOnzxiZmMrrSkv65yHFKMx9Yfo8+AjbaL7HKsstpp4 ZpmEq1zmhilIFaA4iKxBGuyQ8Gd8SjC7MKCdwuH/RAt0TY/Tm1s748vPRRYzYwG9De JD9FhsNVst8Yw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4VhM1P2tPtz9rxM; Sat, 18 May 2024 13:24:41 +0200 (CEST) From: Ihor Radchenko To: Joris Caravati Cc: emacs-orgmode list Subject: Re: [PATCH] Add org-after-note-stored-hook In-Reply-To: References: <8734qouw77.fsf@localhost> Date: Sat, 18 May 2024 11:26:21 +0000 Message-ID: <87ikzbtl7m.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.65; envelope-from=yantar92@posteo.net; helo=mout01.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_HELO_NONE=0.001, SPF_PASS=-0.001 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.58 X-Spam-Score: -9.58 X-Migadu-Queue-Id: A371811CFD X-Migadu-Scanner: mx13.migadu.com X-TUID: rYw26Bql+fok --=-=-= Content-Type: text/plain Joris Caravati writes: >> An easier way would be forcing note earlier by calling >> `org-add-log-note' from your hook. > > I remember trying that before adding the hook (and I tried again today) > but the problem with adding the note directly is that I only seem to > manage storing the note where the task was before being archived, > eg. with this (or any variants I could think of while making sense of > what note functions do): > > #+begin_src elisp > (when (member (plist-get properties ':to) '("CANCELLED" "READ")) > (org-add-log-note) > (my/org-roam-archive-to-today)) > #+end_src > > which I find logical, since `org-store-log-note' is only called after > =C-c C-c= is pressed, whereas the archival function is called just after > the note buffer is created. So I still struggle to see how I could do > without the hook (maybe if the archival function would return the > position of the task after moving it, but that seems more complicated > than just using the hook). Right. Yet, using a hook is still not ideal - what if you configure todo keywords to not store note at all in future? Then, the hook will never be executed or will be executed at the time you don't expect. Note-taking mechanisms is generally tricky - it is schedule-based, with note being taken after the current command is executed. I think I know how to make it possible for the note to be taken at the right place after subtree archival. May you try the attached patch? --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-org-save-markers-in-region-Store-log-note-marker.patch >From 2e24b634275c61ab913851b11d8b8f053f0f88f0 Mon Sep 17 00:00:00 2001 Message-ID: <2e24b634275c61ab913851b11d8b8f053f0f88f0.1716030861.git.yantar92@posteo.net> From: Ihor Radchenko Date: Sat, 18 May 2024 13:12:50 +0200 Subject: [PATCH] org-save-markers-in-region: Store log note marker * lisp/org.el (org-save-markers-in-region): Store `org-log-note-marker' when storing and reinstalling Org markers. This change automatically handles note taken after refiling/archiving without trying to place the note in place of the moved subtree/heading. Link: https://orgmode.org/list/m2plyjid8q.fsf@kyon.home --- lisp/org.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lisp/org.el b/lisp/org.el index 8d921f11e..bec8a87a4 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -7365,6 +7365,7 @@ (defvar org-markers-to-move nil Those markers are stored together with their positions relative to the start of the region.") +(defvar org-log-note-marker) ; defined later (defun org-save-markers-in-region (beg end) "Check markers in region. If these markers are between BEG and END, record their position relative @@ -7374,6 +7375,7 @@ (defun org-save-markers-in-region (beg end) buffer. After re-insertion, `org-reinstall-markers-in-region' must be called immediately, to move the markers with the entries." (setq org-markers-to-move nil) + (org-check-and-save-marker org-log-note-marker beg end) (when (featurep 'org-clock) (org-clock-save-markers-for-cut-and-paste beg end)) (when (featurep 'org-agenda) -- 2.45.1 --=-=-= Content-Type: text/plain >> It will probably be better to run such new hooks right before (message "Note stored") >> in `org-store-log-note'. > > A patch modified to match the suggested location for the `run-hooks' is > attached. Thanks! Applied, onto main, with amendments. https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=f3e306c73 I added necessary keywords to the defcustom, changed the docstring to state explicitly that the point is at the note taken when running a hook, and changed the NEWS entry to (1) not have a link - we usually do not do it; (2) moved it under appropriate heading. I also removed your example from the commit message as it is not the best illustration (see my considerations above). https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=f3e306c73 You are now listed among Org mode contributors. https://git.sr.ht/~bzg/worg/commit/3093b569 -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at --=-=-=--