annotate lisp/calendar/cal-x.el @ 123:c77884c6318d

Added tag r20-1b14 for changeset d2f30a177268
author cvs
date Mon, 13 Aug 2007 09:26:04 +0200
parents 376386a54a3c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; cal-x.el --- calendar windows in dedicated frames in x-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1994 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Author: Michael Kifer <kifer@cs.sunysb.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Edward M. Reingold <reingold@cs.uiuc.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Modified for XEmacs by: Chuck Thompson <cthomp@cs.uiuc.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; Keywords: calendar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; Human-Keywords: calendar, dedicated frames, x-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; This file is part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; along with GNU Emacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; This collection of functions implements dedicated frames in x-windows for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; calendar.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; Comments, corrections, and improvements should be sent to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; Edward M. Reingold Department of Computer Science
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;; (217) 333-6733 University of Illinois at Urbana-Champaign
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;; reingold@cs.uiuc.edu 1304 West Springfield Avenue
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; Urbana, Illinois 61801
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (require 'calendar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (if (not (fboundp 'calendar-basic-setup))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (fset 'calendar-basic-setup (symbol-function 'calendar)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (defvar calendar-setup 'one-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 "The frame set up of the calendar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 The choices are `one-frame' (calendar and diary together in one separate,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 dediciated frame) or `two-frames' (calendar and diary in separate, dedicated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 frames); with any other value the current frame is used.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (defun calendar (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 "Choose between the one frame, two frame, or basic calendar displays.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 The original function `calendar' has been renamed `calendar-basic-setup'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (cond ((equal calendar-setup 'one-frame) (calendar-one-frame-setup arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ((equal calendar-setup 'two-frames) (calendar-two-frame-setup arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (t (calendar-basic-setup arg))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (defvar calendar-frame nil "Frame in which to display the calendar.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (defvar diary-frame nil "Frame in which to display the diary.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (defvar diary-frame-parameters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 '((name . "Diary") (height . 10) (width . 80) (unsplittable . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (font . "6x13") (auto-lower . t) (auto-raise . t) (minibuffer . nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 "Parameters of the diary frame, if the diary is in its own frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 Location and color should be set in .Xdefaults.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (defvar calendar-frame-parameters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 '((name . "Calendar") (minibuffer . nil) (height . 10) (width . 80)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (auto-raise . t) (auto-lower . t) (font . "6x13") (unsplittable . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (vertical-scroll-bars . nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 "Parameters of the calendar frame, if the calendar is in a separate frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 Location and color should be set in .Xdefaults.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (defvar calendar-and-diary-frame-parameters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 '((name . "Calendar") (height . 28) (width . 80) (minibuffer . nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (font . "6x13") (auto-raise . t) (auto-lower . t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 "Parameters of the frame that displays both the calendar and the diary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 Location and color should be set in .Xdefaults.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (defvar calendar-after-frame-setup-hooks nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 "Hooks to be run just after setting up a calendar frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 Can be used to change frame parameters, such as font, color, location, etc.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (defun calendar-not-using-window-system-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 "Return t if not running under a window system."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (if (fboundp 'device-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (not (eq (device-type (selected-device)) 'x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (not window-system)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (defun calendar-deiconify-frame (frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 "Deiconify the given frame if it is currently iconified."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (if (string-match "XEmacs" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (if (frame-iconified-p frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (deiconify-frame frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (if (eq 'icon (cdr (assoc 'visibility (frame-parameters frame))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;; This isn't necessary going to do what is intended since it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;; only works with the selected frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (iconify-or-deiconify-frame))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (defun calendar-one-frame-setup (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 "Start calendar and display it in a dedicated frame together with the diary."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (if (calendar-not-using-window-system-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (calendar-basic-setup arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (if (frame-live-p calendar-frame) (delete-frame calendar-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (if (frame-live-p diary-frame) (delete-frame diary-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (let ((special-display-buffer-names nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (view-diary-entries-initially t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (setq calendar-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (make-frame calendar-and-diary-frame-parameters))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (run-hooks 'calendar-after-frame-setup-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (select-frame calendar-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (calendar-deiconify-frame calendar-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (calendar-basic-setup arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (set-window-dedicated-p (selected-window) 'calendar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (set-window-dedicated-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (display-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (if (not (memq 'fancy-diary-display diary-display-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (get-file-buffer diary-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (if (not (bufferp (get-buffer fancy-diary-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (make-fancy-diary-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 fancy-diary-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 'diary))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (defun calendar-two-frame-setup (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 "Start calendar and diary in separate, dedicated frames."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (if (calendar-not-using-window-system-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (calendar-basic-setup arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (if (frame-live-p calendar-frame) (delete-frame calendar-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (if (frame-live-p diary-frame) (delete-frame diary-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (let ((pop-up-windows nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (view-diary-entries-initially nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (special-display-buffer-names nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (save-excursion (calendar-basic-setup arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (setq calendar-frame (make-frame calendar-frame-parameters))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (run-hooks 'calendar-after-frame-setup-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (select-frame calendar-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (calendar-deiconify-frame calendar-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (display-buffer calendar-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (set-window-dedicated-p (selected-window) 'calendar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (setq diary-frame (make-frame diary-frame-parameters))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (run-hooks 'calendar-after-frame-setup-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (select-frame diary-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (calendar-deiconify-frame diary-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (save-excursion (diary))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (set-window-dedicated-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (display-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (if (not (memq 'fancy-diary-display diary-display-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (get-file-buffer diary-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (if (not (bufferp (get-buffer fancy-diary-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (make-fancy-diary-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 fancy-diary-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 'diary)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (defun make-fancy-diary-buffer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (set-buffer (get-buffer-create fancy-diary-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (setq buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (make-local-variable 'mode-line-format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (calendar-set-mode-line "Diary Entries")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (setq buffer-read-only t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (if (not (string-match "XEmacs" emacs-version))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (setq special-display-buffer-names
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (append special-display-buffer-names
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (list "*Yahrzeits*" lunar-phases-buffer holiday-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 fancy-diary-buffer (get-file-buffer diary-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 calendar-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (run-hooks 'cal-x-load-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (provide 'cal-x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ;;; cal-x.el ends here