Browse Source

Fix bug with multiple archiving to sibling.

Calling `org-archive-to-archive-sibling' caused problems when used
several times in a row.  The new killed subtree would be appended to
the current head of the kill-ring, instead of being pushed there.  The
reason for this is that the command `kill-region', which is called by
`org-cut-subtree' changes the variable `this-command', so that during
the next archive command, `kill-region' will think that the previous
command was also a kill and do the append.

Normally this is wanted, to make sure that several kill commands
create one big yank string.  But in this case it has to be avoided.
The patch fixes the problem by let-binding (and therefore protecting)
the value of `this-command' around the call to `org-cut-subtree'.

Reported by Bernt Hansen.
Carsten Dominik 12 years ago
2 changed files with 4 additions and 1 deletions
  1. 3 0
  2. 1 1

+ 3 - 0

@@ -1,5 +1,8 @@
 2008-12-03  Carsten Dominik  <>
+	* org-archive.el (org-archive-to-archive-sibling): Protect
+	`this-command' to avoid appending kills during archiving.
 	* org-exp.el (org-export-with-priority): New variable.
 	(org-export-add-options-to-plist): Use `org-export-plist-vars'
 	instead of internal list of strings and properties.

+ 1 - 1

@@ -345,7 +345,7 @@ sibling does not exist, it will be created at the end of the subtree."
       (org-end-of-subtree t t)
 	(goto-char pos)
-	(org-cut-subtree))
+	(let ((this-command this-command)) (org-cut-subtree)))
       (org-paste-subtree (org-get-valid-level level 1))