org-agenda.el: Fix bug when calling `org-agenda-kill' and `org-agenda-archive-with' with a non-nil value of `org-agenda-stick'

* org-agenda.el (org-agenda-kill, org-agenda-archive-with):
Fix bug when called with a non-nil value of `org-agenda-stick'.

Thanks to Moritz Ulrich for reporting this.
This commit is contained in:
Bastien Guerry 2012-08-26 14:53:59 +02:00
parent 74d1658c60
commit d85e7bc10a
1 changed files with 8 additions and 4 deletions

View File

@ -7399,7 +7399,8 @@ Point is in the buffer where the item originated.")
"Kill the entry or subtree belonging to the current agenda entry." "Kill the entry or subtree belonging to the current agenda entry."
(interactive) (interactive)
(or (eq major-mode 'org-agenda-mode) (error "Not in agenda")) (or (eq major-mode 'org-agenda-mode) (error "Not in agenda"))
(let* ((marker (or (org-get-at-bol 'org-marker) (let* ((bufname-orig (buffer-name))
(marker (or (org-get-at-bol 'org-marker)
(org-agenda-error))) (org-agenda-error)))
(buffer (marker-buffer marker)) (buffer (marker-buffer marker))
(pos (marker-position marker)) (pos (marker-position marker))
@ -7424,7 +7425,8 @@ Point is in the buffer where the item originated.")
(format "Delete entry with %d lines in buffer \"%s\"? " (format "Delete entry with %d lines in buffer \"%s\"? "
n (buffer-name buffer)))) n (buffer-name buffer))))
(error "Abort")) (error "Abort"))
(org-remove-subtree-entries-from-agenda buffer dbeg dend) (let ((org-agenda-buffer-name bufname-orig))
(org-remove-subtree-entries-from-agenda buffer dbeg dend))
(with-current-buffer buffer (delete-region dbeg dend)) (with-current-buffer buffer (delete-region dbeg dend))
(message "Agenda item and source killed")))) (message "Agenda item and source killed"))))
@ -7455,7 +7457,8 @@ Point is in the buffer where the item originated.")
"Move the entry to the archive sibling." "Move the entry to the archive sibling."
(interactive) (interactive)
(or (eq major-mode 'org-agenda-mode) (error "Not in agenda")) (or (eq major-mode 'org-agenda-mode) (error "Not in agenda"))
(let* ((marker (or (org-get-at-bol 'org-marker) (let* ((bufname-orig (buffer-name))
(marker (or (org-get-at-bol 'org-marker)
(org-agenda-error))) (org-agenda-error)))
(buffer (marker-buffer marker)) (buffer (marker-buffer marker))
(pos (marker-position marker))) (pos (marker-position marker)))
@ -7467,7 +7470,8 @@ Point is in the buffer where the item originated.")
(error "Abort") (error "Abort")
(save-excursion (save-excursion
(goto-char pos) (goto-char pos)
(org-remove-subtree-entries-from-agenda) (let ((org-agenda-buffer-name bufname-orig))
(org-remove-subtree-entries-from-agenda))
(org-back-to-heading t) (org-back-to-heading t)
(funcall cmd))) (funcall cmd)))
(error "Archiving works only in Org-mode files")))))) (error "Archiving works only in Org-mode files"))))))