Unquote lambda functions. Add autoload cookies to functions formerly
[emacs.git] / lisp / calendar / cal-x.el
blob294927c4a11873d6b099c6fe6f07606fb1a93196
1 ;;; cal-x.el --- calendar windows in dedicated frames in X
3 ;; Copyright (C) 1994, 1995, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
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>
9 ;; Keywords: calendar
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 3, or (at your option)
17 ;; any later version.
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.
29 ;;; Commentary:
31 ;; This collection of functions implements dedicated frames in X for
32 ;; calendar.el.
34 ;;; Code:
36 (require 'calendar)
38 (defvar calendar-frame nil "Frame in which to display the calendar.")
40 (defvar diary-frame nil "Frame in which to display the diary.")
42 ;; This should not specify the font. That's up to the user.
43 ;; Certainly it should not specify auto-lower and auto-raise
44 ;; since most users won't like that.
45 (defvar diary-frame-parameters
46 '((name . "Diary") (title . "Diary") (height . 10) (width . 80)
47 (unsplittable . 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.")
51 (defvar calendar-frame-parameters
52 '((name . "Calendar") (title . "Calendar") (minibuffer . nil)
53 (height . 10) (width . 80) (unsplittable . t) (vertical-scroll-bars . nil))
54 "Parameters of the calendar frame, if the calendar is in a separate frame.
55 Location and color should be set in .Xdefaults.")
57 (defvar calendar-and-diary-frame-parameters
58 '((name . "Calendar") (title . "Calendar") (height . 28) (width . 80)
59 (minibuffer . nil))
60 "Parameters of the frame that displays both the calendar and the diary.
61 Location and color should be set in .Xdefaults.")
63 (defvar calendar-after-frame-setup-hooks nil
64 "Hooks to be run just after setting up a calendar frame.
65 Can be used to change frame parameters, such as font, color, location, etc.")
67 ;; calendar-basic-setup is called first, and will autoload diary-lib.
68 (declare-function make-fancy-diary-buffer "diary-lib" nil)
70 (defun calendar-one-frame-setup (&optional arg)
71 "Start calendar and display it in a dedicated frame together with the diary.
72 This function requires a display capable of multiple frames, else
73 `calendar-basic-setup' is used instead."
74 (if (not (display-multi-frame-p))
75 (calendar-basic-setup arg)
76 (if (frame-live-p calendar-frame) (delete-frame calendar-frame))
77 (if (frame-live-p diary-frame) (delete-frame diary-frame))
78 (let ((special-display-buffer-names nil)
79 (view-diary-entries-initially t))
80 (save-window-excursion
81 (save-excursion
82 (setq calendar-frame
83 (make-frame calendar-and-diary-frame-parameters))
84 (run-hooks 'calendar-after-frame-setup-hooks)
85 (select-frame calendar-frame)
86 (if (eq 'icon (cdr (assoc 'visibility
87 (frame-parameters calendar-frame))))
88 (iconify-or-deiconify-frame))
89 (calendar-basic-setup arg)
90 (set-window-dedicated-p (selected-window) t)
91 (set-window-dedicated-p
92 (display-buffer
93 (if (not (memq 'fancy-diary-display diary-display-hook))
94 (get-file-buffer diary-file)
95 (if (not (bufferp (get-buffer fancy-diary-buffer)))
96 (make-fancy-diary-buffer))
97 fancy-diary-buffer))
98 t))))))
100 (defun calendar-only-one-frame-setup (&optional arg)
101 "Start calendar and display it in a dedicated frame.
102 This function requires a display capable of multiple frames, else
103 `calendar-basic-setup' is used instead."
104 (if (not (display-multi-frame-p))
105 (calendar-basic-setup arg)
106 (if (frame-live-p calendar-frame) (delete-frame calendar-frame))
107 (let ((special-display-buffer-names nil)
108 (view-diary-entries-initially nil))
109 (save-window-excursion
110 (save-excursion
111 (setq calendar-frame
112 (make-frame calendar-frame-parameters))
113 (run-hooks 'calendar-after-frame-setup-hooks)
114 (select-frame calendar-frame)
115 (if (eq 'icon (cdr (assoc 'visibility
116 (frame-parameters calendar-frame))))
117 (iconify-or-deiconify-frame))
118 (calendar-basic-setup arg)
119 (set-window-dedicated-p (selected-window) t))))))
121 (defun calendar-two-frame-setup (&optional arg)
122 "Start calendar and diary in separate, dedicated frames.
123 This function requires a display capable of multiple frames, else
124 `calendar-basic-setup' is used instead."
125 (if (not (display-multi-frame-p))
126 (calendar-basic-setup arg)
127 (if (frame-live-p calendar-frame) (delete-frame calendar-frame))
128 (if (frame-live-p diary-frame) (delete-frame diary-frame))
129 (let ((pop-up-windows nil)
130 (view-diary-entries-initially nil)
131 (special-display-buffer-names nil))
132 (save-window-excursion
133 (save-excursion (calendar-basic-setup arg))
134 (setq calendar-frame (make-frame calendar-frame-parameters))
135 (run-hooks 'calendar-after-frame-setup-hooks)
136 (select-frame calendar-frame)
137 (if (eq 'icon (cdr (assoc 'visibility
138 (frame-parameters calendar-frame))))
139 (iconify-or-deiconify-frame))
140 (display-buffer calendar-buffer)
141 (set-window-dedicated-p (selected-window) t)
142 (setq diary-frame (make-frame diary-frame-parameters))
143 (run-hooks 'calendar-after-frame-setup-hooks)
144 (select-frame diary-frame)
145 (if (eq 'icon (cdr (assoc 'visibility
146 (frame-parameters diary-frame))))
147 (iconify-or-deiconify-frame))
148 (save-excursion (diary))
149 (set-window-dedicated-p
150 (display-buffer
151 (if (not (memq 'fancy-diary-display diary-display-hook))
152 (get-file-buffer diary-file)
153 (if (not (bufferp (get-buffer fancy-diary-buffer)))
154 (make-fancy-diary-buffer))
155 fancy-diary-buffer))
156 t)))))
158 ;; Formerly (get-file-buffer diary-file) was added to the list here,
159 ;; but that isn't clean, and the value could even be nil.
160 (setq special-display-buffer-names
161 (append special-display-buffer-names
162 (list "*Yahrzeits*" lunar-phases-buffer holiday-buffer
163 fancy-diary-buffer
164 other-calendars-buffer calendar-buffer)))
166 (run-hooks 'cal-x-load-hook)
168 (provide 'cal-x)
170 ;; arch-tag: c6dbddca-ae84-442d-87fc-244b76e38e17
171 ;;; cal-x.el ends here