emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Aaron Ecay <aaronecay@gmail.com>
To: Eric Abrahamsen <eric@ericabrahamsen.net>, emacs-orgmode@gnu.org
Subject: Re: [PATCH RFC] subtree archive hook?
Date: Sun, 12 Oct 2014 16:22:53 +0100	[thread overview]
Message-ID: <87oathia7m.fsf@gmail.com> (raw)
In-Reply-To: <87vbnp2wix.fsf@ericabrahamsen.net>

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 <eric@ericabrahamsen.net>
> 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

  reply	other threads:[~2014-10-12 15:23 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-12 14:27 [PATCH RFC] subtree archive hook? Eric Abrahamsen
2014-10-12 15:22 ` Aaron Ecay [this message]
2014-10-12 16:10   ` Eric Abrahamsen
2014-10-12 18:13     ` Aaron Ecay
2014-10-12 18:45       ` Eric Abrahamsen
2014-10-13 16:13 ` Nicolas Goaziou
2014-10-14  1:55   ` Eric Abrahamsen
2014-10-16 17:03     ` Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87oathia7m.fsf@gmail.com \
    --to=aaronecay@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=eric@ericabrahamsen.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).