comparison lisp/calendar/cal-x.el @ 93188:bb7e96e383ab

(diary-frame-parameters, calendar-frame-parameters) (calendar-and-diary-frame-parameters): Doc fixes. (make-fancy-diary-buffer): Remove declaration. (calendar-dedicate-diary): Replace call to deleted function make-fancy-diary-buffer. (calendar-frame-setup): New function. (calendar-one-frame-setup, calendar-only-one-frame-setup) (calendar-two-frame-setup): Call calendar-frame-setup to do the actual work, and mark as obsolete. (special-display-buffer-names): Don't mess with this; it's not our business. (cal-x-load-hook): Defvar it, and mark as obsolete.
author Glenn Morris <rgm@gnu.org>
date Tue, 25 Mar 2008 03:43:31 +0000
parents 531ac371602f
children 9785749a1557
comparison
equal deleted inserted replaced
93187:c68684b0a2d1 93188:bb7e96e383ab
37 37
38 (defcustom diary-frame-parameters 38 (defcustom diary-frame-parameters
39 '((name . "Diary") (title . "Diary") (height . 10) (width . 80) 39 '((name . "Diary") (title . "Diary") (height . 10) (width . 80)
40 (unsplittable . t) (minibuffer . nil)) 40 (unsplittable . t) (minibuffer . nil))
41 "Parameters of the diary frame, if the diary is in its own frame. 41 "Parameters of the diary frame, if the diary is in its own frame.
42 Location and color should be set in .Xdefaults." ; why? 42 Relevant if `calendar-setup' has the value `two-frames'."
43 :type 'alist 43 :type 'alist
44 :options '((name string) (title string) (height integer) (width integer) 44 :options '((name string) (title string) (height integer) (width integer)
45 (unsplittable boolean) (minibuffer boolean) 45 (unsplittable boolean) (minibuffer boolean)
46 (vertical-scroll-bars boolean)) 46 (vertical-scroll-bars boolean))
47 :group 'calendar) 47 :group 'calendar)
48 48
49 (defcustom calendar-frame-parameters 49 (defcustom calendar-frame-parameters
50 '((name . "Calendar") (title . "Calendar") (height . 10) (width . 80) 50 '((name . "Calendar") (title . "Calendar") (height . 10) (width . 80)
51 (unsplittable . t) (minibuffer . nil) (vertical-scroll-bars . nil)) 51 (unsplittable . t) (minibuffer . nil) (vertical-scroll-bars . nil))
52 "Parameters of the calendar frame, if the calendar is in a separate frame. 52 "Parameters of the calendar frame, if the calendar is in a separate frame.
53 Location and color should be set in .Xdefaults." 53 Relevant if `calendar-setup' has the value `calendar-only' or `two-frames'."
54 :type 'alist 54 :type 'alist
55 :options '((name string) (title string) (height integer) (width integer) 55 :options '((name string) (title string) (height integer) (width integer)
56 (unsplittable boolean) (minibuffer boolean) 56 (unsplittable boolean) (minibuffer boolean)
57 (vertical-scroll-bars boolean)) 57 (vertical-scroll-bars boolean))
58 :group 'calendar) 58 :group 'calendar)
59 59
60 (defcustom calendar-and-diary-frame-parameters 60 (defcustom calendar-and-diary-frame-parameters
61 '((name . "Calendar") (title . "Calendar") (height . 28) (width . 80) 61 '((name . "Calendar") (title . "Calendar") (height . 28) (width . 80)
62 (minibuffer . nil)) 62 (minibuffer . nil))
63 "Parameters of the frame that displays both the calendar and the diary. 63 "Parameters of the frame that displays both the calendar and the diary.
64 Location and color should be set in .Xdefaults." 64 Relevant if `calendar-setup' has the value `one-frame'."
65 :type 'alist 65 :type 'alist
66 :options '((name string) (title string) (height integer) (width integer) 66 :options '((name string) (title string) (height integer) (width integer)
67 (unsplittable boolean) (minibuffer boolean) 67 (unsplittable boolean) (minibuffer boolean)
68 (vertical-scroll-bars boolean)) 68 (vertical-scroll-bars boolean))
69 :group 'calendar) 69 :group 'calendar)
87 (run-hooks 'calendar-after-frame-setup-hooks) 87 (run-hooks 'calendar-after-frame-setup-hooks)
88 (select-frame frame) 88 (select-frame frame)
89 (if (eq 'icon (cdr (assoc 'visibility (frame-parameters frame)))) 89 (if (eq 'icon (cdr (assoc 'visibility (frame-parameters frame))))
90 (iconify-or-deiconify-frame))) 90 (iconify-or-deiconify-frame)))
91 91
92 ;; calendar-basic-setup is called first, and will autoload diary-lib.
93 (declare-function make-fancy-diary-buffer "diary-lib" nil)
94
95 (defun calendar-dedicate-diary () 92 (defun calendar-dedicate-diary ()
96 "Dedicate the window associated with the diary buffer." 93 "Display and dedicate the window associated with the diary buffer."
97 (set-window-dedicated-p 94 (set-window-dedicated-p
98 (display-buffer 95 (display-buffer
99 (if (not (memq 'fancy-diary-display diary-display-hook)) 96 (if (not (memq 'fancy-diary-display diary-display-hook))
100 (get-file-buffer diary-file) 97 (get-file-buffer diary-file)
98 ;; If there are no diary entries, there won't be a fancy-diary
99 ;; to dedicate, so make a basic one.
101 (or (buffer-live-p fancy-diary-buffer) 100 (or (buffer-live-p fancy-diary-buffer)
102 (make-fancy-diary-buffer)) 101 (calendar-in-read-only-buffer fancy-diary-buffer
102 (calendar-set-mode-line "Diary Entries")))
103 fancy-diary-buffer)) 103 fancy-diary-buffer))
104 t)) 104 t))
105 105
106 ;;; FIXME ../../src/emacs -Q --eval "(setq calendar-setup 'calendar-only)" -f calendar
107 ;;;###cal-autoload 106 ;;;###cal-autoload
108 (defun calendar-one-frame-setup (&optional arg only) 107 (defun calendar-frame-setup (config &optional prompt)
109 "Start calendar and display it in a dedicated frame. 108 "Display the calendar, and optionally the diary, in a separate frame.
110 Also show the diary in that frame, unless ONLY is non-nil. The optional 109 CONFIG should be one of:
111 argument ARG is passed to `calendar-basic-setup'. If the display 110 `calendar-only' - just the calendar, no diary
112 is not capable of multiple frames, `calendar-basic-setup' is all 111 `one-frame' - calendar and diary in a single frame
113 that is used." 112 `two-frames' - calendar and diary each in a separate frame
114 (if (not (display-multi-frame-p)) 113
115 (calendar-basic-setup arg) 114 If CONFIG has any other value, or if the display is not capable of
115 multiple frames, then `calendar-basic-setup' is called.
116
117 If PROMPT is non-nil, prompt for the month and year to use."
118 (if (not (and (display-multi-frame-p)
119 (memq config '(calendar-only one-frame two-frames))))
120 (calendar-basic-setup prompt)
116 (if (frame-live-p calendar-frame) (delete-frame calendar-frame)) 121 (if (frame-live-p calendar-frame) (delete-frame calendar-frame))
117 (unless only 122 (unless (eq config 'calendar-only)
118 (if (frame-live-p diary-frame) (delete-frame diary-frame))) 123 (if (frame-live-p diary-frame) (delete-frame diary-frame)))
119 (let ((special-display-buffer-names nil) 124 (let ((view-diary-entries-initially (eq config 'one-frame))
120 (view-diary-entries-initially (not only))) 125 ;; For final calendar-dedicate-diary in two-frames case.
126 (pop-up-windows nil))
121 (save-window-excursion 127 (save-window-excursion
122 (save-excursion 128 ;; Do diary first so that calendar is always left current.
129 (when (eq config 'two-frames)
123 (calendar-frame-1 130 (calendar-frame-1
124 (setq calendar-frame 131 (setq diary-frame (make-frame diary-frame-parameters)))
125 (make-frame (if only 132 (diary)
126 calendar-frame-parameters 133 (calendar-dedicate-diary))
127 calendar-and-diary-frame-parameters)))) 134 (calendar-frame-1
128 (calendar-basic-setup arg) ; FIXME move? 135 (setq calendar-frame
129 ;; FIXME display-buffer? 136 (make-frame (if (eq config 'one-frame)
130 (set-window-dedicated-p (selected-window) t) 137 calendar-and-diary-frame-parameters
131 (unless only (calendar-dedicate-diary))))))) 138 calendar-frame-parameters))))
139 (calendar-basic-setup prompt (not (eq config 'one-frame)))
140 (set-window-buffer (selected-window) calendar-buffer)
141 (set-window-dedicated-p (selected-window) t)
142 (if (eq config 'one-frame)
143 (calendar-dedicate-diary))))))
144
132 145
133 ;;;###cal-autoload 146 ;;;###cal-autoload
134 (defun calendar-only-one-frame-setup (&optional arg) 147 (defun calendar-one-frame-setup (&optional prompt)
135 "Start calendar and display it in a dedicated frame. 148 "Display calendar and diary in a single dedicated frame.
136 The optional argument ARG is passed to `calendar-basic-setup'. 149 See `calendar-frame-setup' for more information."
137 If the display is not capable of multiple frames, `calendar-basic-setup' 150 (calendar-frame-setup 'one-frame prompt))
138 is all that is used." 151
139 (calendar-one-frame-setup arg t)) 152 (make-obsolete 'calendar-one-frame-setup 'calendar-frame-setup "23.1")
153
140 154
141 ;;;###cal-autoload 155 ;;;###cal-autoload
142 (defun calendar-two-frame-setup (&optional arg) 156 (defun calendar-only-one-frame-setup (&optional prompt)
143 "Start calendar and diary in separate, dedicated frames. 157 "Display calendar in a dedicated frame.
144 The optional argument ARG is passed to `calendar-basic-setup'. 158 See `calendar-frame-setup' for more information."
145 If the display is not capable of multiple frames, `calendar-basic-setup' 159 (calendar-frame-setup 'calendar-only prompt))
146 is all that is used."
147 (if (not (display-multi-frame-p))
148 (calendar-basic-setup arg)
149 (if (frame-live-p calendar-frame) (delete-frame calendar-frame))
150 (if (frame-live-p diary-frame) (delete-frame diary-frame))
151 (let ((pop-up-windows nil)
152 (view-diary-entries-initially nil)
153 (special-display-buffer-names nil))
154 (save-window-excursion
155 ;; FIXME why does this do things in a slightly different order
156 ;; to calendar-one-frame-setup?
157 (save-excursion (calendar-basic-setup arg))
158 (calendar-frame-1
159 (setq calendar-frame (make-frame calendar-frame-parameters)))
160 (display-buffer calendar-buffer)
161 (set-window-dedicated-p (selected-window) t)
162 (calendar-frame-1
163 (setq diary-frame (make-frame diary-frame-parameters)))
164 (save-excursion (diary))
165 (calendar-dedicate-diary)))))
166 160
167 ;; Formerly (get-file-buffer diary-file) was added to the list here, 161
168 ;; but that isn't clean, and the value could even be nil. 162 (make-obsolete 'calendar-only-one-frame-setup 'calendar-frame-setup "23.1")
169 ;; FIXME is this really our business? 163
170 (setq special-display-buffer-names 164 ;;;###cal-autoload
171 (append special-display-buffer-names 165 (defun calendar-two-frame-setup (&optional prompt)
172 (list cal-hebrew-yahrzeit-buffer 166 "Display calendar and diary in separate, dedicated frames.
173 lunar-phases-buffer holiday-buffer fancy-diary-buffer 167 See `calendar-frame-setup' for more information."
174 other-calendars-buffer calendar-buffer))) 168 (calendar-frame-setup 'two-frames prompt))
169
170 (make-obsolete 'calendar-two-frame-setup 'calendar-frame-setup "23.1")
171
172
173 ;; Undocumented and probably useless.
174 (defvar cal-x-load-hook nil
175 "Hook run on loading of the `cal-x' package.")
176 (make-obsolete-variable 'cal-x-load-hook "it will be removed in future." "23.1")
175 177
176 (run-hooks 'cal-x-load-hook) 178 (run-hooks 'cal-x-load-hook)
179
177 180
178 (provide 'cal-x) 181 (provide 'cal-x)
179 182
180 ;; arch-tag: c6dbddca-ae84-442d-87fc-244b76e38e17 183 ;; arch-tag: c6dbddca-ae84-442d-87fc-244b76e38e17
181 ;;; cal-x.el ends here 184 ;;; cal-x.el ends here