Mercurial > emacs
comparison lisp/calendar/calendar.el @ 68366:f148491791ae
Remove unnecessary leading stars in docstrings.
(calendar-week-start-day): Add an :initializer.
(calendar-mode-map): Use suppress-keymap, and command remapping.
(describe-calendar-mode): Setup xref-stack info for the back button.
(calendar-star-date): Insert before delete.
(calendar-set-mode-line): Add file-modified info if applicable.
(calendar-increment-month): New function.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Tue, 24 Jan 2006 17:07:29 +0000 |
parents | a55ee709ec8d |
children | 3d624f4184ec 5b7d410e31f9 |
comparison
equal
deleted
inserted
replaced
68365:72d2da82303c | 68366:f148491791ae |
---|---|
1 ;;; calendar.el --- calendar functions | 1 ;;; calendar.el --- calendar functions |
2 | 2 |
3 ;; Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1997, | 3 ;; Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1997, |
4 ;; 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. | 4 ;; 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. |
5 | 5 |
6 ;; Author: Edward M. Reingold <reingold@cs.uiuc.edu> | 6 ;; Author: Edward M. Reingold <reingold@cs.uiuc.edu> |
7 ;; Maintainer: Glenn Morris <rgm@gnu.org> | 7 ;; Maintainer: Glenn Morris <rgm@gnu.org> |
8 ;; Keywords: calendar | 8 ;; Keywords: calendar |
9 ;; Human-Keywords: calendar, Gregorian calendar, diary, holidays | 9 ;; Human-Keywords: calendar, Gregorian calendar, diary, holidays |
96 ;; reingold@cs.uiuc.edu 1304 West Springfield Avenue | 96 ;; reingold@cs.uiuc.edu 1304 West Springfield Avenue |
97 ;; Urbana, Illinois 61801 | 97 ;; Urbana, Illinois 61801 |
98 | 98 |
99 ;;; Code: | 99 ;;; Code: |
100 | 100 |
101 (eval-when-compile | 101 (defvar displayed-month) |
102 (defvar displayed-month) | 102 (defvar displayed-year) |
103 (defvar displayed-year) | 103 (defvar calendar-month-name-array) |
104 (defvar calendar-month-name-array) | 104 (defvar calendar-starred-day) |
105 (defvar calendar-starred-day)) | |
106 | 105 |
107 (defun calendar-version () | 106 (defun calendar-version () |
108 (interactive) | 107 (interactive) |
109 (message "Version 6, October 12, 1995")) | 108 (message "Version 6, October 12, 1995")) |
110 | 109 |
144 (defconst calendar-buffer "*Calendar*" | 143 (defconst calendar-buffer "*Calendar*" |
145 "Name of the buffer used for the calendar.") | 144 "Name of the buffer used for the calendar.") |
146 | 145 |
147 ;;;###autoload | 146 ;;;###autoload |
148 (defcustom calendar-offset 0 | 147 (defcustom calendar-offset 0 |
149 "*The offset of the principal month from the center of the calendar window. | 148 "The offset of the principal month from the center of the calendar window. |
150 0 means the principal month is in the center (default), -1 means on the left, | 149 0 means the principal month is in the center (default), -1 means on the left, |
151 +1 means on the right. Larger (or smaller) values push the principal month off | 150 +1 means on the right. Larger (or smaller) values push the principal month off |
152 the screen." | 151 the screen." |
153 :type 'integer | 152 :type 'integer |
154 :group 'calendar) | 153 :group 'calendar) |
155 | 154 |
156 ;;;###autoload | 155 ;;;###autoload |
157 (defcustom view-diary-entries-initially nil | 156 (defcustom view-diary-entries-initially nil |
158 "*Non-nil means display current date's diary entries on entry to calendar. | 157 "Non-nil means display current date's diary entries on entry to calendar. |
159 The diary is displayed in another window when the calendar is first displayed, | 158 The diary is displayed in another window when the calendar is first displayed, |
160 if the current date is visible. The number of days of diary entries displayed | 159 if the current date is visible. The number of days of diary entries displayed |
161 is governed by the variable `number-of-diary-entries'. This variable can | 160 is governed by the variable `number-of-diary-entries'. This variable can |
162 be overridden by the value of `calendar-setup'." | 161 be overridden by the value of `calendar-setup'." |
163 :type 'boolean | 162 :type 'boolean |
164 :group 'diary) | 163 :group 'diary) |
165 | 164 |
166 ;;;###autoload | 165 ;;;###autoload |
167 (defcustom mark-diary-entries-in-calendar nil | 166 (defcustom mark-diary-entries-in-calendar nil |
168 "*Non-nil means mark dates with diary entries, in the calendar window. | 167 "Non-nil means mark dates with diary entries, in the calendar window. |
169 The marking symbol is specified by the variable `diary-entry-marker'." | 168 The marking symbol is specified by the variable `diary-entry-marker'." |
170 :type 'boolean | 169 :type 'boolean |
171 :group 'diary) | 170 :group 'diary) |
172 | 171 |
173 ;;;###autoload | 172 ;;;###autoload |
174 (defcustom calendar-remove-frame-by-deleting nil | 173 (defcustom calendar-remove-frame-by-deleting nil |
175 "*Determine how the calendar mode removes a frame no longer needed. | 174 "Determine how the calendar mode removes a frame no longer needed. |
176 If nil, make an icon of the frame. If non-nil, delete the frame." | 175 If nil, make an icon of the frame. If non-nil, delete the frame." |
177 :type 'boolean | 176 :type 'boolean |
178 :group 'view) | 177 :group 'view) |
179 | 178 |
180 (defvar diary-face 'diary | 179 (defvar diary-face 'diary |
222 | 221 |
223 (defcustom diary-entry-marker | 222 (defcustom diary-entry-marker |
224 (if (not (display-color-p)) | 223 (if (not (display-color-p)) |
225 "+" | 224 "+" |
226 'diary) | 225 'diary) |
227 "*How to mark dates that have diary entries. | 226 "How to mark dates that have diary entries. |
228 The value can be either a single-character string or a face." | 227 The value can be either a single-character string or a face." |
229 :type '(choice string face) | 228 :type '(choice string face) |
230 :group 'diary) | 229 :group 'diary) |
231 | 230 |
232 (defcustom calendar-today-marker | 231 (defcustom calendar-today-marker |
233 (if (not (display-color-p)) | 232 (if (not (display-color-p)) |
234 "=" | 233 "=" |
235 'calendar-today) | 234 'calendar-today) |
236 "*How to mark today's date in the calendar. | 235 "How to mark today's date in the calendar. |
237 The value can be either a single-character string or a face. | 236 The value can be either a single-character string or a face. |
238 Marking today's date is done only if you set up `today-visible-calendar-hook' | 237 Marking today's date is done only if you set up `today-visible-calendar-hook' |
239 to request that." | 238 to request that." |
240 :type '(choice string face) | 239 :type '(choice string face) |
241 :group 'calendar) | 240 :group 'calendar) |
242 | 241 |
243 (defcustom calendar-holiday-marker | 242 (defcustom calendar-holiday-marker |
244 (if (not (display-color-p)) | 243 (if (not (display-color-p)) |
245 "*" | 244 "*" |
246 'holiday) | 245 'holiday) |
247 "*How to mark notable dates in the calendar. | 246 "How to mark notable dates in the calendar. |
248 The value can be either a single-character string or a face." | 247 The value can be either a single-character string or a face." |
249 :type '(choice string face) | 248 :type '(choice string face) |
250 :group 'calendar) | 249 :group 'calendar) |
251 | 250 |
252 ;;;###autoload | 251 ;;;###autoload |
253 (defcustom view-calendar-holidays-initially nil | 252 (defcustom view-calendar-holidays-initially nil |
254 "*Non-nil means display holidays for current three month period on entry. | 253 "Non-nil means display holidays for current three month period on entry. |
255 The holidays are displayed in another window when the calendar is first | 254 The holidays are displayed in another window when the calendar is first |
256 displayed." | 255 displayed." |
257 :type 'boolean | 256 :type 'boolean |
258 :group 'holidays) | 257 :group 'holidays) |
259 | 258 |
260 ;;;###autoload | 259 ;;;###autoload |
261 (defcustom mark-holidays-in-calendar nil | 260 (defcustom mark-holidays-in-calendar nil |
262 "*Non-nil means mark dates of holidays in the calendar window. | 261 "Non-nil means mark dates of holidays in the calendar window. |
263 The marking symbol is specified by the variable `calendar-holiday-marker'." | 262 The marking symbol is specified by the variable `calendar-holiday-marker'." |
264 :type 'boolean | 263 :type 'boolean |
265 :group 'holidays) | 264 :group 'holidays) |
266 | 265 |
267 ;;;###autoload | 266 ;;;###autoload |
268 (defcustom all-hebrew-calendar-holidays nil | 267 (defcustom all-hebrew-calendar-holidays nil |
269 "*If nil, show only major holidays from the Hebrew calendar. | 268 "If nil, show only major holidays from the Hebrew calendar. |
270 This means only those Jewish holidays that appear on secular calendars. | 269 This means only those Jewish holidays that appear on secular calendars. |
271 | 270 |
272 If t, show all the holidays that would appear in a complete Hebrew calendar." | 271 If t, show all the holidays that would appear in a complete Hebrew calendar." |
273 :type 'boolean | 272 :type 'boolean |
274 :group 'holidays) | 273 :group 'holidays) |
275 | 274 |
276 ;;;###autoload | 275 ;;;###autoload |
277 (defcustom all-christian-calendar-holidays nil | 276 (defcustom all-christian-calendar-holidays nil |
278 "*If nil, show only major holidays from the Christian calendar. | 277 "If nil, show only major holidays from the Christian calendar. |
279 This means only those Christian holidays that appear on secular calendars. | 278 This means only those Christian holidays that appear on secular calendars. |
280 | 279 |
281 If t, show all the holidays that would appear in a complete Christian | 280 If t, show all the holidays that would appear in a complete Christian |
282 calendar." | 281 calendar." |
283 :type 'boolean | 282 :type 'boolean |
284 :group 'holidays) | 283 :group 'holidays) |
285 | 284 |
286 ;;;###autoload | 285 ;;;###autoload |
287 (defcustom all-islamic-calendar-holidays nil | 286 (defcustom all-islamic-calendar-holidays nil |
288 "*If nil, show only major holidays from the Islamic calendar. | 287 "If nil, show only major holidays from the Islamic calendar. |
289 This means only those Islamic holidays that appear on secular calendars. | 288 This means only those Islamic holidays that appear on secular calendars. |
290 | 289 |
291 If t, show all the holidays that would appear in a complete Islamic | 290 If t, show all the holidays that would appear in a complete Islamic |
292 calendar." | 291 calendar." |
293 :type 'boolean | 292 :type 'boolean |
294 :group 'holidays) | 293 :group 'holidays) |
295 | 294 |
296 (defcustom diary-file-name-prefix-function (function (lambda (str) str)) | 295 (defcustom diary-file-name-prefix-function (function (lambda (str) str)) |
297 "*The function that will take a diary file name and return the desired prefix." | 296 "The function that will take a diary file name and return the desired prefix." |
298 :type 'function | 297 :type 'function |
299 :group 'diary) | 298 :group 'diary) |
300 | 299 |
301 ;;;###autoload | 300 ;;;###autoload |
302 (defcustom all-bahai-calendar-holidays nil | 301 (defcustom all-bahai-calendar-holidays nil |
303 "*If nil, show only major holidays from the Baha'i calendar. | 302 "If nil, show only major holidays from the Baha'i calendar. |
304 These are the days on which work and school must be suspended. | 303 These are the days on which work and school must be suspended. |
305 | 304 |
306 If t, show all the holidays that would appear in a complete Baha'i | 305 If t, show all the holidays that would appear in a complete Baha'i |
307 calendar." | 306 calendar." |
308 :type 'boolean | 307 :type 'boolean |
309 :group 'holidays) | 308 :group 'holidays) |
310 | 309 |
311 ;;;###autoload | 310 ;;;###autoload |
312 (defcustom calendar-load-hook nil | 311 (defcustom calendar-load-hook nil |
313 "*List of functions to be called after the calendar is first loaded. | 312 "List of functions to be called after the calendar is first loaded. |
314 This is the place to add key bindings to `calendar-mode-map'." | 313 This is the place to add key bindings to `calendar-mode-map'." |
315 :type 'hook | 314 :type 'hook |
316 :group 'calendar-hooks) | 315 :group 'calendar-hooks) |
317 | 316 |
318 ;;;###autoload | 317 ;;;###autoload |
319 (defcustom initial-calendar-window-hook nil | 318 (defcustom initial-calendar-window-hook nil |
320 "*List of functions to be called when the calendar window is first opened. | 319 "List of functions to be called when the calendar window is first opened. |
321 The functions invoked are called after the calendar window is opened, but | 320 The functions invoked are called after the calendar window is opened, but |
322 once opened is never called again. Leaving the calendar with the `q' command | 321 once opened is never called again. Leaving the calendar with the `q' command |
323 and reentering it will cause these functions to be called again." | 322 and reentering it will cause these functions to be called again." |
324 :type 'hook | 323 :type 'hook |
325 :group 'calendar-hooks) | 324 :group 'calendar-hooks) |
326 | 325 |
327 ;;;###autoload | 326 ;;;###autoload |
328 (defcustom today-visible-calendar-hook nil | 327 (defcustom today-visible-calendar-hook nil |
329 "*List of functions called whenever the current date is visible. | 328 "List of functions called whenever the current date is visible. |
330 This can be used, for example, to replace today's date with asterisks; a | 329 This can be used, for example, to replace today's date with asterisks; a |
331 function `calendar-star-date' is included for this purpose: | 330 function `calendar-star-date' is included for this purpose: |
332 (setq today-visible-calendar-hook 'calendar-star-date) | 331 (setq today-visible-calendar-hook 'calendar-star-date) |
333 It can also be used to mark the current date with `calendar-today-marker'; | 332 It can also be used to mark the current date with `calendar-today-marker'; |
334 a function is also provided for this: | 333 a function is also provided for this: |
344 :type 'hook | 343 :type 'hook |
345 :group 'calendar-hooks) | 344 :group 'calendar-hooks) |
346 | 345 |
347 ;;;###autoload | 346 ;;;###autoload |
348 (defcustom today-invisible-calendar-hook nil | 347 (defcustom today-invisible-calendar-hook nil |
349 "*List of functions called whenever the current date is not visible. | 348 "List of functions called whenever the current date is not visible. |
350 | 349 |
351 The corresponding variable `today-visible-calendar-hook' is the list of | 350 The corresponding variable `today-visible-calendar-hook' is the list of |
352 functions called when the calendar function was called when the current | 351 functions called when the calendar function was called when the current |
353 date is visible in the window. | 352 date is visible in the window. |
354 | 353 |
358 :type 'hook | 357 :type 'hook |
359 :group 'calendar-hooks) | 358 :group 'calendar-hooks) |
360 | 359 |
361 ;;;###autoload | 360 ;;;###autoload |
362 (defcustom calendar-move-hook nil | 361 (defcustom calendar-move-hook nil |
363 "*List of functions called whenever the cursor moves in the calendar. | 362 "List of functions called whenever the cursor moves in the calendar. |
364 | 363 |
365 For example, | 364 For example, |
366 | 365 |
367 (add-hook 'calendar-move-hook (lambda () (diary-view-entries 1))) | 366 (add-hook 'calendar-move-hook (lambda () (diary-view-entries 1))) |
368 | 367 |
370 :type 'hook | 369 :type 'hook |
371 :group 'calendar-hooks) | 370 :group 'calendar-hooks) |
372 | 371 |
373 ;;;###autoload | 372 ;;;###autoload |
374 (defcustom diary-file "~/diary" | 373 (defcustom diary-file "~/diary" |
375 "*Name of the file in which one's personal diary of dates is kept. | 374 "Name of the file in which one's personal diary of dates is kept. |
376 | 375 |
377 The file's entries are lines beginning with any of the forms | 376 The file's entries are lines beginning with any of the forms |
378 specified by the variable `american-date-diary-pattern', by default: | 377 specified by the variable `american-date-diary-pattern', by default: |
379 | 378 |
380 MONTH/DAY | 379 MONTH/DAY |
478 :type 'file | 477 :type 'file |
479 :group 'diary) | 478 :group 'diary) |
480 | 479 |
481 ;;;###autoload | 480 ;;;###autoload |
482 (defcustom diary-nonmarking-symbol "&" | 481 (defcustom diary-nonmarking-symbol "&" |
483 "*Symbol indicating that a diary entry is not to be marked in the calendar." | 482 "Symbol indicating that a diary entry is not to be marked in the calendar." |
484 :type 'string | 483 :type 'string |
485 :group 'diary) | 484 :group 'diary) |
486 | 485 |
487 ;;;###autoload | 486 ;;;###autoload |
488 (defcustom hebrew-diary-entry-symbol "H" | 487 (defcustom hebrew-diary-entry-symbol "H" |
489 "*Symbol indicating a diary entry according to the Hebrew calendar." | 488 "Symbol indicating a diary entry according to the Hebrew calendar." |
490 :type 'string | 489 :type 'string |
491 :group 'diary) | 490 :group 'diary) |
492 | 491 |
493 ;;;###autoload | 492 ;;;###autoload |
494 (defcustom islamic-diary-entry-symbol "I" | 493 (defcustom islamic-diary-entry-symbol "I" |
495 "*Symbol indicating a diary entry according to the Islamic calendar." | 494 "Symbol indicating a diary entry according to the Islamic calendar." |
496 :type 'string | 495 :type 'string |
497 :group 'diary) | 496 :group 'diary) |
498 | 497 |
499 ;;;###autoload | 498 ;;;###autoload |
500 (defcustom bahai-diary-entry-symbol "B" | 499 (defcustom bahai-diary-entry-symbol "B" |
501 "*Symbol indicating a diary entry according to the Baha'i calendar." | 500 "Symbol indicating a diary entry according to the Baha'i calendar." |
502 :type 'string | 501 :type 'string |
503 :group 'diary) | 502 :group 'diary) |
504 | 503 |
505 ;;;###autoload | 504 ;;;###autoload |
506 (defcustom diary-include-string "#include" | 505 (defcustom diary-include-string "#include" |
507 "*The string indicating inclusion of another file of diary entries. | 506 "The string indicating inclusion of another file of diary entries. |
508 See the documentation for the function `include-other-diary-files'." | 507 See the documentation for the function `include-other-diary-files'." |
509 :type 'string | 508 :type 'string |
510 :group 'diary) | 509 :group 'diary) |
511 | 510 |
512 (defcustom diary-glob-file-regexp-prefix "^\\#" | 511 (defcustom diary-glob-file-regexp-prefix "^\\#" |
513 "*The regular expression that gets pre-pended to each of the attribute-regexp's for file-wide specifiers." | 512 "The regular expression that gets pre-pended to each of the attribute-regexp's for file-wide specifiers." |
514 :type 'regexp | 513 :type 'regexp |
515 :group 'diary) | 514 :group 'diary) |
516 | 515 |
517 (defcustom diary-face-attrs | 516 (defcustom diary-face-attrs |
518 '((" *\\[foreground:\\([-a-z]+\\)\\]$" 1 :foreground string) | 517 '((" *\\[foreground:\\([-a-z]+\\)\\]$" 1 :foreground string) |
529 (" *\\[font:\\([-a-z0-9]+\\)\\]$" 1 :font string) | 528 (" *\\[font:\\([-a-z0-9]+\\)\\]$" 1 :font string) |
530 ;; Unsupported. | 529 ;; Unsupported. |
531 ;;; (" *\\[box:\\([-a-z]+\\)\\]$" 1 :box) | 530 ;;; (" *\\[box:\\([-a-z]+\\)\\]$" 1 :box) |
532 ;;; (" *\\[stipple:\\([-a-z]+\\)\\]$" 1 :stipple) | 531 ;;; (" *\\[stipple:\\([-a-z]+\\)\\]$" 1 :stipple) |
533 ) | 532 ) |
534 "*A list of (regexp regnum attr attrtype) lists where the | 533 "A list of (regexp regnum attr attrtype) lists where the |
535 regexp says how to find the tag, the regnum says which | 534 regexp says how to find the tag, the regnum says which |
536 parenthetical sub-regexp this regexp looks for, and the attr says | 535 parenthetical sub-regexp this regexp looks for, and the attr says |
537 which attribute of the face (or that this _is_ a face) is being | 536 which attribute of the face (or that this _is_ a face) is being |
538 modified." | 537 modified." |
539 :type 'sexp | 538 :type 'sexp |
544 :type 'boolean | 543 :type 'boolean |
545 :group 'diary) | 544 :group 'diary) |
546 | 545 |
547 ;;;###autoload | 546 ;;;###autoload |
548 (defcustom sexp-diary-entry-symbol "%%" | 547 (defcustom sexp-diary-entry-symbol "%%" |
549 "*The string used to indicate a sexp diary entry in `diary-file'. | 548 "The string used to indicate a sexp diary entry in `diary-file'. |
550 See the documentation for the function `list-sexp-diary-entries'." | 549 See the documentation for the function `list-sexp-diary-entries'." |
551 :type 'string | 550 :type 'string |
552 :group 'diary) | 551 :group 'diary) |
553 | 552 |
554 ;;;###autoload | 553 ;;;###autoload |
555 (defcustom abbreviated-calendar-year t | 554 (defcustom abbreviated-calendar-year t |
556 "*Interpret a two-digit year DD in a diary entry as either 19DD or 20DD. | 555 "Interpret a two-digit year DD in a diary entry as either 19DD or 20DD. |
557 For the Gregorian calendar; similarly for the Hebrew, Islamic and | 556 For the Gregorian calendar; similarly for the Hebrew, Islamic and |
558 Baha'i calendars. If this variable is nil, years must be written in | 557 Baha'i calendars. If this variable is nil, years must be written in |
559 full." | 558 full." |
560 :type 'boolean | 559 :type 'boolean |
561 :group 'diary) | 560 :group 'diary) |
562 | 561 |
563 ;;;###autoload | 562 ;;;###autoload |
564 (defcustom european-calendar-style nil | 563 (defcustom european-calendar-style nil |
565 "*Use the European style of dates in the diary and in any displays. | 564 "Use the European style of dates in the diary and in any displays. |
566 If this variable is t, a date 1/2/1990 would be interpreted as February 1, | 565 If this variable is t, a date 1/2/1990 would be interpreted as February 1, |
567 1990. The default European date styles (see `european-date-diary-pattern') | 566 1990. The default European date styles (see `european-date-diary-pattern') |
568 are | 567 are |
569 | 568 |
570 DAY/MONTH | 569 DAY/MONTH |
587 '((month "/" day "[^/0-9]") | 586 '((month "/" day "[^/0-9]") |
588 (month "/" day "/" year "[^0-9]") | 587 (month "/" day "/" year "[^0-9]") |
589 (monthname " *" day "[^,0-9]") | 588 (monthname " *" day "[^,0-9]") |
590 (monthname " *" day ", *" year "[^0-9]") | 589 (monthname " *" day ", *" year "[^0-9]") |
591 (dayname "\\W")) | 590 (dayname "\\W")) |
592 "*List of pseudo-patterns describing the American patterns of date used. | 591 "List of pseudo-patterns describing the American patterns of date used. |
593 See the documentation of `diary-date-forms' for an explanation." | 592 See the documentation of `diary-date-forms' for an explanation." |
594 :type '(repeat (choice (cons :tag "Backup" | 593 :type '(repeat (choice (cons :tag "Backup" |
595 :value (backup . nil) | 594 :value (backup . nil) |
596 (const backup) | 595 (const backup) |
597 (repeat (list :inline t :format "%v" | 596 (repeat (list :inline t :format "%v" |
607 '((day "/" month "[^/0-9]") | 606 '((day "/" month "[^/0-9]") |
608 (day "/" month "/" year "[^0-9]") | 607 (day "/" month "/" year "[^0-9]") |
609 (backup day " *" monthname "\\W+\\<\\([^*0-9]\\|\\([0-9]+[:aApP]\\)\\)") | 608 (backup day " *" monthname "\\W+\\<\\([^*0-9]\\|\\([0-9]+[:aApP]\\)\\)") |
610 (day " *" monthname " *" year "[^0-9]") | 609 (day " *" monthname " *" year "[^0-9]") |
611 (dayname "\\W")) | 610 (dayname "\\W")) |
612 "*List of pseudo-patterns describing the European patterns of date used. | 611 "List of pseudo-patterns describing the European patterns of date used. |
613 See the documentation of `diary-date-forms' for an explanation." | 612 See the documentation of `diary-date-forms' for an explanation." |
614 :type '(repeat (choice (cons :tag "Backup" | 613 :type '(repeat (choice (cons :tag "Backup" |
615 :value (backup . nil) | 614 :value (backup . nil) |
616 (const backup) | 615 (const backup) |
617 (repeat (list :inline t :format "%v" | 616 (repeat (list :inline t :format "%v" |
624 | 623 |
625 (defcustom diary-date-forms | 624 (defcustom diary-date-forms |
626 (if european-calendar-style | 625 (if european-calendar-style |
627 european-date-diary-pattern | 626 european-date-diary-pattern |
628 american-date-diary-pattern) | 627 american-date-diary-pattern) |
629 "*List of pseudo-patterns describing the forms of date used in the diary. | 628 "List of pseudo-patterns describing the forms of date used in the diary. |
630 The patterns on the list must be MUTUALLY EXCLUSIVE and should not match | 629 The patterns on the list must be MUTUALLY EXCLUSIVE and should not match |
631 any portion of the diary entry itself, just the date component. | 630 any portion of the diary entry itself, just the date component. |
632 | 631 |
633 A pseudo-pattern is a list of regular expressions and the keywords `month', | 632 A pseudo-pattern is a list of regular expressions and the keywords `month', |
634 `day', `year', `monthname', and `dayname'. The keyword `monthname' will | 633 `day', `year', `monthname', and `dayname'. The keyword `monthname' will |
662 :group 'diary) | 661 :group 'diary) |
663 | 662 |
664 ;;;###autoload | 663 ;;;###autoload |
665 (defcustom european-calendar-display-form | 664 (defcustom european-calendar-display-form |
666 '((if dayname (concat dayname ", ")) day " " monthname " " year) | 665 '((if dayname (concat dayname ", ")) day " " monthname " " year) |
667 "*Pseudo-pattern governing the way a date appears in the European style. | 666 "Pseudo-pattern governing the way a date appears in the European style. |
668 See the documentation of `calendar-date-display-form' for an explanation." | 667 See the documentation of `calendar-date-display-form' for an explanation." |
669 :type 'sexp | 668 :type 'sexp |
670 :group 'calendar) | 669 :group 'calendar) |
671 | 670 |
672 ;;;###autoload | 671 ;;;###autoload |
673 (defcustom american-calendar-display-form | 672 (defcustom american-calendar-display-form |
674 '((if dayname (concat dayname ", ")) monthname " " day ", " year) | 673 '((if dayname (concat dayname ", ")) monthname " " day ", " year) |
675 "*Pseudo-pattern governing the way a date appears in the American style. | 674 "Pseudo-pattern governing the way a date appears in the American style. |
676 See the documentation of `calendar-date-display-form' for an explanation." | 675 See the documentation of `calendar-date-display-form' for an explanation." |
677 :type 'sexp | 676 :type 'sexp |
678 :group 'calendar) | 677 :group 'calendar) |
679 | 678 |
680 (defcustom calendar-date-display-form | 679 (defcustom calendar-date-display-form |
681 (if european-calendar-style | 680 (if european-calendar-style |
682 european-calendar-display-form | 681 european-calendar-display-form |
683 american-calendar-display-form) | 682 american-calendar-display-form) |
684 "*Pseudo-pattern governing the way a date appears. | 683 "Pseudo-pattern governing the way a date appears. |
685 | 684 |
686 Used by the function `calendar-date-string', a pseudo-pattern is a list of | 685 Used by the function `calendar-date-string', a pseudo-pattern is a list of |
687 expressions that can involve the keywords `month', `day', and `year', all | 686 expressions that can involve the keywords `month', `day', and `year', all |
688 numbers in string form, and `monthname' and `dayname', both alphabetic | 687 numbers in string form, and `monthname' and `dayname', both alphabetic |
689 strings. For example, the ISO standard would use the pseudo- pattern | 688 strings. For example, the ISO standard would use the pseudo- pattern |
720 (setq diary-date-forms american-date-diary-pattern) | 719 (setq diary-date-forms american-date-diary-pattern) |
721 (update-calendar-mode-line)) | 720 (update-calendar-mode-line)) |
722 | 721 |
723 ;;;###autoload | 722 ;;;###autoload |
724 (defcustom print-diary-entries-hook 'lpr-buffer | 723 (defcustom print-diary-entries-hook 'lpr-buffer |
725 "*List of functions called after a temporary diary buffer is prepared. | 724 "List of functions called after a temporary diary buffer is prepared. |
726 The buffer shows only the diary entries currently visible in the diary | 725 The buffer shows only the diary entries currently visible in the diary |
727 buffer. The default just does the printing. Other uses might include, for | 726 buffer. The default just does the printing. Other uses might include, for |
728 example, rearranging the lines into order by day and time, saving the buffer | 727 example, rearranging the lines into order by day and time, saving the buffer |
729 instead of deleting it, or changing the function used to do the printing." | 728 instead of deleting it, or changing the function used to do the printing." |
730 :type 'hook | 729 :type 'hook |
731 :group 'diary) | 730 :group 'diary) |
732 | 731 |
733 ;;;###autoload | 732 ;;;###autoload |
734 (defcustom list-diary-entries-hook nil | 733 (defcustom list-diary-entries-hook nil |
735 "*List of functions called after diary file is culled for relevant entries. | 734 "List of functions called after diary file is culled for relevant entries. |
736 It is to be used for diary entries that are not found in the diary file. | 735 It is to be used for diary entries that are not found in the diary file. |
737 | 736 |
738 A function `include-other-diary-files' is provided for use as the value of | 737 A function `include-other-diary-files' is provided for use as the value of |
739 this hook. This function enables you to use shared diary files together | 738 this hook. This function enables you to use shared diary files together |
740 with your own. The files included are specified in the diary file by lines | 739 with your own. The files included are specified in the diary file by lines |
761 :options '(include-other-diary-files sort-diary-entries) | 760 :options '(include-other-diary-files sort-diary-entries) |
762 :group 'diary) | 761 :group 'diary) |
763 | 762 |
764 ;;;###autoload | 763 ;;;###autoload |
765 (defcustom diary-hook nil | 764 (defcustom diary-hook nil |
766 "*List of functions called after the display of the diary. | 765 "List of functions called after the display of the diary. |
767 Can be used for appointment notification." | 766 Can be used for appointment notification." |
768 :type 'hook | 767 :type 'hook |
769 :group 'diary) | 768 :group 'diary) |
770 | 769 |
771 ;;;###autoload | 770 ;;;###autoload |
772 (defcustom diary-display-hook nil | 771 (defcustom diary-display-hook nil |
773 "*List of functions that handle the display of the diary. | 772 "List of functions that handle the display of the diary. |
774 If nil (the default), `simple-diary-display' is used. Use `ignore' for no | 773 If nil (the default), `simple-diary-display' is used. Use `ignore' for no |
775 diary display. | 774 diary display. |
776 | 775 |
777 Ordinarily, this just displays the diary buffer (with holidays indicated in | 776 Ordinarily, this just displays the diary buffer (with holidays indicated in |
778 the mode line), if there are any relevant entries. At the time these | 777 the mode line), if there are any relevant entries. At the time these |
794 :options '(fancy-diary-display) | 793 :options '(fancy-diary-display) |
795 :group 'diary) | 794 :group 'diary) |
796 | 795 |
797 ;;;###autoload | 796 ;;;###autoload |
798 (defcustom nongregorian-diary-listing-hook nil | 797 (defcustom nongregorian-diary-listing-hook nil |
799 "*List of functions called for listing diary file and included files. | 798 "List of functions called for listing diary file and included files. |
800 As the files are processed for diary entries, these functions are used | 799 As the files are processed for diary entries, these functions are used |
801 to cull relevant entries. You can use either or both of | 800 to cull relevant entries. You can use either or both of |
802 `list-hebrew-diary-entries', `list-islamic-diary-entries' and | 801 `list-hebrew-diary-entries', `list-islamic-diary-entries' and |
803 `list-bahai-diary-entries'. The documentation for these functions | 802 `list-bahai-diary-entries'. The documentation for these functions |
804 describes the style of such diary entries." | 803 describes the style of such diary entries." |
808 list-bahai-diary-entries) | 807 list-bahai-diary-entries) |
809 :group 'diary) | 808 :group 'diary) |
810 | 809 |
811 ;;;###autoload | 810 ;;;###autoload |
812 (defcustom mark-diary-entries-hook nil | 811 (defcustom mark-diary-entries-hook nil |
813 "*List of functions called after marking diary entries in the calendar. | 812 "List of functions called after marking diary entries in the calendar. |
814 | 813 |
815 A function `mark-included-diary-files' is also provided for use as the | 814 A function `mark-included-diary-files' is also provided for use as the |
816 `mark-diary-entries-hook'; it enables you to use shared diary files together | 815 `mark-diary-entries-hook'; it enables you to use shared diary files together |
817 with your own. The files included are specified in the diary file by lines | 816 with your own. The files included are specified in the diary file by lines |
818 of the form | 817 of the form |
826 :options '(mark-included-diary-files) | 825 :options '(mark-included-diary-files) |
827 :group 'diary) | 826 :group 'diary) |
828 | 827 |
829 ;;;###autoload | 828 ;;;###autoload |
830 (defcustom nongregorian-diary-marking-hook nil | 829 (defcustom nongregorian-diary-marking-hook nil |
831 "*List of functions called for marking diary file and included files. | 830 "List of functions called for marking diary file and included files. |
832 As the files are processed for diary entries, these functions are used | 831 As the files are processed for diary entries, these functions are used |
833 to cull relevant entries. You can use either or both of | 832 to cull relevant entries. You can use either or both of |
834 `mark-hebrew-diary-entries', `mark-islamic-diary-entries' and | 833 `mark-hebrew-diary-entries', `mark-islamic-diary-entries' and |
835 `mark-bahai-diary-entries'. The documentation for these functions | 834 `mark-bahai-diary-entries'. The documentation for these functions |
836 describes the style of such diary entries." | 835 describes the style of such diary entries." |
840 mark-bahai-diary-entries) | 839 mark-bahai-diary-entries) |
841 :group 'diary) | 840 :group 'diary) |
842 | 841 |
843 ;;;###autoload | 842 ;;;###autoload |
844 (defcustom diary-list-include-blanks nil | 843 (defcustom diary-list-include-blanks nil |
845 "*If nil, do not include days with no diary entry in the list of diary entries. | 844 "If nil, do not include days with no diary entry in the list of diary entries. |
846 Such days will then not be shown in the fancy diary buffer, even if they | 845 Such days will then not be shown in the fancy diary buffer, even if they |
847 are holidays." | 846 are holidays." |
848 :type 'boolean | 847 :type 'boolean |
849 :group 'diary) | 848 :group 'diary) |
850 | 849 |
851 ;;;###autoload | 850 ;;;###autoload |
852 (defcustom holidays-in-diary-buffer t | 851 (defcustom holidays-in-diary-buffer t |
853 "*Non-nil means include holidays in the diary display. | 852 "Non-nil means include holidays in the diary display. |
854 The holidays appear in the mode line of the diary buffer, or in the | 853 The holidays appear in the mode line of the diary buffer, or in the |
855 fancy diary buffer next to the date. This slows down the diary functions | 854 fancy diary buffer next to the date. This slows down the diary functions |
856 somewhat; setting it to nil makes the diary display faster." | 855 somewhat; setting it to nil makes the diary display faster." |
857 :type 'boolean | 856 :type 'boolean |
858 :group 'holidays) | 857 :group 'holidays) |
878 (holiday-float 9 1 1 "Labor Day") | 877 (holiday-float 9 1 1 "Labor Day") |
879 (holiday-float 10 1 2 "Columbus Day") | 878 (holiday-float 10 1 2 "Columbus Day") |
880 (holiday-fixed 10 31 "Halloween") | 879 (holiday-fixed 10 31 "Halloween") |
881 (holiday-fixed 11 11 "Veteran's Day") | 880 (holiday-fixed 11 11 "Veteran's Day") |
882 (holiday-float 11 4 4 "Thanksgiving")) | 881 (holiday-float 11 4 4 "Thanksgiving")) |
883 "*General holidays. Default value is for the United States. | 882 "General holidays. Default value is for the United States. |
884 See the documentation for `calendar-holidays' for details." | 883 See the documentation for `calendar-holidays' for details." |
885 :type 'sexp | 884 :type 'sexp |
886 :group 'holidays) | 885 :group 'holidays) |
887 | 886 |
888 ;;;###autoload | 887 ;;;###autoload |
889 (put 'oriental-holidays 'risky-local-variable t) | 888 (put 'oriental-holidays 'risky-local-variable t) |
890 ;;;###autoload | 889 ;;;###autoload |
891 (defcustom oriental-holidays | 890 (defcustom oriental-holidays |
892 '((if (fboundp 'atan) | 891 '((if (fboundp 'atan) |
893 (holiday-chinese-new-year))) | 892 (holiday-chinese-new-year))) |
894 "*Oriental holidays. | 893 "Oriental holidays. |
895 See the documentation for `calendar-holidays' for details." | 894 See the documentation for `calendar-holidays' for details." |
896 :type 'sexp | 895 :type 'sexp |
897 :group 'holidays) | 896 :group 'holidays) |
898 | 897 |
899 ;;;###autoload | 898 ;;;###autoload |
900 (put 'local-holidays 'risky-local-variable t) | 899 (put 'local-holidays 'risky-local-variable t) |
901 ;;;###autoload | 900 ;;;###autoload |
902 (defcustom local-holidays nil | 901 (defcustom local-holidays nil |
903 "*Local holidays. | 902 "Local holidays. |
904 See the documentation for `calendar-holidays' for details." | 903 See the documentation for `calendar-holidays' for details." |
905 :type 'sexp | 904 :type 'sexp |
906 :group 'holidays) | 905 :group 'holidays) |
907 | 906 |
908 ;;;###autoload | 907 ;;;###autoload |
909 (put 'other-holidays 'risky-local-variable t) | 908 (put 'other-holidays 'risky-local-variable t) |
910 ;;;###autoload | 909 ;;;###autoload |
911 (defcustom other-holidays nil | 910 (defcustom other-holidays nil |
912 "*User defined holidays. | 911 "User defined holidays. |
913 See the documentation for `calendar-holidays' for details." | 912 See the documentation for `calendar-holidays' for details." |
914 :type 'sexp | 913 :type 'sexp |
915 :group 'holidays) | 914 :group 'holidays) |
916 | 915 |
917 ;;;###autoload | 916 ;;;###autoload |
1011 ;;;###autoload | 1010 ;;;###autoload |
1012 (put 'hebrew-holidays 'risky-local-variable t) | 1011 (put 'hebrew-holidays 'risky-local-variable t) |
1013 ;;;###autoload | 1012 ;;;###autoload |
1014 (defcustom hebrew-holidays (append hebrew-holidays-1 hebrew-holidays-2 | 1013 (defcustom hebrew-holidays (append hebrew-holidays-1 hebrew-holidays-2 |
1015 hebrew-holidays-3 hebrew-holidays-4) | 1014 hebrew-holidays-3 hebrew-holidays-4) |
1016 "*Jewish holidays. | 1015 "Jewish holidays. |
1017 See the documentation for `calendar-holidays' for details." | 1016 See the documentation for `calendar-holidays' for details." |
1018 :type 'sexp | 1017 :type 'sexp |
1019 :group 'holidays) | 1018 :group 'holidays) |
1020 | 1019 |
1021 ;;;###autoload | 1020 ;;;###autoload |
1062 (if all-christian-calendar-holidays | 1061 (if all-christian-calendar-holidays |
1063 (holiday-advent 0 "Advent")) | 1062 (holiday-advent 0 "Advent")) |
1064 (holiday-fixed 12 25 "Christmas") | 1063 (holiday-fixed 12 25 "Christmas") |
1065 (if all-christian-calendar-holidays | 1064 (if all-christian-calendar-holidays |
1066 (holiday-julian 12 25 "Eastern Orthodox Christmas"))) | 1065 (holiday-julian 12 25 "Eastern Orthodox Christmas"))) |
1067 "*Christian holidays. | 1066 "Christian holidays. |
1068 See the documentation for `calendar-holidays' for details." | 1067 See the documentation for `calendar-holidays' for details." |
1069 :type 'sexp | 1068 :type 'sexp |
1070 :group 'holidays) | 1069 :group 'holidays) |
1071 | 1070 |
1072 ;;;###autoload | 1071 ;;;###autoload |
1097 (holiday-islamic 9 27 "Shab-e Qadr")) | 1096 (holiday-islamic 9 27 "Shab-e Qadr")) |
1098 (if all-islamic-calendar-holidays | 1097 (if all-islamic-calendar-holidays |
1099 (holiday-islamic 10 1 "Id-al-Fitr")) | 1098 (holiday-islamic 10 1 "Id-al-Fitr")) |
1100 (if all-islamic-calendar-holidays | 1099 (if all-islamic-calendar-holidays |
1101 (holiday-islamic 12 10 "Id-al-Adha"))) | 1100 (holiday-islamic 12 10 "Id-al-Adha"))) |
1102 "*Islamic holidays. | 1101 "Islamic holidays. |
1103 See the documentation for `calendar-holidays' for details." | 1102 See the documentation for `calendar-holidays' for details." |
1104 :type 'sexp | 1103 :type 'sexp |
1105 :group 'holidays) | 1104 :group 'holidays) |
1106 | 1105 |
1107 ;;;###autoload | 1106 ;;;###autoload |
1139 (holiday-fixed 11 12 "Birth of Baha'u'llah") | 1138 (holiday-fixed 11 12 "Birth of Baha'u'llah") |
1140 (if all-bahai-calendar-holidays | 1139 (if all-bahai-calendar-holidays |
1141 (holiday-fixed 11 26 "Day of the Covenant")) | 1140 (holiday-fixed 11 26 "Day of the Covenant")) |
1142 (if all-bahai-calendar-holidays | 1141 (if all-bahai-calendar-holidays |
1143 (holiday-fixed 11 28 "Ascension of `Abdu'l-Baha"))) | 1142 (holiday-fixed 11 28 "Ascension of `Abdu'l-Baha"))) |
1144 "*Baha'i holidays. | 1143 "Baha'i holidays. |
1145 See the documentation for `calendar-holidays' for details." | 1144 See the documentation for `calendar-holidays' for details." |
1146 :type 'sexp | 1145 :type 'sexp |
1147 :group 'holidays) | 1146 :group 'holidays) |
1148 | 1147 |
1149 ;;;###autoload | 1148 ;;;###autoload |
1171 (if (fboundp 'atan) | 1170 (if (fboundp 'atan) |
1172 (solar-time-string | 1171 (solar-time-string |
1173 (/ calendar-daylight-savings-ends-time (float 60)) | 1172 (/ calendar-daylight-savings-ends-time (float 60)) |
1174 calendar-daylight-time-zone-name) | 1173 calendar-daylight-time-zone-name) |
1175 "")))) | 1174 "")))) |
1176 "*Sun-related holidays. | 1175 "Sun-related holidays. |
1177 See the documentation for `calendar-holidays' for details." | 1176 See the documentation for `calendar-holidays' for details." |
1178 :type 'sexp | 1177 :type 'sexp |
1179 :group 'holidays) | 1178 :group 'holidays) |
1180 | 1179 |
1181 ;;;###autoload | 1180 ;;;###autoload |
1182 (put 'calendar-holidays 'risky-local-variable t) | 1181 (put 'calendar-holidays 'risky-local-variable t) |
1183 (defcustom calendar-holidays | 1182 (defcustom calendar-holidays |
1184 (append general-holidays local-holidays other-holidays | 1183 (append general-holidays local-holidays other-holidays |
1185 christian-holidays hebrew-holidays islamic-holidays | 1184 christian-holidays hebrew-holidays islamic-holidays |
1186 bahai-holidays oriental-holidays solar-holidays) | 1185 bahai-holidays oriental-holidays solar-holidays) |
1187 "*List of notable days for the command \\[holidays]. | 1186 "List of notable days for the command \\[holidays]. |
1188 | 1187 |
1189 Additional holidays are easy to add to the list, just put them in the | 1188 Additional holidays are easy to add to the list, just put them in the |
1190 list `other-holidays' in your .emacs file. Similarly, by setting any | 1189 list `other-holidays' in your .emacs file. Similarly, by setting any |
1191 of `general-holidays', `local-holidays' `christian-holidays', | 1190 of `general-holidays', `local-holidays' `christian-holidays', |
1192 `hebrew-holidays', `islamic-holidays', `bahai-holidays', | 1191 `hebrew-holidays', `islamic-holidays', `bahai-holidays', |
1302 ,mon (1+ (mod macro-y 12)) | 1301 ,mon (1+ (mod macro-y 12)) |
1303 ,yr (/ macro-y 12)) | 1302 ,yr (/ macro-y 12)) |
1304 (and (< macro-y 0) (> ,mon 1) (setq ,yr (1- ,yr))) | 1303 (and (< macro-y 0) (> ,mon 1) (setq ,yr (1- ,yr))) |
1305 (if (< ,yr 1) (setq ,yr (1- ,yr))))) ; 0 AD -> -1 BC, etc | 1304 (if (< ,yr 1) (setq ,yr (1- ,yr))))) ; 0 AD -> -1 BC, etc |
1306 | 1305 |
1306 (defun calendar-increment-month (n &optional mon yr) | |
1307 "Return the Nth month after MON/YR. | |
1308 The return value is a pair (MONTH . YEAR). | |
1309 MON defaults to `displayed-month'. YR defaults to `displayed-year'." | |
1310 (unless mon (setq mon displayed-month)) | |
1311 (unless yr (setq mon displayed-year)) | |
1312 (increment-calendar-month mon yr n) | |
1313 (cons mon yr)) | |
1314 | |
1307 (defmacro calendar-for-loop (var from init to final do &rest body) | 1315 (defmacro calendar-for-loop (var from init to final do &rest body) |
1308 "Execute a for loop." | 1316 "Execute a for loop." |
1309 (declare (debug (symbolp "from" form "to" form "do" body))) | 1317 (declare (debug (symbolp "from" form "to" form "do" body))) |
1310 `(let ((,var (1- ,init))) | 1318 `(let ((,var (1- ,init))) |
1311 (while (>= ,final (setq ,var (1+ ,var))) | 1319 (while (>= ,final (setq ,var (1+ ,var))) |
1312 ,@body))) | 1320 ,@body))) |
1313 | 1321 |
1314 (defmacro calendar-sum (index initial condition expression) | 1322 (defmacro calendar-sum (index initial condition expression) |
1315 "For INDEX = INITIAL et seq, as long as CONDITION holds, sum EXPRESSION." | 1323 "For INDEX = INITIAL et seq, as long as CONDITION holds, sum EXPRESSION." |
1324 (declare (debug (symbolp form form form))) | |
1316 `(let ((,index ,initial) | 1325 `(let ((,index ,initial) |
1317 (sum 0)) | 1326 (sum 0)) |
1318 (while ,condition | 1327 (while ,condition |
1319 (setq sum (+ sum ,expression)) | 1328 (setq sum (+ sum ,expression)) |
1320 (setq ,index (1+ ,index))) | 1329 (setq ,index (1+ ,index))) |
2138 (generate-calendar-window displayed-month displayed-year) | 2147 (generate-calendar-window displayed-month displayed-year) |
2139 (calendar-cursor-to-visible-date cursor-date))))) | 2148 (calendar-cursor-to-visible-date cursor-date))))) |
2140 | 2149 |
2141 ;;;###autoload | 2150 ;;;###autoload |
2142 (defcustom calendar-week-start-day 0 | 2151 (defcustom calendar-week-start-day 0 |
2143 "*The day of the week on which a week in the calendar begins. | 2152 "The day of the week on which a week in the calendar begins. |
2144 0 means Sunday (default), 1 means Monday, and so on. | 2153 0 means Sunday (default), 1 means Monday, and so on. |
2145 | 2154 |
2146 If you change this variable directly (without using customize) | 2155 If you change this variable directly (without using customize) |
2147 after starting `calendar', you should call `redraw-calendar' to | 2156 after starting `calendar', you should call `redraw-calendar' to |
2148 update the calendar display to reflect the change, otherwise | 2157 update the calendar display to reflect the change, otherwise |
2149 movement commands will not work correctly." | 2158 movement commands will not work correctly." |
2150 :type 'integer | 2159 :type 'integer |
2160 ;; Change the initialize so that if you reload calendar.el, it will not | |
2161 ;; cause a redraw (which may fail, e.g. with "invalid byte-code in | |
2162 ;; calendar.elc" because of the "byte-compile-dynamic"). | |
2163 :initialize 'custom-initialize-default | |
2151 :set (lambda (sym val) | 2164 :set (lambda (sym val) |
2152 (set sym val) | 2165 (set sym val) |
2153 (redraw-calendar)) | 2166 (redraw-calendar)) |
2154 :group 'calendar) | 2167 :group 'calendar) |
2155 | 2168 |
2156 (defcustom calendar-debug-sexp nil | 2169 (defcustom calendar-debug-sexp nil |
2157 "*Turn debugging on when evaluating a sexp in the diary or holiday list." | 2170 "Turn debugging on when evaluating a sexp in the diary or holiday list." |
2158 :type 'boolean | 2171 :type 'boolean |
2159 :group 'calendar) | 2172 :group 'calendar) |
2160 | 2173 |
2161 (defvar calendar-mode-map nil) | 2174 (defvar calendar-mode-map nil) |
2162 (if calendar-mode-map | 2175 (if calendar-mode-map |
2163 nil | 2176 nil |
2164 (setq calendar-mode-map (make-sparse-keymap)) | 2177 (let ((map (make-keymap))) |
2165 (require 'cal-menu) | 2178 (suppress-keymap map) |
2166 (calendar-for-loop i from 0 to 9 do | 2179 (dolist (c '(narrow-to-region mark-word mark-sexp mark-paragraph |
2167 (define-key calendar-mode-map (int-to-string i) 'digit-argument)) | 2180 mark-defun mark-whole-buffer mark-page |
2168 (let ((l (list 'narrow-to-region 'mark-word 'mark-sexp 'mark-paragraph | 2181 downcase-region upcase-region kill-region |
2169 'mark-defun 'mark-whole-buffer 'mark-page | 2182 copy-region-as-kill capitalize-region write-region)) |
2170 'downcase-region 'upcase-region 'kill-region | 2183 (define-key map (vector 'remap c) 'calendar-not-implemented)) |
2171 'copy-region-as-kill 'capitalize-region 'write-region))) | 2184 (define-key map ">" 'scroll-calendar-right) |
2172 (while l | 2185 (define-key map "\C-x>" 'scroll-calendar-right) |
2173 (substitute-key-definition (car l) 'calendar-not-implemented | 2186 (define-key map [prior] 'scroll-calendar-right-three-months) |
2174 calendar-mode-map global-map) | 2187 (define-key map "\ev" 'scroll-calendar-right-three-months) |
2175 (setq l (cdr l)))) | 2188 (define-key map "<" 'scroll-calendar-left) |
2176 (define-key calendar-mode-map "-" 'negative-argument) | 2189 (define-key map "\C-x<" 'scroll-calendar-left) |
2177 (define-key calendar-mode-map ">" 'scroll-calendar-right) | 2190 (define-key map [next] 'scroll-calendar-left-three-months) |
2178 (define-key calendar-mode-map "\C-x>" 'scroll-calendar-right) | 2191 (define-key map "\C-v" 'scroll-calendar-left-three-months) |
2179 (define-key calendar-mode-map [prior] 'scroll-calendar-right-three-months) | 2192 (define-key map "\C-b" 'calendar-backward-day) |
2180 (define-key calendar-mode-map "\ev" 'scroll-calendar-right-three-months) | 2193 (define-key map "\C-p" 'calendar-backward-week) |
2181 (define-key calendar-mode-map "<" 'scroll-calendar-left) | 2194 (define-key map "\e{" 'calendar-backward-month) |
2182 (define-key calendar-mode-map "\C-x<" 'scroll-calendar-left) | 2195 (define-key map "\C-x[" 'calendar-backward-year) |
2183 (define-key calendar-mode-map [next] 'scroll-calendar-left-three-months) | 2196 (define-key map "\C-f" 'calendar-forward-day) |
2184 (define-key calendar-mode-map "\C-v" 'scroll-calendar-left-three-months) | 2197 (define-key map "\C-n" 'calendar-forward-week) |
2185 (define-key calendar-mode-map "\C-b" 'calendar-backward-day) | 2198 (define-key map [left] 'calendar-backward-day) |
2186 (define-key calendar-mode-map "\C-p" 'calendar-backward-week) | 2199 (define-key map [up] 'calendar-backward-week) |
2187 (define-key calendar-mode-map "\e{" 'calendar-backward-month) | 2200 (define-key map [right] 'calendar-forward-day) |
2188 (define-key calendar-mode-map "\C-x[" 'calendar-backward-year) | 2201 (define-key map [down] 'calendar-forward-week) |
2189 (define-key calendar-mode-map "\C-f" 'calendar-forward-day) | 2202 (define-key map "\e}" 'calendar-forward-month) |
2190 (define-key calendar-mode-map "\C-n" 'calendar-forward-week) | 2203 (define-key map "\C-x]" 'calendar-forward-year) |
2191 (define-key calendar-mode-map [left] 'calendar-backward-day) | 2204 (define-key map "\C-a" 'calendar-beginning-of-week) |
2192 (define-key calendar-mode-map [up] 'calendar-backward-week) | 2205 (define-key map "\C-e" 'calendar-end-of-week) |
2193 (define-key calendar-mode-map [right] 'calendar-forward-day) | 2206 (define-key map "\ea" 'calendar-beginning-of-month) |
2194 (define-key calendar-mode-map [down] 'calendar-forward-week) | 2207 (define-key map "\ee" 'calendar-end-of-month) |
2195 (define-key calendar-mode-map "\e}" 'calendar-forward-month) | 2208 (define-key map "\e<" 'calendar-beginning-of-year) |
2196 (define-key calendar-mode-map "\C-x]" 'calendar-forward-year) | 2209 (define-key map "\e>" 'calendar-end-of-year) |
2197 (define-key calendar-mode-map "\C-a" 'calendar-beginning-of-week) | 2210 (define-key map "\C-@" 'calendar-set-mark) |
2198 (define-key calendar-mode-map "\C-e" 'calendar-end-of-week) | 2211 ;; Many people are used to typing C-SPC and getting C-@. |
2199 (define-key calendar-mode-map "\ea" 'calendar-beginning-of-month) | 2212 (define-key map [?\C- ] 'calendar-set-mark) |
2200 (define-key calendar-mode-map "\ee" 'calendar-end-of-month) | 2213 (define-key map "\C-x\C-x" 'calendar-exchange-point-and-mark) |
2201 (define-key calendar-mode-map "\e<" 'calendar-beginning-of-year) | 2214 (define-key map "\e=" 'calendar-count-days-region) |
2202 (define-key calendar-mode-map "\e>" 'calendar-end-of-year) | 2215 (define-key map "gd" 'calendar-goto-date) |
2203 (define-key calendar-mode-map "\C-@" 'calendar-set-mark) | 2216 (define-key map "gD" 'calendar-goto-day-of-year) |
2204 ;; Many people are used to typing C-SPC and getting C-@. | 2217 (define-key map "gj" 'calendar-goto-julian-date) |
2205 (define-key calendar-mode-map [?\C- ] 'calendar-set-mark) | 2218 (define-key map "ga" 'calendar-goto-astro-day-number) |
2206 (define-key calendar-mode-map "\C-x\C-x" 'calendar-exchange-point-and-mark) | 2219 (define-key map "gh" 'calendar-goto-hebrew-date) |
2207 (define-key calendar-mode-map "\e=" 'calendar-count-days-region) | 2220 (define-key map "gi" 'calendar-goto-islamic-date) |
2208 (define-key calendar-mode-map "gd" 'calendar-goto-date) | 2221 (define-key map "gb" 'calendar-goto-bahai-date) |
2209 (define-key calendar-mode-map "gD" 'calendar-goto-day-of-year) | 2222 (define-key map "gC" 'calendar-goto-chinese-date) |
2210 (define-key calendar-mode-map "gj" 'calendar-goto-julian-date) | 2223 (define-key map "gk" 'calendar-goto-coptic-date) |
2211 (define-key calendar-mode-map "ga" 'calendar-goto-astro-day-number) | 2224 (define-key map "ge" 'calendar-goto-ethiopic-date) |
2212 (define-key calendar-mode-map "gh" 'calendar-goto-hebrew-date) | 2225 (define-key map "gp" 'calendar-goto-persian-date) |
2213 (define-key calendar-mode-map "gi" 'calendar-goto-islamic-date) | 2226 (define-key map "gc" 'calendar-goto-iso-date) |
2214 (define-key calendar-mode-map "gb" 'calendar-goto-bahai-date) | 2227 (define-key map "gw" 'calendar-goto-iso-week) |
2215 (define-key calendar-mode-map "gC" 'calendar-goto-chinese-date) | 2228 (define-key map "gf" 'calendar-goto-french-date) |
2216 (define-key calendar-mode-map "gk" 'calendar-goto-coptic-date) | 2229 (define-key map "gml" 'calendar-goto-mayan-long-count-date) |
2217 (define-key calendar-mode-map "ge" 'calendar-goto-ethiopic-date) | 2230 (define-key map "gmpc" 'calendar-previous-calendar-round-date) |
2218 (define-key calendar-mode-map "gp" 'calendar-goto-persian-date) | 2231 (define-key map "gmnc" 'calendar-next-calendar-round-date) |
2219 (define-key calendar-mode-map "gc" 'calendar-goto-iso-date) | 2232 (define-key map "gmph" 'calendar-previous-haab-date) |
2220 (define-key calendar-mode-map "gw" 'calendar-goto-iso-week) | 2233 (define-key map "gmnh" 'calendar-next-haab-date) |
2221 (define-key calendar-mode-map "gf" 'calendar-goto-french-date) | 2234 (define-key map "gmpt" 'calendar-previous-tzolkin-date) |
2222 (define-key calendar-mode-map "gml" 'calendar-goto-mayan-long-count-date) | 2235 (define-key map "gmnt" 'calendar-next-tzolkin-date) |
2223 (define-key calendar-mode-map "gmpc" 'calendar-previous-calendar-round-date) | 2236 (define-key map "Aa" 'appt-add) |
2224 (define-key calendar-mode-map "gmnc" 'calendar-next-calendar-round-date) | 2237 (define-key map "Ad" 'appt-delete) |
2225 (define-key calendar-mode-map "gmph" 'calendar-previous-haab-date) | 2238 (define-key map "S" 'calendar-sunrise-sunset) |
2226 (define-key calendar-mode-map "gmnh" 'calendar-next-haab-date) | 2239 (define-key map "M" 'calendar-phases-of-moon) |
2227 (define-key calendar-mode-map "gmpt" 'calendar-previous-tzolkin-date) | 2240 (define-key map " " 'scroll-other-window) |
2228 (define-key calendar-mode-map "gmnt" 'calendar-next-tzolkin-date) | 2241 (define-key map (kbd "DEL") 'scroll-other-window-down) |
2229 (define-key calendar-mode-map "Aa" 'appt-add) | 2242 (define-key map "\C-c\C-l" 'redraw-calendar) |
2230 (define-key calendar-mode-map "Ad" 'appt-delete) | 2243 (define-key map "." 'calendar-goto-today) |
2231 (define-key calendar-mode-map "S" 'calendar-sunrise-sunset) | 2244 (define-key map "o" 'calendar-other-month) |
2232 (define-key calendar-mode-map "M" 'calendar-phases-of-moon) | 2245 (define-key map "q" 'exit-calendar) |
2233 (define-key calendar-mode-map " " 'scroll-other-window) | 2246 (define-key map "a" 'list-calendar-holidays) |
2234 (define-key calendar-mode-map (kbd "DEL") 'scroll-other-window-down) | 2247 (define-key map "h" 'calendar-cursor-holidays) |
2235 (define-key calendar-mode-map "\C-c\C-l" 'redraw-calendar) | 2248 (define-key map "x" 'mark-calendar-holidays) |
2236 (define-key calendar-mode-map "." 'calendar-goto-today) | 2249 (define-key map "u" 'calendar-unmark) |
2237 (define-key calendar-mode-map "o" 'calendar-other-month) | 2250 (define-key map "m" 'mark-diary-entries) |
2238 (define-key calendar-mode-map "q" 'exit-calendar) | 2251 (define-key map "d" 'diary-view-entries) |
2239 (define-key calendar-mode-map "a" 'list-calendar-holidays) | 2252 (define-key map "D" 'view-other-diary-entries) |
2240 (define-key calendar-mode-map "h" 'calendar-cursor-holidays) | 2253 (define-key map "s" 'show-all-diary-entries) |
2241 (define-key calendar-mode-map "x" 'mark-calendar-holidays) | 2254 (define-key map "pd" 'calendar-print-day-of-year) |
2242 (define-key calendar-mode-map "u" 'calendar-unmark) | 2255 (define-key map "pC" 'calendar-print-chinese-date) |
2243 (define-key calendar-mode-map "m" 'mark-diary-entries) | 2256 (define-key map "pk" 'calendar-print-coptic-date) |
2244 (define-key calendar-mode-map "d" 'diary-view-entries) | 2257 (define-key map "pe" 'calendar-print-ethiopic-date) |
2245 (define-key calendar-mode-map "D" 'view-other-diary-entries) | 2258 (define-key map "pp" 'calendar-print-persian-date) |
2246 (define-key calendar-mode-map "s" 'show-all-diary-entries) | 2259 (define-key map "pc" 'calendar-print-iso-date) |
2247 (define-key calendar-mode-map "pd" 'calendar-print-day-of-year) | 2260 (define-key map "pj" 'calendar-print-julian-date) |
2248 (define-key calendar-mode-map "pC" 'calendar-print-chinese-date) | 2261 (define-key map "pa" 'calendar-print-astro-day-number) |
2249 (define-key calendar-mode-map "pk" 'calendar-print-coptic-date) | 2262 (define-key map "ph" 'calendar-print-hebrew-date) |
2250 (define-key calendar-mode-map "pe" 'calendar-print-ethiopic-date) | 2263 (define-key map "pi" 'calendar-print-islamic-date) |
2251 (define-key calendar-mode-map "pp" 'calendar-print-persian-date) | 2264 (define-key map "pb" 'calendar-print-bahai-date) |
2252 (define-key calendar-mode-map "pc" 'calendar-print-iso-date) | 2265 (define-key map "pf" 'calendar-print-french-date) |
2253 (define-key calendar-mode-map "pj" 'calendar-print-julian-date) | 2266 (define-key map "pm" 'calendar-print-mayan-date) |
2254 (define-key calendar-mode-map "pa" 'calendar-print-astro-day-number) | 2267 (define-key map "po" 'calendar-print-other-dates) |
2255 (define-key calendar-mode-map "ph" 'calendar-print-hebrew-date) | 2268 (define-key map "id" 'insert-diary-entry) |
2256 (define-key calendar-mode-map "pi" 'calendar-print-islamic-date) | 2269 (define-key map "iw" 'insert-weekly-diary-entry) |
2257 (define-key calendar-mode-map "pb" 'calendar-print-bahai-date) | 2270 (define-key map "im" 'insert-monthly-diary-entry) |
2258 (define-key calendar-mode-map "pf" 'calendar-print-french-date) | 2271 (define-key map "iy" 'insert-yearly-diary-entry) |
2259 (define-key calendar-mode-map "pm" 'calendar-print-mayan-date) | 2272 (define-key map "ia" 'insert-anniversary-diary-entry) |
2260 (define-key calendar-mode-map "po" 'calendar-print-other-dates) | 2273 (define-key map "ib" 'insert-block-diary-entry) |
2261 (define-key calendar-mode-map "id" 'insert-diary-entry) | 2274 (define-key map "ic" 'insert-cyclic-diary-entry) |
2262 (define-key calendar-mode-map "iw" 'insert-weekly-diary-entry) | 2275 (define-key map "ihd" 'insert-hebrew-diary-entry) |
2263 (define-key calendar-mode-map "im" 'insert-monthly-diary-entry) | 2276 (define-key map "ihm" 'insert-monthly-hebrew-diary-entry) |
2264 (define-key calendar-mode-map "iy" 'insert-yearly-diary-entry) | 2277 (define-key map "ihy" 'insert-yearly-hebrew-diary-entry) |
2265 (define-key calendar-mode-map "ia" 'insert-anniversary-diary-entry) | 2278 (define-key map "iid" 'insert-islamic-diary-entry) |
2266 (define-key calendar-mode-map "ib" 'insert-block-diary-entry) | 2279 (define-key map "iim" 'insert-monthly-islamic-diary-entry) |
2267 (define-key calendar-mode-map "ic" 'insert-cyclic-diary-entry) | 2280 (define-key map "iiy" 'insert-yearly-islamic-diary-entry) |
2268 (define-key calendar-mode-map "ihd" 'insert-hebrew-diary-entry) | 2281 (define-key map "iBd" 'insert-bahai-diary-entry) |
2269 (define-key calendar-mode-map "ihm" 'insert-monthly-hebrew-diary-entry) | 2282 (define-key map "iBm" 'insert-monthly-bahai-diary-entry) |
2270 (define-key calendar-mode-map "ihy" 'insert-yearly-hebrew-diary-entry) | 2283 (define-key map "iBy" 'insert-yearly-bahai-diary-entry) |
2271 (define-key calendar-mode-map "iid" 'insert-islamic-diary-entry) | 2284 (define-key map "?" 'calendar-goto-info-node) |
2272 (define-key calendar-mode-map "iim" 'insert-monthly-islamic-diary-entry) | 2285 (define-key map "tm" 'cal-tex-cursor-month) |
2273 (define-key calendar-mode-map "iiy" 'insert-yearly-islamic-diary-entry) | 2286 (define-key map "tM" 'cal-tex-cursor-month-landscape) |
2274 (define-key calendar-mode-map "iBd" 'insert-bahai-diary-entry) | 2287 (define-key map "td" 'cal-tex-cursor-day) |
2275 (define-key calendar-mode-map "iBm" 'insert-monthly-bahai-diary-entry) | 2288 (define-key map "tw1" 'cal-tex-cursor-week) |
2276 (define-key calendar-mode-map "iBy" 'insert-yearly-bahai-diary-entry) | 2289 (define-key map "tw2" 'cal-tex-cursor-week2) |
2277 (define-key calendar-mode-map "?" 'calendar-goto-info-node) | 2290 (define-key map "tw3" 'cal-tex-cursor-week-iso) |
2278 (define-key calendar-mode-map "tm" 'cal-tex-cursor-month) | 2291 (define-key map "tw4" 'cal-tex-cursor-week-monday) |
2279 (define-key calendar-mode-map "tM" 'cal-tex-cursor-month-landscape) | 2292 (define-key map "tfd" 'cal-tex-cursor-filofax-daily) |
2280 (define-key calendar-mode-map "td" 'cal-tex-cursor-day) | 2293 (define-key map "tfw" 'cal-tex-cursor-filofax-2week) |
2281 (define-key calendar-mode-map "tw1" 'cal-tex-cursor-week) | 2294 (define-key map "tfW" 'cal-tex-cursor-filofax-week) |
2282 (define-key calendar-mode-map "tw2" 'cal-tex-cursor-week2) | 2295 (define-key map "tfy" 'cal-tex-cursor-filofax-year) |
2283 (define-key calendar-mode-map "tw3" 'cal-tex-cursor-week-iso) | 2296 (define-key map "ty" 'cal-tex-cursor-year) |
2284 (define-key calendar-mode-map "tw4" 'cal-tex-cursor-week-monday) | 2297 (define-key map "tY" 'cal-tex-cursor-year-landscape) |
2285 (define-key calendar-mode-map "tfd" 'cal-tex-cursor-filofax-daily) | 2298 (setq calendar-mode-map map) |
2286 (define-key calendar-mode-map "tfw" 'cal-tex-cursor-filofax-2week) | 2299 ;; Require cal-menu after initializing calendar-mode-map because it uses it. |
2287 (define-key calendar-mode-map "tfW" 'cal-tex-cursor-filofax-week) | 2300 (require 'cal-menu))) |
2288 (define-key calendar-mode-map "tfy" 'cal-tex-cursor-filofax-year) | |
2289 (define-key calendar-mode-map "ty" 'cal-tex-cursor-year) | |
2290 (define-key calendar-mode-map "tY" 'cal-tex-cursor-year-landscape)) | |
2291 | 2301 |
2292 (defun describe-calendar-mode () | 2302 (defun describe-calendar-mode () |
2293 "Create a help buffer with a brief description of the `calendar-mode'." | 2303 "Create a help buffer with a brief description of the `calendar-mode'." |
2294 (interactive) | 2304 (interactive) |
2295 (with-output-to-temp-buffer "*Help*" | 2305 (help-setup-xref (list #'describe-calendar-mode) (interactive-p)) |
2306 (with-output-to-temp-buffer (help-buffer) | |
2296 (princ | 2307 (princ |
2297 (format | 2308 (format |
2298 "Calendar Mode:\nFor a complete description, type %s\n%s\n" | 2309 "Calendar Mode:\nFor a complete description, type %s\n%s\n" |
2299 (substitute-command-keys | 2310 (substitute-command-keys |
2300 "\\<calendar-mode-map>\\[describe-mode] from within the calendar") | 2311 "\\<calendar-mode-map>\\[describe-mode] from within the calendar") |
2301 (substitute-command-keys "\\{calendar-mode-map}"))) | 2312 (substitute-command-keys "\\{calendar-mode-map}"))) |
2302 (save-excursion | |
2303 (set-buffer standard-output) | |
2304 (help-mode)) | |
2305 (print-help-return-message))) | 2313 (print-help-return-message))) |
2306 | 2314 |
2307 ;; Calendar mode is suitable only for specially formatted data. | 2315 ;; Calendar mode is suitable only for specially formatted data. |
2308 (put 'calendar-mode 'mode-class 'special) | 2316 (put 'calendar-mode 'mode-class 'special) |
2309 | 2317 |
2449 (n (- length (length (apply 'concat strings)))) | 2457 (n (- length (length (apply 'concat strings)))) |
2450 (m (1- (length strings))) | 2458 (m (1- (length strings))) |
2451 (s (car strings)) | 2459 (s (car strings)) |
2452 (strings (cdr strings)) | 2460 (strings (cdr strings)) |
2453 (i 0)) | 2461 (i 0)) |
2454 (while strings | 2462 (dolist (string strings) |
2455 (setq s (concat s | 2463 (setq s (concat s |
2456 (make-string (max 0 (/ (+ n i) m)) char) | 2464 (make-string (max 0 (/ (+ n i) m)) char) |
2457 (car strings))) | 2465 string)) |
2458 (setq i (1+ i)) | 2466 (setq i (1+ i))) |
2459 (setq strings (cdr strings))) | |
2460 (substring s 0 length))) | 2467 (substring s 0 length))) |
2461 | 2468 |
2462 (defun update-calendar-mode-line () | 2469 (defun update-calendar-mode-line () |
2463 "Update the calendar mode line with the current date and date style." | 2470 "Update the calendar mode line with the current date and date style." |
2464 (if (bufferp (get-buffer calendar-buffer)) | 2471 (if (bufferp (get-buffer calendar-buffer)) |
2476 "List of all calendar-related windows." | 2483 "List of all calendar-related windows." |
2477 (let ((calendar-buffers (calendar-buffer-list)) | 2484 (let ((calendar-buffers (calendar-buffer-list)) |
2478 list) | 2485 list) |
2479 (walk-windows (lambda (w) | 2486 (walk-windows (lambda (w) |
2480 (if (memq (window-buffer w) calendar-buffers) | 2487 (if (memq (window-buffer w) calendar-buffers) |
2481 (setq list (cons w list)))) | 2488 (push w list))) |
2482 nil t) | 2489 nil t) |
2483 list)) | 2490 list)) |
2484 | 2491 |
2485 (defun calendar-buffer-list () | 2492 (defun calendar-buffer-list () |
2486 "List of all calendar-related buffers." | 2493 "List of all calendar-related buffers." |
2487 (let* ((diary-buffer (get-file-buffer diary-file)) | 2494 (let* ((diary-buffer (get-file-buffer diary-file)) |
2488 (buffers (list "*Yahrzeits*" lunar-phases-buffer holiday-buffer | 2495 (buffers (list "*Yahrzeits*" lunar-phases-buffer holiday-buffer |
2489 fancy-diary-buffer diary-buffer calendar-buffer | 2496 fancy-diary-buffer diary-buffer calendar-buffer |
2490 other-calendars-buffer)) | 2497 other-calendars-buffer)) |
2491 (buffer-list nil) | 2498 (buffer-list nil)) |
2492 b) | 2499 (dolist (b buffers) |
2493 (while buffers | |
2494 (setq b (car buffers)) | |
2495 (setq b (cond ((stringp b) (get-buffer b)) | 2500 (setq b (cond ((stringp b) (get-buffer b)) |
2496 ((bufferp b) b) | 2501 ((bufferp b) b) |
2497 (t nil))) | 2502 (t nil))) |
2498 (if b (setq buffer-list (cons b buffer-list))) | 2503 (if b (push b buffer-list))) |
2499 (setq buffers (cdr buffers))) | |
2500 buffer-list)) | 2504 buffer-list)) |
2501 | 2505 |
2502 (defun exit-calendar () | 2506 (defun exit-calendar () |
2503 "Get out of the calendar window and hide it and related buffers." | 2507 "Get out of the calendar window and hide it and related buffers." |
2504 (interactive) | 2508 (interactive) |
2640 With argument, jump to mark, pop it, and put point at end of ring." | 2644 With argument, jump to mark, pop it, and put point at end of ring." |
2641 (interactive "P") | 2645 (interactive "P") |
2642 (let ((date (calendar-cursor-to-date t))) | 2646 (let ((date (calendar-cursor-to-date t))) |
2643 (if (null arg) | 2647 (if (null arg) |
2644 (progn | 2648 (progn |
2645 (setq calendar-mark-ring (cons date calendar-mark-ring)) | 2649 (push date calendar-mark-ring) |
2646 ;; Since the top of the mark ring is the marked date in the | 2650 ;; Since the top of the mark ring is the marked date in the |
2647 ;; calendar, the mark ring in the calendar is one longer than | 2651 ;; calendar, the mark ring in the calendar is one longer than |
2648 ;; in other buffers to get the same effect. | 2652 ;; in other buffers to get the same effect. |
2649 (if (> (length calendar-mark-ring) (1+ mark-ring-max)) | 2653 (if (> (length calendar-mark-ring) (1+ mark-ring-max)) |
2650 (setcdr (nthcdr mark-ring-max calendar-mark-ring) nil)) | 2654 (setcdr (nthcdr mark-ring-max calendar-mark-ring) nil)) |
2947 | 2951 |
2948 (defun calendar-star-date () | 2952 (defun calendar-star-date () |
2949 "Replace the date under the cursor in the calendar window with asterisks. | 2953 "Replace the date under the cursor in the calendar window with asterisks. |
2950 This function can be used with the `today-visible-calendar-hook' run after the | 2954 This function can be used with the `today-visible-calendar-hook' run after the |
2951 calendar window has been prepared." | 2955 calendar window has been prepared." |
2952 (let ((inhibit-read-only t)) | 2956 (let ((inhibit-read-only t) |
2953 (make-local-variable 'calendar-starred-day) | 2957 (modified (buffer-modified-p))) |
2954 (forward-char 1) | 2958 (forward-char 1) |
2955 (setq calendar-starred-day | 2959 (set (make-local-variable 'calendar-starred-day) |
2956 (string-to-number | 2960 (string-to-number |
2957 (buffer-substring (point) (- (point) 2)))) | 2961 (buffer-substring (point) (- (point) 2)))) |
2962 ;; Insert before deleting, to better preserve markers. | |
2963 (insert "**") | |
2964 (forward-char -2) | |
2958 (delete-char -2) | 2965 (delete-char -2) |
2959 (insert "**") | 2966 (forward-char 1) |
2960 (backward-char 1) | 2967 (restore-buffer-modified-p modified))) |
2961 (set-buffer-modified-p nil))) | |
2962 | 2968 |
2963 (defun calendar-mark-today () | 2969 (defun calendar-mark-today () |
2964 "Mark the date under the cursor in the calendar window. | 2970 "Mark the date under the cursor in the calendar window. |
2965 The date is marked with `calendar-today-marker'. This function can be used with | 2971 The date is marked with `calendar-today-marker'. This function can be used with |
2966 the `today-visible-calendar-hook' run after the calendar window has been | 2972 the `today-visible-calendar-hook' run after the calendar window has been |
3046 (defun calendar-print-other-dates () | 3052 (defun calendar-print-other-dates () |
3047 "Show dates on other calendars for date under the cursor." | 3053 "Show dates on other calendars for date under the cursor." |
3048 (interactive) | 3054 (interactive) |
3049 (let* ((date (calendar-cursor-to-date t))) | 3055 (let* ((date (calendar-cursor-to-date t))) |
3050 (with-current-buffer (get-buffer-create other-calendars-buffer) | 3056 (with-current-buffer (get-buffer-create other-calendars-buffer) |
3051 (setq buffer-read-only nil) | 3057 (let ((inhibit-read-only t) |
3052 (calendar-set-mode-line | 3058 (modified (buffer-modified-p))) |
3053 (concat (calendar-date-string date) " (Gregorian)")) | 3059 (calendar-set-mode-line |
3054 (erase-buffer) | 3060 (concat (calendar-date-string date) " (Gregorian)")) |
3055 (insert | 3061 (erase-buffer) |
3056 (mapconcat 'identity | 3062 (apply |
3057 (list (calendar-day-of-year-string date) | 3063 'insert |
3058 (format "ISO date: %s" (calendar-iso-date-string date)) | 3064 (delq nil |
3059 (format "Julian date: %s" | 3065 (list |
3060 (calendar-julian-date-string date)) | 3066 (calendar-day-of-year-string date) "\n" |
3061 (format | 3067 (format "ISO date: %s\n" (calendar-iso-date-string date)) |
3062 "Astronomical (Julian) day number (at noon UTC): %s.0" | 3068 (format "Julian date: %s\n" |
3063 (calendar-astro-date-string date)) | 3069 (calendar-julian-date-string date)) |
3064 (format "Fixed (RD) date: %s" | 3070 (format "Astronomical (Julian) day number (at noon UTC): %s.0\n" |
3065 (calendar-absolute-from-gregorian date)) | 3071 (calendar-astro-date-string date)) |
3066 (format "Hebrew date (before sunset): %s" | 3072 (format "Fixed (RD) date: %s\n" |
3067 (calendar-hebrew-date-string date)) | 3073 (calendar-absolute-from-gregorian date)) |
3068 (format "Persian date: %s" | 3074 (format "Hebrew date (before sunset): %s\n" |
3069 (calendar-persian-date-string date)) | 3075 (calendar-hebrew-date-string date)) |
3070 (let ((i (calendar-islamic-date-string date))) | 3076 (format "Persian date: %s\n" |
3071 (if (not (string-equal i "")) | 3077 (calendar-persian-date-string date)) |
3072 (format "Islamic date (before sunset): %s" i))) | 3078 (let ((i (calendar-islamic-date-string date))) |
3073 (let ((b (calendar-bahai-date-string date))) | 3079 (if (not (string-equal i "")) |
3074 (if (not (string-equal b "")) | 3080 (format "Islamic date (before sunset): %s\n" i))) |
3075 (format "Baha'i date (before sunset): %s" b))) | 3081 (let ((b (calendar-bahai-date-string date))) |
3076 (format "Chinese date: %s" | 3082 (if (not (string-equal b "")) |
3077 (calendar-chinese-date-string date)) | 3083 (format "Baha'i date (before sunset): %s\n" b))) |
3078 (let ((c (calendar-coptic-date-string date))) | 3084 (format "Chinese date: %s\n" |
3079 (if (not (string-equal c "")) | 3085 (calendar-chinese-date-string date)) |
3080 (format "Coptic date: %s" c))) | 3086 (let ((c (calendar-coptic-date-string date))) |
3081 (let ((e (calendar-ethiopic-date-string date))) | 3087 (if (not (string-equal c "")) |
3082 (if (not (string-equal e "")) | 3088 (format "Coptic date: %s\n" c))) |
3083 (format "Ethiopic date: %s" e))) | 3089 (let ((e (calendar-ethiopic-date-string date))) |
3084 (let ((f (calendar-french-date-string date))) | 3090 (if (not (string-equal e "")) |
3085 (if (not (string-equal f "")) | 3091 (format "Ethiopic date: %s\n" e))) |
3086 (format "French Revolutionary date: %s" f))) | 3092 (let ((f (calendar-french-date-string date))) |
3087 (format "Mayan date: %s" | 3093 (if (not (string-equal f "")) |
3088 (calendar-mayan-date-string date))) | 3094 (format "French Revolutionary date: %s\n" f))) |
3089 "\n")) | 3095 (format "Mayan date: %s\n" |
3090 (goto-char (point-min)) | 3096 (calendar-mayan-date-string date))))) |
3091 (set-buffer-modified-p nil) | 3097 (goto-char (point-min)) |
3092 (setq buffer-read-only t) | 3098 (restore-buffer-modified-p modified)) |
3093 (display-buffer other-calendars-buffer)))) | 3099 (display-buffer other-calendars-buffer)))) |
3094 | 3100 |
3095 (defun calendar-print-day-of-year () | 3101 (defun calendar-print-day-of-year () |
3096 "Show day number in year/days remaining in year for date under the cursor." | 3102 "Show day number in year/days remaining in year for date under the cursor." |
3097 (interactive) | 3103 (interactive) |
3098 (message (calendar-day-of-year-string (calendar-cursor-to-date t)))) | 3104 (message (calendar-day-of-year-string (calendar-cursor-to-date t)))) |
3099 | 3105 |
3100 (defun calendar-set-mode-line (str) | 3106 (defun calendar-set-mode-line (str) |
3101 "Set mode line to STR, centered, surrounded by dashes." | 3107 "Set mode line to STR, centered, surrounded by dashes." |
3102 (setq mode-line-format | 3108 (let* ((edges (window-edges)) |
3103 (calendar-string-spread | |
3104 (list str) ?- | |
3105 ;; As per doc of window-width, total visible mode-line length. | 3109 ;; As per doc of window-width, total visible mode-line length. |
3106 (let ((edges (window-edges))) (- (nth 2 edges) (nth 0 edges)))))) | 3110 (width (- (nth 2 edges) (nth 0 edges)))) |
3111 (setq mode-line-format | |
3112 (if buffer-file-name | |
3113 `("-" mode-line-modified | |
3114 ,(calendar-string-spread (list str) ?- (- width 6)) | |
3115 "---") | |
3116 (calendar-string-spread (list str) ?- width))))) | |
3107 | 3117 |
3108 (defun calendar-mod (m n) | 3118 (defun calendar-mod (m n) |
3109 "Non-negative remainder of M/N with N instead of 0." | 3119 "Non-negative remainder of M/N with N instead of 0." |
3110 (1+ (mod (1- m) n))) | 3120 (1+ (mod (1- m) n))) |
3111 | 3121 |