]> code.delx.au - gnu-emacs/blob - lisp/calendar/cal-x.el
Require calendar.
[gnu-emacs] / lisp / calendar / cal-x.el
1 ;;; cal-x.el --- calendar windows in dedicated frames in x-windows
2
3 ;; Copyright (C) 1994, 1995 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
41 (defvar calendar-frame nil "Frame in which to display the calendar.")
42
43 (defvar diary-frame nil "Frame in which to display the diary.")
44
45 (defvar diary-frame-parameters
46 '((name . "Diary") (height . 10) (width . 80) (unsplittable . t)
47 (font . "6x13") (auto-lower . t) (auto-raise . t) (minibuffer . nil))
48 "Parameters of the diary frame, if the diary is in its own frame.
49 Location and color should be set in .Xdefaults.")
50
51 (defvar calendar-frame-parameters
52 '((name . "Calendar") (minibuffer . nil) (height . 10) (width . 80)
53 (auto-raise . t) (auto-lower . t) (font . "6x13") (unsplittable . t)
54 (vertical-scroll-bars . nil))
55 "Parameters of the calendar frame, if the calendar is in a separate frame.
56 Location and color should be set in .Xdefaults.")
57
58 (defvar calendar-and-diary-frame-parameters
59 '((name . "Calendar") (height . 28) (width . 80) (minibuffer . nil)
60 (font . "6x13") (auto-raise . t) (auto-lower . t))
61 "Parameters of the frame that displays both the calendar and the diary.
62 Location and color should be set in .Xdefaults.")
63
64 (defvar calendar-after-frame-setup-hooks nil
65 "Hooks to be run just after setting up a calendar frame.
66 Can be used to change frame parameters, such as font, color, location, etc.")
67
68 (defun calendar-one-frame-setup (&optional arg)
69 "Start calendar and display it in a dedicated frame together with the diary."
70 (if (not window-system)
71 (calendar-basic-setup arg)
72 (if (frame-live-p calendar-frame) (delete-frame calendar-frame))
73 (if (frame-live-p diary-frame) (delete-frame diary-frame))
74 (let ((special-display-buffer-names nil)
75 (view-diary-entries-initially t))
76 (save-window-excursion
77 (save-excursion
78 (setq calendar-frame
79 (make-frame calendar-and-diary-frame-parameters))
80 (run-hooks 'calendar-after-frame-setup-hooks)
81 (select-frame calendar-frame)
82 (if (eq 'icon (cdr (assoc 'visibility
83 (frame-parameters calendar-frame))))
84 (iconify-or-deiconify-frame))
85 (calendar-basic-setup arg)
86 (set-window-dedicated-p (selected-window) 'calendar)
87 (set-window-dedicated-p
88 (display-buffer
89 (if (not (memq 'fancy-diary-display diary-display-hook))
90 (get-file-buffer diary-file)
91 (if (not (bufferp (get-buffer fancy-diary-buffer)))
92 (make-fancy-diary-buffer))
93 fancy-diary-buffer))
94 'diary))))))
95
96 (defun calendar-two-frame-setup (&optional arg)
97 "Start calendar and diary in separate, dedicated frames."
98 (if (not window-system)
99 (calendar-basic-setup arg)
100 (if (frame-live-p calendar-frame) (delete-frame calendar-frame))
101 (if (frame-live-p diary-frame) (delete-frame diary-frame))
102 (let ((pop-up-windows nil)
103 (view-diary-entries-initially nil)
104 (special-display-buffer-names nil))
105 (save-window-excursion
106 (save-excursion (calendar-basic-setup arg))
107 (setq calendar-frame (make-frame calendar-frame-parameters))
108 (run-hooks 'calendar-after-frame-setup-hooks)
109 (select-frame calendar-frame)
110 (if (eq 'icon (cdr (assoc 'visibility
111 (frame-parameters calendar-frame))))
112 (iconify-or-deiconify-frame))
113 (display-buffer calendar-buffer)
114 (set-window-dedicated-p (selected-window) 'calendar)
115 (setq diary-frame (make-frame diary-frame-parameters))
116 (run-hooks 'calendar-after-frame-setup-hooks)
117 (select-frame diary-frame)
118 (if (eq 'icon (cdr (assoc 'visibility
119 (frame-parameters diary-frame))))
120 (iconify-or-deiconify-frame))
121 (save-excursion (diary))
122 (set-window-dedicated-p
123 (display-buffer
124 (if (not (memq 'fancy-diary-display diary-display-hook))
125 (get-file-buffer diary-file)
126 (if (not (bufferp (get-buffer fancy-diary-buffer)))
127 (make-fancy-diary-buffer))
128 fancy-diary-buffer))
129 'diary)))))
130
131 (setq special-display-buffer-names
132 (append special-display-buffer-names
133 (list "*Yahrzeits*" lunar-phases-buffer holiday-buffer
134 fancy-diary-buffer (get-file-buffer diary-file)
135 calendar-buffer)))
136
137 (run-hooks 'cal-x-load-hook)
138
139 (provide 'cal-x)
140
141 ;;; cal-x.el ends here