From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id kPVfAc9AYmc2XgAAe85BDQ:P1 (envelope-from ) for ; Wed, 18 Dec 2024 03:26:07 +0000 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 kPVfAc9AYmc2XgAAe85BDQ (envelope-from ) for ; Wed, 18 Dec 2024 04:26:07 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Y0vt5npa; 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=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1734492366; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=jn57c019+fxeqZTJT2UNau/WFvZSYLfD1tUpz6rO4S0=; b=qkMvoSueby3O/V0njiAPcjirK3eKGiUXqRKEpWV9b1W/GujsEOlUZZpyBfn/z5TiQgn7OR DDVOB9pi+Nb8RMqhwp8EVWwL1/P0R8dZWXAN/W7uVhoeD/ZfJBQqkuZMejQvRHwE7vjWhd H54qiMWFu2OXK/GWbC+sqCU2VF1o8TDcouBICbDT4Y9xtQppmsuOfsPSYfcliEgJyQPtvj VbpAqCn2gIloEqmB4FXZ/vgTeJprx/SixANz8qfGe0XBeYIRGw2/0SsRrqNZLO+Te4PWxt qUwMpHn5vSgqR9mBz+IpOjZVyEeIK8ixiyqzS4SCfaNZtXny7ZZWeIFSEV05eQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Y0vt5npa; 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=gmail.com ARC-Seal: i=1; s=key1; d=yhetil.org; t=1734492366; a=rsa-sha256; cv=none; b=AXtJJy5ztuBWl+iA25ZGtoEAKQPNiYDiGc+ZLBr0iFedVSTaoqlJpNhjr4ltP/kxmZ6gZU B2AeXwFGX/sNS90/Qq6ez+AG5evtC6kiSQjzWK6NiakxW5OeGXutPVwKJwjEoGB4BBblgC //WP/vHsFUz+mneyzi3Sz6Hk+/lg7YSSvRuGQaP7KTy3sNERXcH2Xr1jio+GOVT+qhWnuj sVilaD//TQLJvyP44mq8GY8hQXx3480Pfy3GnkfBatPWP48RFg/8fXJq3bi7gBOWpqnmIw +d0FRjPd5bymN/vypYq7+3TpngNbfKbwkKz8iMf8O72CrS2yQS7RTDYy1GGKBQ== 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 A639C64BED for ; Wed, 18 Dec 2024 04:26:06 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tNkg2-0002Tf-Q9; Tue, 17 Dec 2024 22:24:46 -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 1tNkg1-0002TA-6Q for emacs-orgmode@gnu.org; Tue, 17 Dec 2024 22:24:45 -0500 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tNkfu-0006l5-PO; Tue, 17 Dec 2024 22:24:44 -0500 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-728e3826211so4812520b3a.0; Tue, 17 Dec 2024 19:24:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734492275; x=1735097075; darn=gnu.org; h=content-transfer-encoding:in-reply-to:from:reply-to:cc :content-language:references:to:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=jn57c019+fxeqZTJT2UNau/WFvZSYLfD1tUpz6rO4S0=; b=Y0vt5npaZAWLEwFHVKy80K2G+GJleUhuSaussWN5/VCBf/Wgt4Ckc0khvAiaq4+vW+ 6XxikgsAe02ssLi5txiRXTzkpWhJoMgAEMCwLtOVOJVLV9RX3YBT2L4UkxTHj24EonCj 3bBYgrAorrjUzC0+bUzBAZNirPryzlTjTfEUGsvOJAetYacZNM5BQl1kVVp+H5uM4io9 BBhW4XOZWLIdeXXpNM11YnbaLp1hzzWxjT6XKitPtiAX4cWOZufKJoO2uQDmR9CxEw1V aW6G82VwkmOnpXsrsvxV46kVSFE0K4TwIGx3vf3xn2ck2vyrmNbq5djm30ezzeDgo6sG v6sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734492275; x=1735097075; h=content-transfer-encoding:in-reply-to:from:reply-to:cc :content-language:references:to:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=jn57c019+fxeqZTJT2UNau/WFvZSYLfD1tUpz6rO4S0=; b=FrADLMV5AJ1MIXhwL2eX1wD3veQ5SZkSHqZUsHsHx67wflxUHTElLjiHUrSoNHRXzy m+8iXJ9r7q7me10JS9nnUpIHD9oy3W1LaI3oAxTtqE+ksUFknF5vETn8qq2jzyU00C8d S1f8umC+/UtWey3rUo0/yFt888D7VZd0z7wMpew+BiONhNYHck9j4799IlY43EYQdhOz wvdcUh3kDMAE7o6kCC1YDmJ/T+JwkqcnCpy6pBFMv801Ww2JFEh+EUIgh4Z9LvyKGu24 GxKh5CnKta6Nr5LetOxLzBZASn5QyaODc5Nvfx3SgHNWOWX8B8jQqEjTjLpQwnbzN3DQ 3asw== X-Gm-Message-State: AOJu0YzEfP/eD/Hgm5d2IMZpPAwQhui2T//UA56T5biTdAsJqx5cluZT i7frKjRF4p8g8VhRYal3WaABHJAoFywPVevDv4BQzqKpZkSxydz0Vq6Um57Y X-Gm-Gg: ASbGncvhh/sXBYMwjYLsz5erntnPTJtiQKTtuPctL5Qky9+gtZqGeiKPZQHwbz4CSpx jtZQL3VrOlgRf4hx/feN+dcgHxci0YF3JNZxF4qmZxgAS8dcI/IoRsCAy33EznnTbakg6ANRgjX 4HiMnBB5C13U5ql3DrulVIf/L2YyG+ZJYl9pim4Tdl523PqukXiZPoy0paMhvRZ+VkCJ9kPc2F6 lEg9cleSquNcCK4iOcvkWdkzDFdOjvmZvwxDv1+uN/f8wOIcGZe+evvm0B6/g== X-Google-Smtp-Source: AGHT+IE/u5PckwtmYAqeeqciHnmuB/n4MtqXF/aIMze/94YkIlFMieXSY3OpQa+jBAPzr43NdjXeEQ== X-Received: by 2002:a05:6a00:4391:b0:724:5815:62c1 with SMTP id d2e1a72fcca58-72a8d2bca40mr2049411b3a.19.1734492274748; Tue, 17 Dec 2024 19:24:34 -0800 (PST) Received: from [172.16.150.46] ([111.17.194.89]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72918b79044sm7713507b3a.105.2024.12.17.19.24.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 17 Dec 2024 19:24:34 -0800 (PST) Message-ID: <69293fe6-07a8-4dcd-8b37-7e0984df9180@gmail.com> Date: Wed, 18 Dec 2024 11:24:30 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Patch to add a new org-archive hook and context info type To: John Wiegley References: Content-Language: en-US Cc: emacs-orgmode@gnu.org From: Liu Hui In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::42a; envelope-from=liuhui1610@gmail.com; helo=mail-pf1-x42a.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Reply-To: m2ttcja7md.fsf@gnu.org 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-Scanner: mx12.migadu.com X-Migadu-Spam-Score: -5.56 X-Spam-Score: -5.56 X-Migadu-Queue-Id: A639C64BED X-TUID: sxc6QTpPDvvK 在 2024/11/7 14:19, John Wiegley 写道: > Hello, > > The following patch adds ‘org-archive-finalize-hook’, which runs earlier than > ‘org-archive-hook’ and in the destination buffer, not the original 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 ‘ARCHIVE_OLID’ context type, which preserves the ID of the > parent the archived entry was previously under. This is because ARCHIVE_OLPATH > is not stable: it’s very possible the tree structure may change over time and > invalidate the path. But as long as the original parent is not deleted, there > 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))) > > -(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) > > ;;;###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) > > Thank you. This hook is useful and I'm using it to set bookmark at last archive position, etc. Can we add it to org-mode?