Browse Source

org-agenda.el: Fix bug when showing indirect agenda in another frame

* org-agenda.el (org-agenda-tree-to-indirect-buffer): Find the
correct agenda buffer.  Don't split the agenda window when the
indirect buffer is displayed in another frame.

Thanks Viktor Rosenfeld for reporting this.
Bastien Guerry 12 năm trước cách đây
mục cha
commit
b81485d5ff
1 tập tin đã thay đổi với 12 bổ sung9 xóa
  1. 12 9
      lisp/org-agenda.el

+ 12 - 9
lisp/org-agenda.el

@@ -7877,19 +7877,22 @@ use the dedicated frame)."
   (interactive)
   (if (and current-prefix-arg (listp current-prefix-arg))
       (org-agenda-do-tree-to-indirect-buffer)
-    (let ((agenda-window (selected-window))
+    (let ((agenda-buffer (buffer-name))
+	  (agenda-window (selected-window))
           (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 (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)
-            (fit-window-to-buffer indirect-window))
-        (select-window (get-buffer-window org-agenda-buffer-name))))))
+      (unless (or (eq org-indirect-buffer-display 'new-frame)
+		  (eq org-indirect-buffer-display 'dedicated-frame))
+	(unwind-protect
+	    (progn
+	      (unless (and indirect-window (window-live-p indirect-window)))
+	      (setq indirect-window (split-window agenda-window)))
+	  (and indirect-window (select-window indirect-window))
+	  (switch-to-buffer org-last-indirect-buffer :norecord)
+	  (fit-window-to-buffer indirect-window)))
+      (select-window (get-buffer-window agenda-buffer)))))
 
 (defun org-agenda-do-tree-to-indirect-buffer ()
   "Same as `org-agenda-tree-to-indirect-buffer' without saving window."