From 6d0af5974479be9b2932d6fe1676381ec11b5da3 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Thu, 24 Dec 2015 01:48:34 -0500 Subject: [PATCH] org-agenda: Don't kill or bury non-agenda buffer * lisp/org-agenda.el (org-agenda--quit): Fix changes introduced by 9b1c682 and 8594aed that incorrectly assume that the agenda buffer is always the current buffer at the time of killing or burying. Reported-by: David Mann --- lisp/org-agenda.el | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 9f5874079..96e15d544 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -7233,6 +7233,7 @@ agenda." (if org-agenda-columns-active (org-columns-quit) (let ((wconf org-agenda-pre-window-conf) + (buf (current-buffer)) (org-agenda-last-indirect-window (and (eq org-indirect-buffer-display 'other-window) org-agenda-last-indirect-buffer @@ -7254,8 +7255,12 @@ agenda." (not (one-window-p)) (delete-window)))) (if bury - (bury-buffer) - (kill-buffer) + ;; Set the agenda buffer as the current buffer instead of + ;; passing it as an argument to `bury-buffer' so that + ;; `bury-buffer' removes it from the window. + (with-current-buffer buf + (bury-buffer)) + (kill-buffer buf) (setq org-agenda-archives-mode nil org-agenda-buffer nil)))))