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