diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index f856a28ea..c50c60aa2 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -7399,7 +7399,8 @@ Point is in the buffer where the item originated.") "Kill the entry or subtree belonging to the current agenda entry." (interactive) (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))) (buffer (marker-buffer 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\"? " n (buffer-name buffer)))) (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)) (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." (interactive) (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))) (buffer (marker-buffer marker)) (pos (marker-position marker))) @@ -7467,7 +7470,8 @@ Point is in the buffer where the item originated.") (error "Abort") (save-excursion (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) (funcall cmd))) (error "Archiving works only in Org-mode files"))))))