1 ;;; cal-x.el --- calendar windows in dedicated frames
3 ;; Copyright (C) 1994, 1995, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
4 ;; 2008 Free Software Foundation, Inc.
6 ;; Author: Michael Kifer <kifer@cs.sunysb.edu>
7 ;; Edward M. Reingold <reingold@cs.uiuc.edu>
8 ;; Maintainer: Glenn Morris <rgm@gnu.org>
10 ;; Human-Keywords: calendar, dedicated frames
12 ;; This file is part of GNU Emacs.
14 ;; GNU Emacs is free software; you can redistribute it and/or modify
15 ;; it under the terms of the GNU General Public License as published by
16 ;; the Free Software Foundation; either version 3, or (at your option)
19 ;; GNU Emacs is distributed in the hope that it will be useful,
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;; GNU General Public License for more details.
24 ;; You should have received a copy of the GNU General Public License
25 ;; along with GNU Emacs; see the file COPYING. If not, write to the
26 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
27 ;; Boston, MA 02110-1301, USA.
37 (defcustom diary-frame-parameters
38 '((name .
"Diary") (title .
"Diary") (height .
10) (width .
80)
39 (unsplittable . t
) (minibuffer . nil
))
40 "Parameters of the diary frame, if the diary is in its own frame.
41 Relevant if `calendar-setup' has the value `two-frames'."
43 :options
'((name string
) (title string
) (height integer
) (width integer
)
44 (unsplittable boolean
) (minibuffer boolean
)
45 (vertical-scroll-bars boolean
))
48 (defcustom calendar-frame-parameters
49 '((name .
"Calendar") (title .
"Calendar") (height .
10) (width .
80)
50 (unsplittable . t
) (minibuffer . nil
) (vertical-scroll-bars . nil
))
51 "Parameters of the calendar frame, if the calendar is in a separate frame.
52 Relevant if `calendar-setup' has the value `calendar-only' or `two-frames'."
54 :options
'((name string
) (title string
) (height integer
) (width integer
)
55 (unsplittable boolean
) (minibuffer boolean
)
56 (vertical-scroll-bars boolean
))
59 (defcustom calendar-and-diary-frame-parameters
60 '((name .
"Calendar") (title .
"Calendar") (height .
28) (width .
80)
62 "Parameters of the frame that displays both the calendar and the diary.
63 Relevant if `calendar-setup' has the value `one-frame'."
65 :options
'((name string
) (title string
) (height integer
) (width integer
)
66 (unsplittable boolean
) (minibuffer boolean
)
67 (vertical-scroll-bars boolean
))
70 (defcustom calendar-after-frame-setup-hook nil
71 "List of functions to be run after creating a calendar and/or diary frame."
73 :group
'calendar-hooks
)
75 (define-obsolete-variable-alias 'calendar-after-frame-setup-hooks
76 'calendar-after-frame-setup-hook
"23.1")
78 ;;; End of user options.
80 (defvar calendar-frame nil
81 "Frame in which the calendar was last displayed.")
83 (defvar diary-frame nil
84 "Frame in which the diary was last displayed.")
86 (defun calendar-frame-1 (frame)
87 "Subroutine used by `calendar-frame-setup'.
88 Runs `calendar-after-frame-setup-hook', selects frame, iconifies if needed."
89 (run-hooks 'calendar-after-frame-setup-hook
)
91 (if (eq 'icon
(cdr (assoc 'visibility
(frame-parameters frame
))))
92 (iconify-or-deiconify-frame)))
94 (defun calendar-dedicate-diary ()
95 "Display and dedicate the window associated with the diary buffer."
96 (set-window-dedicated-p
98 (if (not (or (memq 'diary-fancy-display diary-display-hook
)
99 (memq 'fancy-diary-display diary-display-hook
)))
100 (get-file-buffer diary-file
)
101 ;; If there are no diary entries, there won't be a fancy-diary
102 ;; to dedicate, so make a basic one.
103 (or (get-buffer fancy-diary-buffer
)
104 (calendar-in-read-only-buffer fancy-diary-buffer
105 (calendar-set-mode-line "Diary Entries")))
110 (defun calendar-frame-setup (config &optional prompt
)
111 "Display the calendar, and optionally the diary, in a separate frame.
112 CONFIG should be one of:
113 `calendar-only' - just the calendar, no diary
114 `one-frame' - calendar and diary in a single frame
115 `two-frames' - calendar and diary each in a separate frame
117 If CONFIG has any other value, or if the display is not capable of
118 multiple frames, then `calendar-basic-setup' is called.
120 If PROMPT is non-nil, prompt for the month and year to use."
121 (if (not (and (display-multi-frame-p)
122 (memq config
'(calendar-only one-frame two-frames
))))
123 (calendar-basic-setup prompt
)
124 (if (frame-live-p calendar-frame
) (delete-frame calendar-frame
))
125 (unless (eq config
'calendar-only
)
126 (if (frame-live-p diary-frame
) (delete-frame diary-frame
)))
127 (let ((view-diary-entries-initially (eq config
'one-frame
))
128 ;; For calendar-dedicate-diary in two-frames case.
129 (pop-up-windows nil
))
130 (save-window-excursion
131 ;; Do diary first so that calendar is always left current.
132 (when (eq config
'two-frames
)
134 (setq diary-frame
(make-frame diary-frame-parameters
)))
136 (calendar-dedicate-diary))
139 (make-frame (if (eq config
'one-frame
)
140 calendar-and-diary-frame-parameters
141 calendar-frame-parameters
))))
142 (calendar-basic-setup prompt
(not (eq config
'one-frame
)))
143 (set-window-buffer (selected-window) calendar-buffer
)
144 (set-window-dedicated-p (selected-window) t
)
145 (if (eq config
'one-frame
)
146 (calendar-dedicate-diary))))))
150 (defun calendar-one-frame-setup (&optional prompt
)
151 "Display calendar and diary in a single dedicated frame.
152 See `calendar-frame-setup' for more information."
153 (calendar-frame-setup 'one-frame prompt
))
155 (make-obsolete 'calendar-one-frame-setup
'calendar-frame-setup
"23.1")
159 (defun calendar-only-one-frame-setup (&optional prompt
)
160 "Display calendar in a dedicated frame.
161 See `calendar-frame-setup' for more information."
162 (calendar-frame-setup 'calendar-only prompt
))
164 (make-obsolete 'calendar-only-one-frame-setup
'calendar-frame-setup
"23.1")
168 (defun calendar-two-frame-setup (&optional prompt
)
169 "Display calendar and diary in separate, dedicated frames.
170 See `calendar-frame-setup' for more information."
171 (calendar-frame-setup 'two-frames prompt
))
173 (make-obsolete 'calendar-two-frame-setup
'calendar-frame-setup
"23.1")
176 ;; Undocumented and probably useless.
177 (defvar cal-x-load-hook nil
178 "Hook run on loading of the `cal-x' package.")
179 (make-obsolete-variable 'cal-x-load-hook
"it will be removed in future." "23.1")
181 (run-hooks 'cal-x-load-hook
)
186 ;; arch-tag: c6dbddca-ae84-442d-87fc-244b76e38e17
187 ;;; cal-x.el ends here