org-agenda: Fix handling of indirect buffer and window

* org-agenda.el (org-agenda-tree-to-indirect-buffer): Fix handling of
indirect buffer and window.

Check if the window of last indirect buffer is still live and properly
handle the case of `org-last-indirect-buffer' being nil.

Changes suggested by Dave Abrahams in <m2boow1q9e.fsf@boostpro.com>.
This commit is contained in:
David Maus 2012-02-25 11:11:48 +01:00
parent f7ea4bef43
commit 89949e69a3

View file

@ -7280,11 +7280,11 @@ use the dedicated frame)."
(if (and current-prefix-arg (listp current-prefix-arg))
(org-agenda-do-tree-to-indirect-buffer)
(let ((agenda-window (selected-window))
(indirect-window (get-buffer-window org-last-indirect-buffer)))
(indirect-window (and org-last-indirect-buffer (get-buffer-window org-last-indirect-buffer))))
(save-window-excursion (org-agenda-do-tree-to-indirect-buffer))
(unwind-protect
(progn
(unless indirect-window
(unless (and indirect-window (window-live-p indirect-window))
(setq indirect-window (split-window agenda-window)))
(select-window indirect-window)
(switch-to-buffer org-last-indirect-buffer :norecord)