From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aaron Ecay Subject: Re: [PATCH RFC] subtree archive hook? Date: Sun, 12 Oct 2014 16:22:53 +0100 Message-ID: <87oathia7m.fsf@gmail.com> References: <87vbnp2wix.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49190) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XdKzC-0002F4-Ry for emacs-orgmode@gnu.org; Sun, 12 Oct 2014 11:23:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XdKz3-0007Y9-Sv for emacs-orgmode@gnu.org; Sun, 12 Oct 2014 11:23:06 -0400 Received: from mail-wi0-x229.google.com ([2a00:1450:400c:c05::229]:59268) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XdKz3-0007X1-KV for emacs-orgmode@gnu.org; Sun, 12 Oct 2014 11:22:57 -0400 Received: by mail-wi0-f169.google.com with SMTP id h11so1553789wiw.4 for ; Sun, 12 Oct 2014 08:22:56 -0700 (PDT) In-Reply-To: <87vbnp2wix.fsf@ericabrahamsen.net> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Eric Abrahamsen , emacs-orgmode@gnu.org Hi Eric, Looks like a sensible feature. One comment: 2014ko urriak 12an, Eric Abrahamsen-ek idatzi zuen: > > I think it would be useful to have a hook that runs before archiving a > subtree. I'm attaching two patches: one that includes a hook in the > archive process, and another (by way of an example) that adds a function > to that hook for the org-attach library. You can set the option > `org-attach-archive-delete' to a non-nil value to have org-attach delete > a subtree's attachments when you archive it. > > Let me know what you think! > > Eric > > From 1bfc84570f29dd884c2759dfe19116f09228ed4e Mon Sep 17 00:00:00 2001 > From: Eric Abrahamsen > Date: Sun, 12 Oct 2014 22:01:29 +0800 > Subject: [PATCH 2/3] Provide a hook during the archive process > > * lisp/org-archive.el (org-archive-hook): New hook. > (org-archive-subtree): Run hook. > --- > lisp/org-archive.el | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) > > diff --git a/lisp/org-archive.el b/lisp/org-archive.el > index 700e59b..c7f02b9 100644 > --- a/lisp/org-archive.el > +++ b/lisp/org-archive.el > @@ -119,6 +119,13 @@ information." > (const :tag "Outline path" olpath) > (const :tag "Local tags" ltags))) > > +(defvar 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.") > + > (defun org-get-local-archive-location () > "Get the archive location applicable at point." > (let ((re "^[ \t]*#\\+ARCHIVE:[ \t]+\\(\\S-.*\\S-\\)[ \t]*$") > @@ -366,8 +373,10 @@ this heading." > ;; Save and kill the buffer, if it is not the same buffer. > (when (not (eq this-buffer buffer)) > (save-buffer)))) > - ;; Here we are back in the original buffer. Everything seems to have > - ;; worked. So now cut the tree and finish up. > + ;; Here we are back in the original buffer. Everything seems > + ;; to have worked. So now run hooks, cut the tree and finish > + ;; up. > + (run-hooks 'org-archive-hook) > (let (this-command) (org-cut-subtree)) > (when (featurep 'org-inlinetask) > (org-inlinetask-remove-END-maybe)) Can the above inlinetask thing also be moved into the hook? That seems cleaner, and gives another demonstration of the usefulness of the feature. -- Aaron Ecay