summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Steingold <sds@gnu.org>2012-03-29 10:00:00 -0400
committerSam Steingold <sds@gnu.org>2012-03-29 10:00:00 -0400
commit6e7a6ec037313ac3fb76134f20ce268324c05518 (patch)
tree34d9dc8d72ab15c27c5c63018ae5934e742c7f79
parentfee88ca0e8777476ea411d666bed8ac9fc4c8e20 (diff)
downloademacs-6e7a6ec037313ac3fb76134f20ce268324c05518.tar.gz
calendar/calendar.el (calendar-exit): Use `quit-windows-on' instead of
the broken adhockery which does not prevent calendar buffers from being displayed at random after exit. (calendar-window-list, calendar-hide-window): Remove the broken adhockery.
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/calendar/calendar.el63
2 files changed, 27 insertions, 44 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index d7e436d2e05..e0aef6b2dd9 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
+2012-03-28 Sam Steingold <sds@gnu.org>
+
+ * calendar/calendar.el (calendar-exit): Use `quit-windows-on'
+ instead of the broken adhockery which does not prevent calendar
+ buffers from being displayed at random after exit.
+ (calendar-window-list, calendar-hide-window): Remove the broken
+ adhockery.
+
2012-03-28 Glenn Morris <rgm@gnu.org>
* replace.el (query-replace-map): Doc fix.
diff --git a/lisp/calendar/calendar.el b/lisp/calendar/calendar.el
index d9ec27b4f88..cdef98a2763 100644
--- a/lisp/calendar/calendar.el
+++ b/lisp/calendar/calendar.el
@@ -1793,19 +1793,6 @@ the STRINGS are just concatenated and the result truncated."
?\s (- calendar-right-margin (1- start))))))
(force-mode-line-update))))
-(defun calendar-window-list ()
- "List of all calendar-related windows."
- (let ((calendar-buffers (calendar-buffer-list))
- list)
- ;; Using 0 rather than t for last argument - see bug#2199.
- ;; This is only used with calendar-hide-window, which ignores
- ;; iconified frames anyway, so could use 'visible rather than 0.
- (walk-windows (lambda (w)
- (if (memq (window-buffer w) calendar-buffers)
- (push w list)))
- nil 0)
- list))
-
(defun calendar-buffer-list ()
"List of all calendar-related buffers (as buffers, not strings)."
(let (buffs)
@@ -1817,41 +1804,29 @@ the STRINGS are just concatenated and the result truncated."
(push b buffs)))
buffs))
-(defun calendar-exit ()
+(defun calendar-exit (&optional kill)
"Get out of the calendar window and hide it and related buffers."
- (interactive)
- (let ((diary-buffer (get-file-buffer diary-file)))
- (if (or (not diary-buffer)
- (not (buffer-modified-p diary-buffer))
- (yes-or-no-p
- "Diary modified; do you really want to exit the calendar? "))
- ;; Need to do this multiple times because one time can replace some
- ;; calendar-related buffers with other calendar-related buffers.
- (mapc (lambda (x)
- (mapc 'calendar-hide-window (calendar-window-list)))
- (calendar-window-list)))))
+ (interactive "P")
+ (let ((diary-buffer (get-file-buffer diary-file))
+ (calendar-buffers (calendar-buffer-list)))
+ (when (or (not diary-buffer)
+ (not (buffer-modified-p diary-buffer))
+ (yes-or-no-p
+ "Diary modified; do you really want to exit the calendar? "))
+ (if (and calendar-setup (display-multi-frame-p))
+ ;; FIXME: replace this cruft with the `quit-restore' window property
+ (dolist (w (window-list-1 nil nil t))
+ (if (and (memq (window-buffer w) calendar-buffers)
+ (window-dedicated-p w))
+ (if calendar-remove-frame-by-deleting
+ (delete-frame (window-frame w))
+ (iconify-frame (window-frame w)))
+ (quit-window kill w)))
+ (dolist (b calendar-buffers)
+ (quit-windows-on b kill))))))
(define-obsolete-function-alias 'exit-calendar 'calendar-exit "23.1")
-(defun calendar-hide-window (window)
- "Hide WINDOW if it is calendar-related."
- (let ((buffer (if (window-live-p window) (window-buffer window))))
- (if (memq buffer (calendar-buffer-list))
- (cond
- ((and (display-multi-frame-p)
- (eq 'icon (cdr (assoc 'visibility
- (frame-parameters
- (window-frame window))))))
- nil)
- ((and (display-multi-frame-p) (window-dedicated-p window))
- (if calendar-remove-frame-by-deleting
- (delete-frame (window-frame window))
- (iconify-frame (window-frame window))))
- ((not (and (select-window window) (one-window-p window)))
- (delete-window window))
- (t (set-buffer buffer)
- (bury-buffer))))))
-
(defun calendar-current-date (&optional offset)
"Return the current date in a list (month day year).
Optional integer OFFSET is a number of days from the current date."