Browse Source

org-agenda.el: Fix bug about restoring existing window conf

* org-agenda.el (org-prepare-agenda-window): Use
`org-pre-agenda-window-conf' if already set.
(org-agenda-Quit): Set `org-pre-agenda-window-conf' to nil
when quitting.
(org-agenda-quit): Ditto.

Thanks to Moritz Ulrich for reporting a bug about this.
Bastien Guerry 5 years ago
parent
commit
d44b56e81e
1 changed files with 6 additions and 3 deletions
  1. 6 3
      lisp/org-agenda.el

+ 6 - 3
lisp/org-agenda.el

@@ -3334,7 +3334,8 @@ generating a new one."
     ;; buffer via elisp link
     (unless (equal (current-buffer) abuf)
       (org-pop-to-buffer-same-window abuf))
-    (setq org-pre-agenda-window-conf wconf)))
+    (setq org-pre-agenda-window-conf
+	  (or org-pre-agenda-window-conf wconf))))
 
 (defun org-prepare-agenda (&optional name)
   (if (org-agenda-use-sticky-p)
@@ -6470,7 +6471,8 @@ If ERROR is non-nil, throw an error, otherwise just return nil."
     (and org-agenda-restore-windows-after-quit
 	 (not (eq org-agenda-window-setup 'other-frame))
 	 org-pre-agenda-window-conf
-	 (set-window-configuration org-pre-agenda-window-conf))))
+	 (set-window-configuration org-pre-agenda-window-conf)
+	 (setq org-pre-agenda-window-conf nil))))
 
 (defun org-agenda-quit ()
   "Exit agenda by killing agenda buffer or burying it when
@@ -6492,7 +6494,8 @@ If ERROR is non-nil, throw an error, otherwise just return nil."
 	    (and org-agenda-restore-windows-after-quit
 		 (not (eq org-agenda-window-setup 'other-frame))
 		 org-pre-agenda-window-conf
-		 (set-window-configuration org-pre-agenda-window-conf))))
+		 (set-window-configuration org-pre-agenda-window-conf)
+		 (setq org-pre-agenda-window-conf nil))))
       (org-agenda-Quit))))
 
 (defun org-agenda-exit ()