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 of the License, or
17 ;; (at your option) any later version.
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. If not, see <http://www.gnu.org/licenses/>.
35 (defcustom diary-frame-parameters
36 '((name .
"Diary") (title .
"Diary") (height .
10) (width .
80)
37 (unsplittable . t
) (minibuffer . nil
))
38 "Parameters of the diary frame, if the diary is in its own frame.
39 Relevant if `calendar-setup' has the value `two-frames'."
41 :options
'((name string
) (title string
) (height integer
) (width integer
)
42 (unsplittable boolean
) (minibuffer boolean
)
43 (vertical-scroll-bars boolean
))
46 (defcustom calendar-frame-parameters
47 '((name .
"Calendar") (title .
"Calendar") (height .
10) (width .
80)
48 (unsplittable . t
) (minibuffer . nil
) (vertical-scroll-bars . nil
))
49 "Parameters of the calendar frame, if the calendar is in a separate frame.
50 Relevant if `calendar-setup' has the value `calendar-only' or `two-frames'."
52 :options
'((name string
) (title string
) (height integer
) (width integer
)
53 (unsplittable boolean
) (minibuffer boolean
)
54 (vertical-scroll-bars boolean
))
57 (defcustom calendar-and-diary-frame-parameters
58 '((name .
"Calendar") (title .
"Calendar") (height .
28) (width .
80)
60 "Parameters of the frame that displays both the calendar and the diary.
61 Relevant if `calendar-setup' has the value `one-frame'."
63 :options
'((name string
) (title string
) (height integer
) (width integer
)
64 (unsplittable boolean
) (minibuffer boolean
)
65 (vertical-scroll-bars boolean
))
68 (define-obsolete-variable-alias 'calendar-after-frame-setup-hooks
69 'calendar-after-frame-setup-hook
"23.1")
71 (defcustom calendar-after-frame-setup-hook nil
72 "List of functions to be run after creating a calendar and/or diary frame."
74 :group
'calendar-hooks
)
76 ;;; End of user options.
78 (defvar calendar-frame nil
79 "Frame in which the calendar was last displayed.")
81 (defvar diary-frame nil
82 "Frame in which the diary was last displayed.")
84 (defun calendar-frame-1 (frame)
85 "Subroutine used by `calendar-frame-setup'.
86 Runs `calendar-after-frame-setup-hook', selects frame, iconifies if needed."
87 (run-hooks 'calendar-after-frame-setup-hook
)
89 (if (eq 'icon
(cdr (assoc 'visibility
(frame-parameters frame
))))
90 (iconify-or-deiconify-frame)))
92 ;; c-d-d is only called after (diary) has been run.
93 (defvar diary-display-function
)
95 (defun calendar-dedicate-diary ()
96 "Display and dedicate the window associated with the diary buffer."
97 (set-window-dedicated-p
99 (if (if (listp diary-display-function
)
100 (or (memq 'diary-fancy-display diary-display-function
)
101 (memq 'fancy-diary-display diary-display-function
))
102 (memq diary-display-function
'(diary-fancy-display
103 fancy-diary-display
)))
105 ;; If there are no diary entries, there won't be a fancy-diary
106 ;; to dedicate, so make a basic one.
107 (or (get-buffer diary-fancy-buffer
)
108 (calendar-in-read-only-buffer diary-fancy-buffer
109 (calendar-set-mode-line "Diary Entries")))
111 (get-file-buffer diary-file
)))
115 (defun calendar-frame-setup (config &optional prompt
)
116 "Display the calendar, and optionally the diary, in a separate frame.
117 CONFIG should be one of:
118 `calendar-only' - just the calendar, no diary
119 `one-frame' - calendar and diary in a single frame
120 `two-frames' - calendar and diary each in a separate frame
122 If CONFIG has any other value, or if the display is not capable of
123 multiple frames, then `calendar-basic-setup' is called.
125 If PROMPT is non-nil, prompt for the month and year to use."
126 (if (not (and (display-multi-frame-p)
127 (memq config
'(calendar-only one-frame two-frames
))))
128 (calendar-basic-setup prompt
)
129 (if (frame-live-p calendar-frame
) (delete-frame calendar-frame
))
130 (unless (eq config
'calendar-only
)
131 (if (frame-live-p diary-frame
) (delete-frame diary-frame
)))
132 (let ((calendar-view-diary-initially-flag (eq config
'one-frame
))
133 ;; For calendar-dedicate-diary in two-frames case.
134 (pop-up-windows nil
))
135 (save-window-excursion
136 ;; Do diary first so that calendar is always left current.
137 (when (eq config
'two-frames
)
139 (setq diary-frame
(make-frame diary-frame-parameters
)))
141 (calendar-dedicate-diary))
144 (make-frame (if (eq config
'one-frame
)
145 calendar-and-diary-frame-parameters
146 calendar-frame-parameters
))))
147 (calendar-basic-setup prompt
(not (eq config
'one-frame
)))
148 (set-window-buffer (selected-window) calendar-buffer
)
149 (set-window-dedicated-p (selected-window) t
)
150 (if (eq config
'one-frame
)
151 (calendar-dedicate-diary))))))
155 (defun calendar-one-frame-setup (&optional prompt
)
156 "Display calendar and diary in a single dedicated frame.
157 See `calendar-frame-setup' for more information."
158 (calendar-frame-setup 'one-frame prompt
))
160 (make-obsolete 'calendar-one-frame-setup
'calendar-frame-setup
"23.1")
164 (defun calendar-only-one-frame-setup (&optional prompt
)
165 "Display calendar in a dedicated frame.
166 See `calendar-frame-setup' for more information."
167 (calendar-frame-setup 'calendar-only prompt
))
169 (make-obsolete 'calendar-only-one-frame-setup
'calendar-frame-setup
"23.1")
173 (defun calendar-two-frame-setup (&optional prompt
)
174 "Display calendar and diary in separate, dedicated frames.
175 See `calendar-frame-setup' for more information."
176 (calendar-frame-setup 'two-frames prompt
))
178 (make-obsolete 'calendar-two-frame-setup
'calendar-frame-setup
"23.1")
181 ;; Undocumented and probably useless.
182 (defvar cal-x-load-hook nil
183 "Hook run on loading of the `cal-x' package.")
184 (make-obsolete-variable 'cal-x-load-hook
"it will be removed in future." "23.1")
186 (run-hooks 'cal-x-load-hook
)
191 ;; arch-tag: c6dbddca-ae84-442d-87fc-244b76e38e17
192 ;;; cal-x.el ends here