diff options
author | Carsten Dominik <carsten.dominik@gmail.com> | 2017-05-05 11:59:10 +0200 |
---|---|---|
committer | Carsten Dominik <carsten.dominik@gmail.com> | 2017-05-05 11:59:10 +0200 |
commit | 44de3efe753d1d8f555928d98a66656047a65eec (patch) | |
tree | 3dade30ee3df810cba929bf743bd057a406d681a | |
parent | c28ec3a17011aafa0bee7dcd2e12d3e7d5a3a87d (diff) | |
download | org-mode-44de3efe753d1d8f555928d98a66656047a65eec.tar.gz |
* lisp/org-archive.el (org-archive-subtree): Honor
`org-archive-reversed-order' also on top level.
-rw-r--r-- | lisp/org-archive.el | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/lisp/org-archive.el b/lisp/org-archive.el index 4ce81aa..c76abdb 100644 --- a/lisp/org-archive.el +++ b/lisp/org-archive.el @@ -338,14 +338,20 @@ this heading." (and (looking-at "[ \t\r\n]*") ;; datetree archives don't need so much spacing. (replace-match (if datetree-date "\n" "\n\n")))) - ;; No specific heading, just go to end of file. - (goto-char (point-max)) - ;; Subtree narrowing can let the buffer end on - ;; a headline. `org-paste-subtree' then deletes it. - ;; To prevent this, make sure visible part of buffer - ;; always terminates on a new line, while limiting - ;; number of blank lines in a date tree. - (unless (and datetree-date (bolp)) (insert "\n"))) + ;; No specific heading, just go to end of file, or to the + ;; beginning, depending on `org-archive-reversed-order'. + (if org-archive-reversed-order + (progn + (goto-char (point-min)) + (unless (org-at-heading-p) (outline-next-heading)) + (insert "\n") (backward-char 1)) + (goto-char (point-max)) + ;; Subtree narrowing can let the buffer end on + ;; a headline. `org-paste-subtree' then deletes it. + ;; To prevent this, make sure visible part of buffer + ;; always terminates on a new line, while limiting + ;; number of blank lines in a date tree. + (unless (and datetree-date (bolp)) (insert "\n")))) ;; Paste (org-paste-subtree (org-get-valid-level level (and heading 1))) ;; Shall we append inherited tags? |