From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id MJZcDyVcLGdQXwEAqHPOHw:P1 (envelope-from ) for ; Thu, 07 Nov 2024 06:20:21 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id MJZcDyVcLGdQXwEAqHPOHw (envelope-from ) for ; Thu, 07 Nov 2024 07:20:21 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gnu.org header.s=fencepost-gnu-org header.b=gkhY7fwk; 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=1730960421; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=9yMsVJG7GDaTSILEDFcMkojfzJgShelrcZ0uoSwWShE=; b=VUVoI6itZ/pbCmGoTAQ2Eb7zQ6bhDcTy8NxiqmH1WAcm9at11Hk+FwMsvxXxbMHaIdHLvp cFoYvWGrTL7NL2rmCK2PxgLY+7HaRZAHBO91/HDtYD+I+0CEExMsh+l99DKJktoknY2DNE xE1e7EVUTLu2C8xtRQnu79AUq5bGj5nTJs+HirRNMbWAtQtI0M4/UZkjVsU33skmOS1uhw 5DP5Y9UuxgHuH486PbekFGxtjuBFTqVWHKVkI/ZUFuxR1Rj+FfGxpUJTzARJm2V4BBMY54 J+P5xlyndqbEPRqgDiShF7+FSqCvAFfpDXEfCz6zF2GotEhsvC2p4kA9XIiVAA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1730960421; a=rsa-sha256; cv=none; b=HJ2FY7SZ8aF4wxEDsmvHUNdnHapy8TACvCWhqPmq8miVTyQ5ELs450n8bU5kROCeFGDSLO Tse/qDUcMcRlo3OcDr3y+M3zaVV04TxarqVoV7sg6oYMUTsEsPRrNAElwUxsdMkO9X+zvX rlhLNst8Tl0SerXokSl6gZOSjJbM4sQzunfy0WQyDdsUOBYmttA2pVPC9029lGciZRqxBH 9ZuYlOuTqzQIfEOUF36lDsi86q0grvITqLYZiT3HJwwFntEpsCyNYv09xqgpxRM7SOSihJ nNpE6L/7AZFsA+bCuGkKVezap2h26XVdZUo02v26u+1QeOXSzNdDwggpH7qvdA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gnu.org header.s=fencepost-gnu-org header.b=gkhY7fwk; 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 E2B98814E1 for ; Thu, 07 Nov 2024 07:20:20 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t8vrg-00033G-5c; Thu, 07 Nov 2024 01:19:32 -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 1t8vre-00032y-Hj for emacs-orgmode@gnu.org; Thu, 07 Nov 2024 01:19:30 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t8vra-0005xb-Fd for emacs-orgmode@gnu.org; Thu, 07 Nov 2024 01:19:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:Subject:To:From:in-reply-to: references; bh=9yMsVJG7GDaTSILEDFcMkojfzJgShelrcZ0uoSwWShE=; b=gkhY7fwkHSqBba v9wqyrS+4EnE0a2z4J6acCFstfJRetO2NkCNsdrpwzSRdFV4hFbXIB0JL+iu+S89R1aF3g1n2tcCl gaGOI35bYiTh4D0eCGUcqgu6VaROj4Ft4RWPamRIVz2p3x3a2GtmCbYLruuQNuzeguR7Co3btXnj9 3zzTqF8etsdPRNh5YIqTIDPe6IKcWfqiMM/FUJP9/lxzDtyXzv2aUyrFe3R+kunF9fIqV389VfXR5 hWy7kiqPLfROH5kM73Bc8ZKonQeBwRv6oQiNn2V5kMhY882PMhYIrFP7ey8qeOP4nynKUtSXGO9zL UdWGL1HbEOa/Wc3olVeA==; X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrtdefgdelhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkf gfgggtgfesthhqredttderjeenucfhrhhomhepfdflohhhnhcuhghivghglhgvhidfuceo jhhohhhnfiesghhnuhdrohhrgheqnecuggftrfgrthhtvghrnheptdetvdelieeihfekge ehheejueeiieeihffhhfeguddvffdtteeuleekvedthfefnecuvehluhhsthgvrhfuihii vgeptdenucfrrghrrghmpehmrghilhhfrhhomhepjhhohhhnfidomhgvshhmthhprghuth hhphgvrhhsohhnrghlihhthidqieekjeektdelgeegqddujeejheefkeduiedqjhhohhhn fieppehgnhhurdhorhhgsehnvgifrghrthhishgrnhhsrdgtohhmpdhnsggprhgtphhtth hopedupdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegvmhgrtghsqdhorhhgmhho uggvsehgnhhurdhorhhg X-ME-Proxy: Feedback-ID: ib64945b7:Fastmail From: "John Wiegley" To: emacs-orgmode@gnu.org Subject: Patch to add a new org-archive hook and context info type Mail-Followup-To: emacs-orgmode@gnu.org Date: Wed, 06 Nov 2024 22:19:22 -0800 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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: -4.52 X-Spam-Score: -4.52 X-Migadu-Queue-Id: E2B98814E1 X-Migadu-Scanner: mx13.migadu.com X-TUID: ocuqOqYiny6h Hello, The following patch adds =E2=80=98org-archive-finalize-hook=E2=80=99, which= runs earlier than =E2=80=98org-archive-hook=E2=80=99 and in the destination buffer, not the o= riginal file. This allows the context to be extended, the archived entry to be cleaned up after inseration, maybe even encrypted or hashed to prevent changes. I also added a new =E2=80=98ARCHIVE_OLID=E2=80=99 context type, which prese= rves the ID of the parent the archived entry was previously under. This is because ARCHIVE_OLP= ATH is not stable: it=E2=80=99s very possible the tree structure may change ove= r time and invalidate the path. But as long as the original parent is not deleted, the= re stands a better chance that the original context of the archived entry can = be restored. John --- a/lisp/org-archive.el +++ b/lisp/org-archive.el @@ -144,13 +144,26 @@ information." (const :tag "Priority" priority) (const :tag "Inherited tags" itags) (const :tag "Outline path" olpath) + (const :tag "Outline parent id" olid) (const :tag "Local tags" ltags))) =20 -(defvar org-archive-hook nil +(defcustom org-archive-hook nil "Hook run after successfully archiving a subtree. Hook functions are called with point on the subtree in the original file. At this stage, the subtree has been added to the -archive location, but not yet deleted from the original file.") +archive location, but not yet deleted from the original file." + :group 'org-archive + :type 'hook) + +(defcustom org-archive-finalize-hook nil + "Hook run after successfully archiving a subtree in final location. +Hook functions are called with point on the subtree in the +destination file. Compare this with `org-archive-hook', which +runs in the original file. At this stage, the subtree has been +added to the archive location, but not yet deleted from the +original file." + :group 'org-archive + :type 'hook) =20 ;;;###autoload (defun org-add-archive-files (files) @@ -299,6 +312,9 @@ direct children of this heading." (olpath . ,(mapconcat #'identity (org-get-outline-path) "/")) + (olid . ,(org-with-wide-buffer + (and (org-up-heading-safe) + (org-entry-get (point) "ID")))) (time . ,time) (todo . ,(org-entry-get (point) "TODO"))))) ;; We first only copy, in case something goes wrong @@ -393,6 +409,7 @@ direct children of this heading." (point) (concat "ARCHIVE_" (upcase (symbol-name item))) value)))) + (run-hooks 'org-archive-finalize-hook) ;; Save the buffer, if it is not the same buffer and ;; depending on `org-archive-subtree-save-file-p'. (unless (eq this-buffer buffer)