branch: externals/org commit 62a5910d874de6540f6dde4f4c4bcd94a6575d01 Author: John Wiegley <jo...@gnu.org> Commit: Ihor Radchenko <yanta...@posteo.net>
org-archive: Add org-archive-finalize-hook * lisp/org-archive.el (org-archive-hook): Convert to defcustom. (org-archive-finalize-hook): Add new hook. (org-archive-subtree): Call the new hook. * etc/ORG-NEWS (New hook ~org-archive-finalize-hook~): Announce the change. --- etc/ORG-NEWS | 6 ++++++ lisp/org-archive.el | 18 ++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index d3eea30f43..61bb0d379f 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -221,6 +221,12 @@ retail 4-4-5 calendars, etc). # adding new customizations, or changing the interpretation of the # existing customizations. +*** New hook ~org-archive-finalize-hook~ + +Hook run after successfully archiving a subtree in final location. +Unlike ~org-archive-hook~, which runs in the sourcce Org buffer, the +new hook is called with point on the subtree in the destination file. + *** ox-odt: New export option ~org-odt-with-forbidden-chars~ The new export option controls how to deal with characters that are forbidden diff --git a/lisp/org-archive.el b/lisp/org-archive.el index c66dc21682..8d3658d27d 100644 --- a/lisp/org-archive.el +++ b/lisp/org-archive.el @@ -146,11 +146,24 @@ information." (const :tag "Outline path" olpath) (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 + :package-version '(Org . "9.8") + :type 'hook) ;;;###autoload (defun org-add-archive-files (files) @@ -393,6 +406,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)