Commit | Line | Data |
---|---|---|
189134c3 | 1 | ;;; cal-x.el --- calendar windows in dedicated frames in X |
38e3261c | 2 | |
ed554ebd | 3 | ;; Copyright (C) 1994, 1995, 2005 Free Software Foundation, Inc. |
38e3261c ER |
4 | |
5 | ;; Author: Michael Kifer <kifer@cs.sunysb.edu> | |
6 | ;; Edward M. Reingold <reingold@cs.uiuc.edu> | |
ed554ebd | 7 | ;; Maintainer: Glenn Morris <gmorris@ast.cam.ac.uk> |
38e3261c | 8 | ;; Keywords: calendar |
189134c3 | 9 | ;; Human-Keywords: calendar, dedicated frames, X Window System |
38e3261c ER |
10 | |
11 | ;; This file is part of GNU Emacs. | |
12 | ||
13 | ;; GNU Emacs is free software; you can redistribute it and/or modify | |
14 | ;; it under the terms of the GNU General Public License as published by | |
15 | ;; the Free Software Foundation; either version 2, or (at your option) | |
16 | ;; any later version. | |
17 | ||
18 | ;; GNU Emacs is distributed in the hope that it will be useful, | |
19 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 | ;; GNU General Public License for more details. | |
22 | ||
23 | ;; You should have received a copy of the GNU General Public License | |
b578f267 EN |
24 | ;; along with GNU Emacs; see the file COPYING. If not, write to the |
25 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
26 | ;; Boston, MA 02111-1307, USA. | |
38e3261c ER |
27 | |
28 | ;;; Commentary: | |
29 | ||
189134c3 | 30 | ;; This collection of functions implements dedicated frames in X for |
38e3261c ER |
31 | ;; calendar.el. |
32 | ||
33 | ;; Comments, corrections, and improvements should be sent to | |
34 | ;; Edward M. Reingold Department of Computer Science | |
35 | ;; (217) 333-6733 University of Illinois at Urbana-Champaign | |
36 | ;; reingold@cs.uiuc.edu 1304 West Springfield Avenue | |
37 | ;; Urbana, Illinois 61801 | |
38 | ||
39 | ;;; Code: | |
40 | ||
10dbf039 RS |
41 | (require 'calendar) |
42 | ||
38e3261c ER |
43 | (defvar calendar-frame nil "Frame in which to display the calendar.") |
44 | ||
45 | (defvar diary-frame nil "Frame in which to display the diary.") | |
a1506d29 | 46 | |
eb18bc57 RS |
47 | ;; This should not specify the font. That's up to the user. |
48 | ;; Certainly it should not specify auto-lower and auto-raise | |
49 | ;; since most users won't like that. | |
38e3261c | 50 | (defvar diary-frame-parameters |
4a7cd65c ER |
51 | '((name . "Diary") (title . "Diary") (height . 10) (width . 80) |
52 | (unsplittable . t) (minibuffer . nil)) | |
38e3261c ER |
53 | "Parameters of the diary frame, if the diary is in its own frame. |
54 | Location and color should be set in .Xdefaults.") | |
a1506d29 | 55 | |
38e3261c | 56 | (defvar calendar-frame-parameters |
4a7cd65c ER |
57 | '((name . "Calendar") (title . "Calendar") (minibuffer . nil) |
58 | (height . 10) (width . 80) (unsplittable . t) (vertical-scroll-bars . nil)) | |
38e3261c ER |
59 | "Parameters of the calendar frame, if the calendar is in a separate frame. |
60 | Location and color should be set in .Xdefaults.") | |
61 | ||
62 | (defvar calendar-and-diary-frame-parameters | |
4a7cd65c ER |
63 | '((name . "Calendar") (title . "Calendar") (height . 28) (width . 80) |
64 | (minibuffer . nil)) | |
38e3261c ER |
65 | "Parameters of the frame that displays both the calendar and the diary. |
66 | Location and color should be set in .Xdefaults.") | |
a1506d29 | 67 | |
38e3261c ER |
68 | (defvar calendar-after-frame-setup-hooks nil |
69 | "Hooks to be run just after setting up a calendar frame. | |
70 | Can be used to change frame parameters, such as font, color, location, etc.") | |
a1506d29 | 71 | |
38e3261c | 72 | (defun calendar-one-frame-setup (&optional arg) |
091f6920 GM |
73 | "Start calendar and display it in a dedicated frame together with the diary. |
74 | This function requires a display capable of multiple frames, else | |
75 | `calendar-basic-setup' is used instead." | |
53e1a74c | 76 | (if (not (display-multi-frame-p)) |
38e3261c ER |
77 | (calendar-basic-setup arg) |
78 | (if (frame-live-p calendar-frame) (delete-frame calendar-frame)) | |
79 | (if (frame-live-p diary-frame) (delete-frame diary-frame)) | |
80 | (let ((special-display-buffer-names nil) | |
81 | (view-diary-entries-initially t)) | |
82 | (save-window-excursion | |
83 | (save-excursion | |
84 | (setq calendar-frame | |
85 | (make-frame calendar-and-diary-frame-parameters)) | |
86 | (run-hooks 'calendar-after-frame-setup-hooks) | |
87 | (select-frame calendar-frame) | |
88 | (if (eq 'icon (cdr (assoc 'visibility | |
89 | (frame-parameters calendar-frame)))) | |
90 | (iconify-or-deiconify-frame)) | |
91 | (calendar-basic-setup arg) | |
ed554ebd | 92 | (set-window-dedicated-p (selected-window) t) |
38e3261c ER |
93 | (set-window-dedicated-p |
94 | (display-buffer | |
0f12fdab ER |
95 | (if (not (memq 'fancy-diary-display diary-display-hook)) |
96 | (get-file-buffer diary-file) | |
97 | (if (not (bufferp (get-buffer fancy-diary-buffer))) | |
98 | (make-fancy-diary-buffer)) | |
99 | fancy-diary-buffer)) | |
ed554ebd | 100 | t)))))) |
77a7efce KH |
101 | |
102 | (defun calendar-only-one-frame-setup (&optional arg) | |
091f6920 GM |
103 | "Start calendar and display it in a dedicated frame. |
104 | This function requires a display capable of multiple frames, else | |
105 | `calendar-basic-setup' is used instead." | |
53e1a74c | 106 | (if (not (display-multi-frame-p)) |
77a7efce KH |
107 | (calendar-basic-setup arg) |
108 | (if (frame-live-p calendar-frame) (delete-frame calendar-frame)) | |
109 | (let ((special-display-buffer-names nil) | |
110 | (view-diary-entries-initially nil)) | |
111 | (save-window-excursion | |
112 | (save-excursion | |
113 | (setq calendar-frame | |
114 | (make-frame calendar-frame-parameters)) | |
115 | (run-hooks 'calendar-after-frame-setup-hooks) | |
116 | (select-frame calendar-frame) | |
117 | (if (eq 'icon (cdr (assoc 'visibility | |
118 | (frame-parameters calendar-frame)))) | |
119 | (iconify-or-deiconify-frame)) | |
120 | (calendar-basic-setup arg) | |
ed554ebd | 121 | (set-window-dedicated-p (selected-window) t)))))) |
0f12fdab | 122 | |
38e3261c | 123 | (defun calendar-two-frame-setup (&optional arg) |
091f6920 GM |
124 | "Start calendar and diary in separate, dedicated frames. |
125 | This function requires a display capable of multiple frames, else | |
126 | `calendar-basic-setup' is used instead." | |
53e1a74c | 127 | (if (not (display-multi-frame-p)) |
38e3261c ER |
128 | (calendar-basic-setup arg) |
129 | (if (frame-live-p calendar-frame) (delete-frame calendar-frame)) | |
130 | (if (frame-live-p diary-frame) (delete-frame diary-frame)) | |
131 | (let ((pop-up-windows nil) | |
132 | (view-diary-entries-initially nil) | |
133 | (special-display-buffer-names nil)) | |
134 | (save-window-excursion | |
135 | (save-excursion (calendar-basic-setup arg)) | |
136 | (setq calendar-frame (make-frame calendar-frame-parameters)) | |
137 | (run-hooks 'calendar-after-frame-setup-hooks) | |
138 | (select-frame calendar-frame) | |
139 | (if (eq 'icon (cdr (assoc 'visibility | |
140 | (frame-parameters calendar-frame)))) | |
141 | (iconify-or-deiconify-frame)) | |
142 | (display-buffer calendar-buffer) | |
ed554ebd | 143 | (set-window-dedicated-p (selected-window) t) |
38e3261c ER |
144 | (setq diary-frame (make-frame diary-frame-parameters)) |
145 | (run-hooks 'calendar-after-frame-setup-hooks) | |
146 | (select-frame diary-frame) | |
147 | (if (eq 'icon (cdr (assoc 'visibility | |
148 | (frame-parameters diary-frame)))) | |
149 | (iconify-or-deiconify-frame)) | |
150 | (save-excursion (diary)) | |
151 | (set-window-dedicated-p | |
152 | (display-buffer | |
0f12fdab ER |
153 | (if (not (memq 'fancy-diary-display diary-display-hook)) |
154 | (get-file-buffer diary-file) | |
155 | (if (not (bufferp (get-buffer fancy-diary-buffer))) | |
156 | (make-fancy-diary-buffer)) | |
157 | fancy-diary-buffer)) | |
ed554ebd | 158 | t))))) |
38e3261c | 159 | |
b5da410a KH |
160 | ;; Formerly (get-file-buffer diary-file) was added to the list here, |
161 | ;; but that isn't clean, and the value could even be nil. | |
38e3261c ER |
162 | (setq special-display-buffer-names |
163 | (append special-display-buffer-names | |
164 | (list "*Yahrzeits*" lunar-phases-buffer holiday-buffer | |
b5da410a | 165 | fancy-diary-buffer |
32eb9671 | 166 | other-calendars-buffer calendar-buffer))) |
38e3261c ER |
167 | |
168 | (run-hooks 'cal-x-load-hook) | |
169 | ||
170 | (provide 'cal-x) | |
171 | ||
ab5796a9 | 172 | ;;; arch-tag: c6dbddca-ae84-442d-87fc-244b76e38e17 |
38e3261c | 173 | ;;; cal-x.el ends here |