Fix bug with dedicated agenda window

George Pearson writes:

> I have been getting the following message in the minibuffer
> area when marking tasks done in the daily agenda:
>
> Error in post-command-hook: (error Cannot switch buffers in a dedicated
> window)
>
> The item in the underlying org file IS marked DONE, and items with
> repeaters appear to be rescheduled properly.  HOWEVER, the log lines,
> like
>
>    - State "DONE"       from "TODO"       [2009-09-07 Mon 10:36]
>
> do NOT appear.
>
> Note I have been using:
>
> org-agenda-window-setup 'other-frame
>
> for some time now, but I notice there has been a recent change
> related to this variable.  Could this be the source of the
> problem?
>
> I believe the error message appears on other operations in the
> daily agenda as well, but have not yet studied this in detail.

Many agenda commands split the current window, which is not allowed on
a frame containing a dedicated window.

Therefore, we now just kill the frame by hand when exiting the agenda.
This commit is contained in:
Carsten Dominik 2009-09-22 12:11:29 +01:00
parent a804078fca
commit 9d322790d4
2 changed files with 24 additions and 11 deletions

View File

@ -1,3 +1,10 @@
2009-09-22 Carsten Dominik <carsten.dominik@gmail.com>
* org-agenda.el (org-prepare-agenda): Don't officially mark this
window dedicated.
(org-agenda-quit): Kill the frame containing the agenda window if
that frame was created for the agenda.
2009-09-21 Carsten Dominik <carsten.dominik@gmail.com>
* org-agenda.el (org-agenda-date-prompt): Mark the changed time

View File

@ -699,10 +699,11 @@ expressions listed in `org-agenda-entry-text-exclude-regexps'.")
Possible values for this option are:
current-window Show agenda in the current window, keeping all other windows.
other-frame Use `switch-to-buffer-other-frame' to display agenda.
other-window Use `switch-to-buffer-other-window' to display agenda.
reorganize-frame Show only two windows on the current frame, the current
window and the agenda.
other-frame Use `switch-to-buffer-other-frame' to display agenda.
Also, when exiting the agenda, kill that frame.
See also the variable `org-agenda-restore-windows-after-quit'."
:group 'org-agenda-windows
:type '(choice
@ -2588,8 +2589,7 @@ bind it in the options section.")
((equal org-agenda-window-setup 'other-window)
(org-switch-to-buffer-other-window abuf))
((equal org-agenda-window-setup 'other-frame)
(switch-to-buffer-other-frame abuf)
(set-window-dedicated-p (selected-window) t))
(switch-to-buffer-other-frame abuf))
((equal org-agenda-window-setup 'reorganize-frame)
(delete-other-windows)
(org-switch-to-buffer-other-window abuf))))
@ -4972,15 +4972,21 @@ If ERROR is non-nil, throw an error, otherwise just return nil."
(interactive)
(if org-agenda-columns-active
(org-columns-quit)
(if (window-dedicated-p (selected-window)) (delete-other-windows))
(let ((buf (current-buffer)))
(and (not (eq org-agenda-window-setup 'current-window))
(not (one-window-p))
(delete-window))
(kill-buffer buf)
(org-agenda-reset-markers)
(org-columns-remove-overlays)
(setq org-agenda-archives-mode nil))
(if (eq org-agenda-window-setup 'other-frame)
(progn
(kill-buffer buf)
(org-agenda-reset-markers)
(org-columns-remove-overlays)
(setq org-agenda-archives-mode nil)
(delete-frame))
(and (not (eq org-agenda-window-setup 'current-window))
(not (one-window-p))
(delete-window))
(kill-buffer buf)
(org-agenda-reset-markers)
(org-columns-remove-overlays)
(setq org-agenda-archives-mode nil)))
;; Maybe restore the pre-agenda window configuration.
(and org-agenda-restore-windows-after-quit
(not (eq org-agenda-window-setup 'other-frame))