(vc-fetch-master-properties): Count cvs status "Needs Patch" as
[bpt/emacs.git] / lisp / calendar / cal-x.el
CommitLineData
38e3261c
ER
1;;; cal-x.el --- calendar windows in dedicated frames in x-windows
2
3;; Copyright (C) 1994 Free Software Foundation, Inc.
4
5;; Author: Michael Kifer <kifer@cs.sunysb.edu>
6;; Edward M. Reingold <reingold@cs.uiuc.edu>
7;; Keywords: calendar
8;; Human-Keywords: calendar, dedicated frames, x-windows
9
10;; This file is part of GNU Emacs.
11
12;; GNU Emacs is free software; you can redistribute it and/or modify
13;; it under the terms of the GNU General Public License as published by
14;; the Free Software Foundation; either version 2, or (at your option)
15;; any later version.
16
17;; GNU Emacs is distributed in the hope that it will be useful,
18;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20;; GNU General Public License for more details.
21
22;; You should have received a copy of the GNU General Public License
23;; along with GNU Emacs; see the file COPYING. If not, write to
24;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
25
26;;; Commentary:
27
28;; This collection of functions implements dedicated frames in x-windows for
29;; calendar.el.
30
31;; Comments, corrections, and improvements should be sent to
32;; Edward M. Reingold Department of Computer Science
33;; (217) 333-6733 University of Illinois at Urbana-Champaign
34;; reingold@cs.uiuc.edu 1304 West Springfield Avenue
35;; Urbana, Illinois 61801
36
37;;; Code:
38
39(require 'calendar)
40(if (not (fboundp 'calendar-basic-setup))
41 (fset 'calendar-basic-setup (symbol-function 'calendar)))
42
a096c36b 43;;;###autoload
38e3261c
ER
44(defvar calendar-setup 'one-frame
45 "The frame set up of the calendar.
46The choices are `one-frame' (calendar and diary together in one separate,
47dediciated frame) or `two-frames' (calendar and diary in separate, dedicated
48frames); with any other value the current frame is used.")
49
50(defun calendar (&optional arg)
51 "Choose between the one frame, two frame, or basic calendar displays.
52The original function `calendar' has been renamed `calendar-basic-setup'."
53 (interactive "P")
54 (cond ((equal calendar-setup 'one-frame) (calendar-one-frame-setup arg))
55 ((equal calendar-setup 'two-frames) (calendar-two-frame-setup arg))
56 (t (calendar-basic-setup arg))))
57
58(defvar calendar-frame nil "Frame in which to display the calendar.")
59
60(defvar diary-frame nil "Frame in which to display the diary.")
61
62(defvar diary-frame-parameters
63 '((name . "Diary") (height . 10) (width . 80) (unsplittable . t)
64 (font . "6x13") (auto-lower . t) (auto-raise . t) (minibuffer . nil))
65 "Parameters of the diary frame, if the diary is in its own frame.
66Location and color should be set in .Xdefaults.")
67
68(defvar calendar-frame-parameters
69 '((name . "Calendar") (minibuffer . nil) (height . 10) (width . 80)
70 (auto-raise . t) (auto-lower . t) (font . "6x13") (unsplittable . t)
71 (vertical-scroll-bars . nil))
72 "Parameters of the calendar frame, if the calendar is in a separate frame.
73Location and color should be set in .Xdefaults.")
74
75(defvar calendar-and-diary-frame-parameters
76 '((name . "Calendar") (height . 28) (width . 80) (minibuffer . nil)
77 (font . "6x13") (auto-raise . t) (auto-lower . t))
78 "Parameters of the frame that displays both the calendar and the diary.
79Location and color should be set in .Xdefaults.")
80
81(defvar calendar-after-frame-setup-hooks nil
82 "Hooks to be run just after setting up a calendar frame.
83Can be used to change frame parameters, such as font, color, location, etc.")
84
85(defun calendar-one-frame-setup (&optional arg)
86 "Start calendar and display it in a dedicated frame together with the diary."
87 (if (not window-system)
88 (calendar-basic-setup arg)
89 (if (frame-live-p calendar-frame) (delete-frame calendar-frame))
90 (if (frame-live-p diary-frame) (delete-frame diary-frame))
91 (let ((special-display-buffer-names nil)
92 (view-diary-entries-initially t))
93 (save-window-excursion
94 (save-excursion
95 (setq calendar-frame
96 (make-frame calendar-and-diary-frame-parameters))
97 (run-hooks 'calendar-after-frame-setup-hooks)
98 (select-frame calendar-frame)
99 (if (eq 'icon (cdr (assoc 'visibility
100 (frame-parameters calendar-frame))))
101 (iconify-or-deiconify-frame))
102 (calendar-basic-setup arg)
103 (set-window-dedicated-p (selected-window) 'calendar)
104 (set-window-dedicated-p
105 (display-buffer
0f12fdab
ER
106 (if (not (memq 'fancy-diary-display diary-display-hook))
107 (get-file-buffer diary-file)
108 (if (not (bufferp (get-buffer fancy-diary-buffer)))
109 (make-fancy-diary-buffer))
110 fancy-diary-buffer))
38e3261c 111 'diary))))))
0f12fdab 112
38e3261c
ER
113(defun calendar-two-frame-setup (&optional arg)
114 "Start calendar and diary in separate, dedicated frames."
115 (if (not window-system)
116 (calendar-basic-setup arg)
117 (if (frame-live-p calendar-frame) (delete-frame calendar-frame))
118 (if (frame-live-p diary-frame) (delete-frame diary-frame))
119 (let ((pop-up-windows nil)
120 (view-diary-entries-initially nil)
121 (special-display-buffer-names nil))
122 (save-window-excursion
123 (save-excursion (calendar-basic-setup arg))
124 (setq calendar-frame (make-frame calendar-frame-parameters))
125 (run-hooks 'calendar-after-frame-setup-hooks)
126 (select-frame calendar-frame)
127 (if (eq 'icon (cdr (assoc 'visibility
128 (frame-parameters calendar-frame))))
129 (iconify-or-deiconify-frame))
130 (display-buffer calendar-buffer)
131 (set-window-dedicated-p (selected-window) 'calendar)
132 (setq diary-frame (make-frame diary-frame-parameters))
133 (run-hooks 'calendar-after-frame-setup-hooks)
134 (select-frame diary-frame)
135 (if (eq 'icon (cdr (assoc 'visibility
136 (frame-parameters diary-frame))))
137 (iconify-or-deiconify-frame))
138 (save-excursion (diary))
139 (set-window-dedicated-p
140 (display-buffer
0f12fdab
ER
141 (if (not (memq 'fancy-diary-display diary-display-hook))
142 (get-file-buffer diary-file)
143 (if (not (bufferp (get-buffer fancy-diary-buffer)))
144 (make-fancy-diary-buffer))
145 fancy-diary-buffer))
38e3261c
ER
146 'diary)))))
147
148(setq special-display-buffer-names
149 (append special-display-buffer-names
150 (list "*Yahrzeits*" lunar-phases-buffer holiday-buffer
151 fancy-diary-buffer (get-file-buffer diary-file)
152 calendar-buffer)))
153
154(run-hooks 'cal-x-load-hook)
155
156(provide 'cal-x)
157
158;;; cal-x.el ends here