Commit | Line | Data |
---|---|---|
189134c3 | 1 | ;;; cal-x.el --- calendar windows in dedicated frames in X |
38e3261c | 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 | |
189134c3 | 8 | ;; Human-Keywords: calendar, dedicated frames, X Window System |
38e3261c ER |
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 | ||
189134c3 | 29 | ;; This collection of functions implements dedicated frames in X for |
38e3261c ER |
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.") | |
a1506d29 | 45 | |
eb18bc57 RS |
46 | ;; This should not specify the font. That's up to the user. |
47 | ;; Certainly it should not specify auto-lower and auto-raise | |
48 | ;; since most users won't like that. | |
38e3261c | 49 | (defvar diary-frame-parameters |
4a7cd65c ER |
50 | '((name . "Diary") (title . "Diary") (height . 10) (width . 80) |
51 | (unsplittable . t) (minibuffer . nil)) | |
38e3261c ER |
52 | "Parameters of the diary frame, if the diary is in its own frame. |
53 | Location and color should be set in .Xdefaults.") | |
a1506d29 | 54 | |
38e3261c | 55 | (defvar calendar-frame-parameters |
4a7cd65c ER |
56 | '((name . "Calendar") (title . "Calendar") (minibuffer . nil) |
57 | (height . 10) (width . 80) (unsplittable . t) (vertical-scroll-bars . nil)) | |
38e3261c ER |
58 | "Parameters of the calendar frame, if the calendar is in a separate frame. |
59 | Location and color should be set in .Xdefaults.") | |
60 | ||
61 | (defvar calendar-and-diary-frame-parameters | |
4a7cd65c ER |
62 | '((name . "Calendar") (title . "Calendar") (height . 28) (width . 80) |
63 | (minibuffer . nil)) | |
38e3261c ER |
64 | "Parameters of the frame that displays both the calendar and the diary. |
65 | Location and color should be set in .Xdefaults.") | |
a1506d29 | 66 | |
38e3261c ER |
67 | (defvar calendar-after-frame-setup-hooks nil |
68 | "Hooks to be run just after setting up a calendar frame. | |
69 | Can be used to change frame parameters, such as font, color, location, etc.") | |
a1506d29 | 70 | |
38e3261c | 71 | (defun calendar-one-frame-setup (&optional arg) |
6b61353c KH |
72 | "Start calendar and display it in a dedicated frame together with the diary. |
73 | This function requires a display capable of multiple frames, else | |
74 | `calendar-basic-setup' is used instead." | |
53e1a74c | 75 | (if (not (display-multi-frame-p)) |
38e3261c ER |
76 | (calendar-basic-setup arg) |
77 | (if (frame-live-p calendar-frame) (delete-frame calendar-frame)) | |
78 | (if (frame-live-p diary-frame) (delete-frame diary-frame)) | |
79 | (let ((special-display-buffer-names nil) | |
80 | (view-diary-entries-initially t)) | |
81 | (save-window-excursion | |
82 | (save-excursion | |
83 | (setq calendar-frame | |
84 | (make-frame calendar-and-diary-frame-parameters)) | |
85 | (run-hooks 'calendar-after-frame-setup-hooks) | |
86 | (select-frame calendar-frame) | |
87 | (if (eq 'icon (cdr (assoc 'visibility | |
88 | (frame-parameters calendar-frame)))) | |
89 | (iconify-or-deiconify-frame)) | |
90 | (calendar-basic-setup arg) | |
91 | (set-window-dedicated-p (selected-window) 'calendar) | |
92 | (set-window-dedicated-p | |
93 | (display-buffer | |
0f12fdab ER |
94 | (if (not (memq 'fancy-diary-display diary-display-hook)) |
95 | (get-file-buffer diary-file) | |
96 | (if (not (bufferp (get-buffer fancy-diary-buffer))) | |
97 | (make-fancy-diary-buffer)) | |
98 | fancy-diary-buffer)) | |
38e3261c | 99 | 'diary)))))) |
77a7efce KH |
100 | |
101 | (defun calendar-only-one-frame-setup (&optional arg) | |
6b61353c KH |
102 | "Start calendar and display it in a dedicated frame. |
103 | This function requires a display capable of multiple frames, else | |
104 | `calendar-basic-setup' is used instead." | |
53e1a74c | 105 | (if (not (display-multi-frame-p)) |
77a7efce KH |
106 | (calendar-basic-setup arg) |
107 | (if (frame-live-p calendar-frame) (delete-frame calendar-frame)) | |
108 | (let ((special-display-buffer-names nil) | |
109 | (view-diary-entries-initially nil)) | |
110 | (save-window-excursion | |
111 | (save-excursion | |
112 | (setq calendar-frame | |
113 | (make-frame calendar-frame-parameters)) | |
114 | (run-hooks 'calendar-after-frame-setup-hooks) | |
115 | (select-frame calendar-frame) | |
116 | (if (eq 'icon (cdr (assoc 'visibility | |
117 | (frame-parameters calendar-frame)))) | |
118 | (iconify-or-deiconify-frame)) | |
119 | (calendar-basic-setup arg) | |
120 | (set-window-dedicated-p (selected-window) 'calendar)))))) | |
0f12fdab | 121 | |
38e3261c | 122 | (defun calendar-two-frame-setup (&optional arg) |
6b61353c KH |
123 | "Start calendar and diary in separate, dedicated frames. |
124 | This function requires a display capable of multiple frames, else | |
125 | `calendar-basic-setup' is used instead." | |
53e1a74c | 126 | (if (not (display-multi-frame-p)) |
38e3261c ER |
127 | (calendar-basic-setup arg) |
128 | (if (frame-live-p calendar-frame) (delete-frame calendar-frame)) | |
129 | (if (frame-live-p diary-frame) (delete-frame diary-frame)) | |
130 | (let ((pop-up-windows nil) | |
131 | (view-diary-entries-initially nil) | |
132 | (special-display-buffer-names nil)) | |
133 | (save-window-excursion | |
134 | (save-excursion (calendar-basic-setup arg)) | |
135 | (setq calendar-frame (make-frame calendar-frame-parameters)) | |
136 | (run-hooks 'calendar-after-frame-setup-hooks) | |
137 | (select-frame calendar-frame) | |
138 | (if (eq 'icon (cdr (assoc 'visibility | |
139 | (frame-parameters calendar-frame)))) | |
140 | (iconify-or-deiconify-frame)) | |
141 | (display-buffer calendar-buffer) | |
142 | (set-window-dedicated-p (selected-window) 'calendar) | |
143 | (setq diary-frame (make-frame diary-frame-parameters)) | |
144 | (run-hooks 'calendar-after-frame-setup-hooks) | |
145 | (select-frame diary-frame) | |
146 | (if (eq 'icon (cdr (assoc 'visibility | |
147 | (frame-parameters diary-frame)))) | |
148 | (iconify-or-deiconify-frame)) | |
149 | (save-excursion (diary)) | |
150 | (set-window-dedicated-p | |
151 | (display-buffer | |
0f12fdab ER |
152 | (if (not (memq 'fancy-diary-display diary-display-hook)) |
153 | (get-file-buffer diary-file) | |
154 | (if (not (bufferp (get-buffer fancy-diary-buffer))) | |
155 | (make-fancy-diary-buffer)) | |
156 | fancy-diary-buffer)) | |
38e3261c ER |
157 | 'diary))))) |
158 | ||
b5da410a KH |
159 | ;; Formerly (get-file-buffer diary-file) was added to the list here, |
160 | ;; but that isn't clean, and the value could even be nil. | |
38e3261c ER |
161 | (setq special-display-buffer-names |
162 | (append special-display-buffer-names | |
163 | (list "*Yahrzeits*" lunar-phases-buffer holiday-buffer | |
b5da410a | 164 | fancy-diary-buffer |
32eb9671 | 165 | other-calendars-buffer calendar-buffer))) |
38e3261c ER |
166 | |
167 | (run-hooks 'cal-x-load-hook) | |
168 | ||
169 | (provide 'cal-x) | |
170 | ||
6b61353c | 171 | ;;; arch-tag: c6dbddca-ae84-442d-87fc-244b76e38e17 |
38e3261c | 172 | ;;; cal-x.el ends here |