summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2016-10-05 23:57:08 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2016-10-05 23:57:08 +0200
commitb42b3aaafc531d6054b424781bb4e02af1c86955 (patch)
tree6b1483f750e1f56548d90fd09651e49fe54d0bfa
parent966e0bff56667e11c9df055d03ae08de6ddcd594 (diff)
downloadorg-mode-b42b3aaafc531d6054b424781bb4e02af1c86955.tar.gz
org-archive: Fix archive to datetree
* lisp/org-archive.el (org-archive-subtree): Fix archiving an entry in a date tree before an existing entry in the same month. Reported-by: Klarre N <klarre@gmail.com> <http://permalink.gmane.org/gmane.emacs.orgmode/109614>
-rw-r--r--lisp/org-archive.el8
1 files changed, 7 insertions, 1 deletions
diff --git a/lisp/org-archive.el b/lisp/org-archive.el
index 86c813c..6daed74 100644
--- a/lisp/org-archive.el
+++ b/lisp/org-archive.el
@@ -339,7 +339,13 @@ this heading."
;; 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)) (unless datetree-date (insert "\n")))
+ (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?