Update FSF's address.
[bpt/emacs.git] / lisp / calendar / cal-x.el
CommitLineData
38e3261c
ER
1;;; cal-x.el --- calendar windows in dedicated frames in x-windows
2
9275d779 3;; Copyright (C) 1994, 1995 Free Software Foundation, Inc.
38e3261c
ER
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
b578f267
EN
23;; along with GNU Emacs; see the file COPYING. If not, write to the
24;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25;; Boston, MA 02111-1307, USA.
38e3261c
ER
26
27;;; Commentary:
28
29;; This collection of functions implements dedicated frames in x-windows for
30;; calendar.el.
31
32;; Comments, corrections, and improvements should be sent to
33;; Edward M. Reingold Department of Computer Science
34;; (217) 333-6733 University of Illinois at Urbana-Champaign
35;; reingold@cs.uiuc.edu 1304 West Springfield Avenue
36;; Urbana, Illinois 61801
37
38;;; Code:
39
10dbf039
RS
40(require 'calendar)
41
38e3261c
ER
42(defvar calendar-frame nil "Frame in which to display the calendar.")
43
44(defvar diary-frame nil "Frame in which to display the diary.")
45
46(defvar diary-frame-parameters
47 '((name . "Diary") (height . 10) (width . 80) (unsplittable . t)
48 (font . "6x13") (auto-lower . t) (auto-raise . t) (minibuffer . nil))
49 "Parameters of the diary frame, if the diary is in its own frame.
50Location and color should be set in .Xdefaults.")
51
52(defvar calendar-frame-parameters
53 '((name . "Calendar") (minibuffer . nil) (height . 10) (width . 80)
54 (auto-raise . t) (auto-lower . t) (font . "6x13") (unsplittable . t)
55 (vertical-scroll-bars . nil))
56 "Parameters of the calendar frame, if the calendar is in a separate frame.
57Location and color should be set in .Xdefaults.")
58
59(defvar calendar-and-diary-frame-parameters
60 '((name . "Calendar") (height . 28) (width . 80) (minibuffer . nil)
61 (font . "6x13") (auto-raise . t) (auto-lower . t))
62 "Parameters of the frame that displays both the calendar and the diary.
63Location and color should be set in .Xdefaults.")
64
65(defvar calendar-after-frame-setup-hooks nil
66 "Hooks to be run just after setting up a calendar frame.
67Can be used to change frame parameters, such as font, color, location, etc.")
68
69(defun calendar-one-frame-setup (&optional arg)
70 "Start calendar and display it in a dedicated frame together with the diary."
71 (if (not window-system)
72 (calendar-basic-setup arg)
73 (if (frame-live-p calendar-frame) (delete-frame calendar-frame))
74 (if (frame-live-p diary-frame) (delete-frame diary-frame))
75 (let ((special-display-buffer-names nil)
76 (view-diary-entries-initially t))
77 (save-window-excursion
78 (save-excursion
79 (setq calendar-frame
80 (make-frame calendar-and-diary-frame-parameters))
81 (run-hooks 'calendar-after-frame-setup-hooks)
82 (select-frame calendar-frame)
83 (if (eq 'icon (cdr (assoc 'visibility
84 (frame-parameters calendar-frame))))
85 (iconify-or-deiconify-frame))
86 (calendar-basic-setup arg)
87 (set-window-dedicated-p (selected-window) 'calendar)
88 (set-window-dedicated-p
89 (display-buffer
0f12fdab
ER
90 (if (not (memq 'fancy-diary-display diary-display-hook))
91 (get-file-buffer diary-file)
92 (if (not (bufferp (get-buffer fancy-diary-buffer)))
93 (make-fancy-diary-buffer))
94 fancy-diary-buffer))
38e3261c 95 'diary))))))
0f12fdab 96
38e3261c
ER
97(defun calendar-two-frame-setup (&optional arg)
98 "Start calendar and diary in separate, dedicated frames."
99 (if (not window-system)
100 (calendar-basic-setup arg)
101 (if (frame-live-p calendar-frame) (delete-frame calendar-frame))
102 (if (frame-live-p diary-frame) (delete-frame diary-frame))
103 (let ((pop-up-windows nil)
104 (view-diary-entries-initially nil)
105 (special-display-buffer-names nil))
106 (save-window-excursion
107 (save-excursion (calendar-basic-setup arg))
108 (setq calendar-frame (make-frame calendar-frame-parameters))
109 (run-hooks 'calendar-after-frame-setup-hooks)
110 (select-frame calendar-frame)
111 (if (eq 'icon (cdr (assoc 'visibility
112 (frame-parameters calendar-frame))))
113 (iconify-or-deiconify-frame))
114 (display-buffer calendar-buffer)
115 (set-window-dedicated-p (selected-window) 'calendar)
116 (setq diary-frame (make-frame diary-frame-parameters))
117 (run-hooks 'calendar-after-frame-setup-hooks)
118 (select-frame diary-frame)
119 (if (eq 'icon (cdr (assoc 'visibility
120 (frame-parameters diary-frame))))
121 (iconify-or-deiconify-frame))
122 (save-excursion (diary))
123 (set-window-dedicated-p
124 (display-buffer
0f12fdab
ER
125 (if (not (memq 'fancy-diary-display diary-display-hook))
126 (get-file-buffer diary-file)
127 (if (not (bufferp (get-buffer fancy-diary-buffer)))
128 (make-fancy-diary-buffer))
129 fancy-diary-buffer))
38e3261c
ER
130 'diary)))))
131
132(setq special-display-buffer-names
133 (append special-display-buffer-names
134 (list "*Yahrzeits*" lunar-phases-buffer holiday-buffer
135 fancy-diary-buffer (get-file-buffer diary-file)
136 calendar-buffer)))
137
138(run-hooks 'cal-x-load-hook)
139
140(provide 'cal-x)
141
142;;; cal-x.el ends here