Archiving: Allow to reverse order in target node

Tom writes:

> When archiving trees I'd like to see the archived items in
> reverse chronological order at the archive location, so if I jump
> to the header under which stuff is archived I would see the most
> recent item at the top.
>
> When searching for something in the archives it is much more
> frequent that I'm looking for something recently archived than
> something archived months ago, so the reserved order would make
> more sense to me.
>
> Is there a setting which tells the archiving command to insert
> the archived tree as first child of the archive location,
> instead of the last?
This commit is contained in:
Carsten Dominik 2010-03-11 07:23:03 +01:00
parent fb528c18f0
commit 77eda20bb6
2 changed files with 19 additions and 2 deletions

View File

@ -1,3 +1,9 @@
2010-03-11 Carsten Dominik <carsten.dominik@gmail.com>
* org-archive.el (org-archive-reversed-order): New option.
(org-archive-subtree, org-archive-to-archive-sibling): Use the new
option `org-archive-reversed-order'.
2010-03-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-agenda.el (org-agenda-entry-types): New variable.

View File

@ -42,6 +42,11 @@
(const org-archive-to-archive-sibling)
(const org-archive-set-tag)))
(defcustom org-archive-reversed-order nil
"Non-nil means make the tree first child under the archive heading, not last."
:group 'org-archive
:type 'boolean)
(defcustom org-archive-sibling-heading "Archive"
"Name of the local archive sibling that is used to archive entries locally.
Locally means: in the tree, under a sibling.
@ -273,7 +278,11 @@ this heading."
(end-of-line 0))
;; Make the subtree visible
(show-subtree)
(org-end-of-subtree t)
(if org-archive-reversed-order
(progn
(org-back-to-heading t)
(outline-next-heading))
(org-end-of-subtree t))
(skip-chars-backward " \t\r\n")
(and (looking-at "[ \t\r\n]*")
(replace-match "\n\n")))
@ -355,7 +364,9 @@ sibling does not exist, it will be created at the end of the subtree."
(beginning-of-line 0)
(org-toggle-tag org-archive-tag 'on))
(beginning-of-line 1)
(org-end-of-subtree t t)
(if org-archive-reversed-order
(outline-next-heading)
(org-end-of-subtree t t))
(save-excursion
(goto-char pos)
(let ((this-command this-command)) (org-cut-subtree)))