comparison lisp/calendar/calendar.el @ 93187:c68684b0a2d1

(calendar-remove-frame-by-deleting): Default to t. Add to 'calendar group. (calendar): Doc fix. Use calendar-frame-setup. (calendar-basic-setup): Doc fix. Add optional NODISPLAY argument. (generate-calendar-window): Doc fix.
author Glenn Morris <rgm@gnu.org>
date Tue, 25 Mar 2008 03:42:55 +0000
parents b801762e0062
children 940127da5863
comparison
equal deleted inserted replaced
93186:3c66b698cc43 93187:c68684b0a2d1
200 "Non-nil means mark dates with diary entries, in the calendar window. 200 "Non-nil means mark dates with diary entries, in the calendar window.
201 The marking symbol is specified by the variable `diary-entry-marker'." 201 The marking symbol is specified by the variable `diary-entry-marker'."
202 :type 'boolean 202 :type 'boolean
203 :group 'diary) 203 :group 'diary)
204 204
205 (defcustom calendar-remove-frame-by-deleting nil 205 (defcustom calendar-remove-frame-by-deleting t
206 "Determine how the calendar mode removes a frame no longer needed. 206 "Determine how the calendar mode removes a frame no longer needed.
207 If nil, make an icon of the frame. If non-nil, delete the frame." 207 If nil, make an icon of the frame. If non-nil, delete the frame."
208 :type 'boolean 208 :type 'boolean
209 :group 'view) 209 :version "23.1" ; changed from nil to t
210 :group 'view
211 :group 'calendar)
210 212
211 (defface calendar-today 213 (defface calendar-today
212 '((t (:underline t))) 214 '((t (:underline t)))
213 "Face for indicating today's date." 215 "Face for indicating today's date."
214 :group 'diary) 216 :group 'diary)
1338 (/ offset-years 400) 1340 (/ offset-years 400)
1339 (calendar-day-number '(12 31 -1))))))) ; days in year 1 BC 1341 (calendar-day-number '(12 31 -1))))))) ; days in year 1 BC
1340 1342
1341 ;;;###autoload 1343 ;;;###autoload
1342 (defun calendar (&optional arg) 1344 (defun calendar (&optional arg)
1343 "Choose between the one frame, two frame, or basic calendar displays. 1345 "Display a three-month Gregorian calendar.
1344 If called with an optional prefix argument ARG, prompts for month and year. 1346 The three months appear side by side, with the current month in
1345 1347 the middle surrounded by the previous and next months. The
1346 The original function `calendar' has been renamed `calendar-basic-setup'. 1348 cursor is put on today's date. If optional prefix argument ARG
1347 See the documentation of that function for more information." 1349 is non-nil, prompts for the central month and year.
1350
1351 Once in the calendar window, future or past months can be moved
1352 into view. Arbitrary months can be displayed, or the calendar
1353 can be scrolled forward or backward. The cursor can be moved
1354 forward or backward by one day, one week, one month, or one year.
1355 All of these commands take prefix arguments which, when negative,
1356 cause movement in the opposite direction. For convenience, the
1357 digit keys and the minus sign are automatically prefixes. Use
1358 \\[describe-mode] for details of the key bindings in the calendar
1359 window.
1360
1361 Displays the calendar in a separate window, or optionally in a
1362 separate frame, depending on the value of `calendar-setup'.
1363
1364 If `view-diary-entries-initially' is non-nil, also displays the
1365 diary entries for the current date (or however many days
1366 `number-of-diary-entries' specifies). This variable can be
1367 overridden by `calendar-setup'. As well as being displayed,
1368 diary entries can also be marked on the calendar (see
1369 `mark-diary-entries-in-calendar').
1370
1371 Runs the following hooks:
1372
1373 `calendar-load-hook' - after loading calendar.el
1374 `today-visible-calendar-hook', `today-invisible-calendar-hook' - after
1375 generating a calendar, if today's date is visible or not, respectively
1376 `initial-calendar-window-hook' - after first creating a calendar
1377
1378 This function is suitable for execution in a .emacs file."
1348 (interactive "P") 1379 (interactive "P")
1349 (cond ((equal calendar-setup 'one-frame) (calendar-one-frame-setup arg)) 1380 ;; Avoid loading cal-x unless it will be used.
1350 ((equal calendar-setup 'two-frames) (calendar-two-frame-setup arg)) 1381 (if (and (memq calendar-setup '(one-frame two-frames calendar-only))
1351 ((equal calendar-setup 'calendar-only) 1382 (display-multi-frame-p))
1352 (calendar-only-one-frame-setup arg)) 1383 (calendar-frame-setup calendar-setup arg)
1353 (t (calendar-basic-setup arg)))) 1384 (calendar-basic-setup arg)))
1354 1385
1355 (defun calendar-basic-setup (&optional arg) 1386 (defun calendar-basic-setup (&optional arg nodisplay)
1356 "Display a three-month calendar in another window. 1387 "Create a three-month calendar.
1357 The three months appear side by side, with the current month in the middle 1388 If optional prefix argument ARG is non-nil, prompts for the month
1358 surrounded by the previous and next months. The cursor is put on today's date. 1389 and year, else uses the current date. If NODISPLAY is non-nil, don't
1359 1390 display the generated calendar."
1360 If called with an optional prefix argument ARG, prompts for month and year.
1361
1362 This function is suitable for execution in a .emacs file; appropriate setting
1363 of the variable `view-diary-entries-initially' will cause the diary entries for
1364 the current date to be displayed in another window. The value of the variable
1365 `number-of-diary-entries' controls the number of days of diary entries
1366 displayed upon initial display of the calendar.
1367
1368 Once in the calendar window, future or past months can be moved into view.
1369 Arbitrary months can be displayed, or the calendar can be scrolled forward
1370 or backward.
1371
1372 The cursor can be moved forward or backward by one day, one week, one month,
1373 or one year. All of these commands take prefix arguments which, when negative,
1374 cause movement in the opposite direction. For convenience, the digit keys
1375 and the minus sign are automatically prefixes. The window is replotted as
1376 necessary to display the desired date.
1377
1378 Diary entries can be marked on the calendar or displayed in another window.
1379
1380 Use \\[describe-mode] for details of the key bindings in the calendar window.
1381
1382 The Gregorian calendar is assumed.
1383
1384 After loading the calendar, the hooks given by the variable
1385 `calendar-load-hook' are run. This is the place to add key bindings to the
1386 `calendar-mode-map'.
1387
1388 The hooks given by the variable `today-visible-calendar-hook' are run
1389 every time the calendar window gets scrolled, if the current date is visible
1390 in the window. If it is not visible, the hooks given by the variable
1391 `today-invisible-calendar-hook' are run.
1392
1393 Finally this command runs `initial-calendar-window-hook'."
1394 (interactive "P") 1391 (interactive "P")
1395 (set-buffer (get-buffer-create calendar-buffer)) 1392 (set-buffer (get-buffer-create calendar-buffer))
1396 (calendar-mode) 1393 (calendar-mode)
1397 (let* ((pop-up-windows t) 1394 (let* ((pop-up-windows t)
1398 (split-height-threshold 1000) 1395 (split-height-threshold 1000)
1401 (month (extract-calendar-month date)) 1398 (month (extract-calendar-month date))
1402 (year (extract-calendar-year date))) 1399 (year (extract-calendar-year date)))
1403 (increment-calendar-month month year (- calendar-offset)) 1400 (increment-calendar-month month year (- calendar-offset))
1404 ;; Display the buffer before calling generate-calendar-window so that it 1401 ;; Display the buffer before calling generate-calendar-window so that it
1405 ;; can get a chance to adjust the window sizes to the frame size. 1402 ;; can get a chance to adjust the window sizes to the frame size.
1406 (pop-to-buffer calendar-buffer) 1403 (or nodisplay (pop-to-buffer calendar-buffer))
1407 (generate-calendar-window month year) 1404 (generate-calendar-window month year)
1408 (if (and view-diary-entries-initially (calendar-date-is-visible-p date)) 1405 (if (and view-diary-entries-initially (calendar-date-is-visible-p date))
1409 (diary-view-entries))) 1406 (diary-view-entries)))
1410 (if view-calendar-holidays-initially 1407 (if view-calendar-holidays-initially
1411 (let* ((diary-buffer (get-file-buffer diary-file)) 1408 (let* ((diary-buffer (get-file-buffer diary-file))
1415 (calendar-list-holidays))) 1412 (calendar-list-holidays)))
1416 (run-hooks 'initial-calendar-window-hook)) 1413 (run-hooks 'initial-calendar-window-hook))
1417 1414
1418 (defun generate-calendar-window (&optional mon yr) 1415 (defun generate-calendar-window (&optional mon yr)
1419 "Generate the calendar window for the current date. 1416 "Generate the calendar window for the current date.
1420 Or, for optional MON, YR." 1417 Optional integers MON and YR are used instead of today's date."
1421 (let* ((inhibit-read-only t) 1418 (let* ((inhibit-read-only t)
1422 (today (calendar-current-date)) 1419 (today (calendar-current-date))
1423 (month (extract-calendar-month today)) 1420 (month (extract-calendar-month today))
1424 (day (extract-calendar-day today)) 1421 (day (extract-calendar-day today))
1425 (year (extract-calendar-year today)) 1422 (year (extract-calendar-year today))