Browse Source

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 <manndmd@gmail.com>
<http://permalink.gmane.org/gmane.emacs.orgmode/103791>
Kyle Meyer 9 years ago
parent
commit
6d0af59744
1 changed files with 7 additions and 2 deletions
  1. 7 2
      lisp/org-agenda.el

+ 7 - 2
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)))))