comparison lisp/calendar/calendar.el @ 93374:4e21455e4410

(diary-file, american-date-diary-pattern) (european-date-diary-pattern,european-calendar-display-form) (american-calendar-display-form, diary-display-hook): Doc fixes. (european-calendar-style): Doc fix. Use calendar-set-date-style for custom :set. Mark as obsolete. (calendar-date-style, iso-date-diary-pattern) (iso-calendar-display-form): New user variables. (diary-date-forms, calendar-date-display-form): Set using calendar-date-style. Doc fix. (calendar-set-date-style): New command. (european-calendar, american-calendar): Use calendar-set-date-style. Mark as obsolete.
author Glenn Morris <rgm@gnu.org>
date Sat, 29 Mar 2008 02:44:03 +0000
parents 1515466cea2b
children 64521597b7dd
comparison
equal deleted inserted replaced
93373:6facf919dde4 93374:4e21455e4410
350 ignored. Any of DAY, MONTH, or MONTHNAME, YEAR can be `*' which 350 ignored. Any of DAY, MONTH, or MONTHNAME, YEAR can be `*' which
351 matches any day, month, or year, respectively. If the date does 351 matches any day, month, or year, respectively. If the date does
352 not contain a year, it is generic and applies to any year. A 352 not contain a year, it is generic and applies to any year. A
353 DAYNAME entry applies to the appropriate day of the week in every week. 353 DAYNAME entry applies to the appropriate day of the week in every week.
354 354
355 The European style (in which the day precedes the month) can be 355 You can customize `diary-date-forms' to your preferred format.
356 used instead, if you execute `european-calendar' when in the 356 Three default styles are provided: `american-date-diary-pattern',
357 calendar, or set `european-calendar-style' to t in your .emacs 357 `european-date-diary-pattern', and `iso-date-diary-pattern'.
358 file. The European forms (see `european-date-diary-pattern') are 358 You can choose between these by setting `calendar-date-style' in your
359 359 .emacs file, or by using `calendar-set-date-style' when in the calendar.
360 DAY/MONTH
361 DAY/MONTH/YEAR
362 DAY MONTHNAME
363 DAY MONTHNAME YEAR
364 DAYNAME
365
366 To revert to the default American style from the European style, execute
367 `american-calendar' in the calendar.
368 360
369 A diary entry can be preceded by the character `diary-nonmarking-symbol' 361 A diary entry can be preceded by the character `diary-nonmarking-symbol'
370 \(ordinarily `&') to make that entry nonmarking--that is, it will not be 362 \(ordinarily `&') to make that entry nonmarking--that is, it will not be
371 marked on dates in the calendar window but will appear in a diary window. 363 marked on dates in the calendar window but will appear in a diary window.
372 364
445 :type 'string 437 :type 'string
446 :group 'diary) 438 :group 'diary)
447 439
448 ;;;###autoload 440 ;;;###autoload
449 (defcustom european-calendar-style nil 441 (defcustom european-calendar-style nil
450 "Use the European style of dates in the diary and in any displays. 442 "Non-nil means use the European style of dates in the diary and display.
451 If this variable is non-nil, a date 1/2/1990 would be interpreted as 443 In this case, a date like 1/2/1990 would be interpreted as
452 February 1, 1990. The default European date styles (see 444 February 1, 1990. See `european-date-diary-pattern' for the
453 `european-date-diary-pattern') are 445 default European diary date styles.
454
455 DAY/MONTH
456 DAY/MONTH/YEAR
457 DAY MONTHNAME
458 DAY MONTHNAME YEAR
459 DAYNAME
460
461 Names can be capitalized or not, written in full (as specified by the
462 variable `calendar-day-name-array'), or abbreviated (as specified by
463 `calendar-day-abbrev-array') with or without a period.
464 446
465 Setting this variable directly does not take effect (if the 447 Setting this variable directly does not take effect (if the
466 calendar package is already loaded). Rather, use either 448 calendar package is already loaded). Rather, use either
467 \\[customize] or the functions `european-calendar' and 449 \\[customize] or the function `calendar-set-date-style'."
468 `american-calendar'."
469 :type 'boolean 450 :type 'boolean
470 ;; Without :initialize (require 'calendar) throws an error because 451 ;; Without :initialize (require 'calendar) throws an error because
471 ;; american-calendar is undefined at this point. 452 ;; calendar-set-date-style is undefined at this point.
472 :initialize 'custom-initialize-default 453 :initialize 'custom-initialize-default
473 :set (lambda (symbol value) 454 :set (lambda (symbol value)
474 (if value 455 (if value
475 (european-calendar) 456 (calendar-set-date-style 'european)
476 (american-calendar))) 457 (calendar-set-date-style 'american)))
477 :group 'diary) 458 :group 'diary)
459
460 ;;;###autoload
461 (make-obsolete-variable 'european-calendar-style 'calendar-date-style "23.1")
462
463 ;; Used by various other packages.
464 ;;;###autoload
465 (defcustom calendar-date-style (if european-calendar-style 'european
466 'american)
467 "Your preferred style for writing dates.
468 The options are:
469 `american' - month/day/year
470 `european' - day/month/year
471 `iso' - year/month/day
472 This affects how dates written in your diary are interpreted.
473 It also affects date display, as well as those calendar and diary
474 functions that take a date as an argument, e.g. `diary-date', by
475 changing the order in which the arguments are interpreted.
476
477 Setting this variable directly does not take effect (if the
478 calendar package is already loaded). Rather, use either
479 \\[customize] or the function `calendar-set-date-style'."
480 :version "23.1"
481 :type '(choice (const american :tag "Month/Day/Year")
482 (const european :tag "Day/Month/Year")
483 (const iso :tag "Year/Month/Day"))
484 :initialize 'custom-initialize-default
485 :set (lambda (symbol value)
486 (calendar-set-date-style value))
487 :group 'calendar)
488
489 ;; Next three are provided to aid in setting diary-date-forms.
490 (defcustom iso-date-diary-pattern
491 '((month "[-/]" day "[^-/0-9]")
492 (year "[-/]" month "[-/]" day "[^0-9]")
493 (monthname "-" day "[^-0-9]")
494 (year "-" monthname "-" day "[^0-9]")
495 (dayname "\\W"))
496 "List of pseudo-patterns describing the ISO style of dates.
497 The defaults are: MONTH[-/]DAY; YEAR[-/]MONTH[-/]DAY; MONTHNAME-DAY;
498 YEAR-MONTHNAME-DAY; DAYNAME. Normally you should not customize this,
499 but `diary-date-forms' (which see)."
500 :version "23.1"
501 :type '(repeat (choice (cons :tag "Backup"
502 :value (backup . nil)
503 (const backup)
504 (repeat (list :inline t :format "%v"
505 (symbol :tag "Keyword")
506 (choice symbol regexp))))
507 (repeat (list :inline t :format "%v"
508 (symbol :tag "Keyword")
509 (choice symbol regexp)))))
510 :group 'diary)
478 511
479 (defcustom american-date-diary-pattern 512 (defcustom american-date-diary-pattern
480 '((month "/" day "[^/0-9]") 513 '((month "/" day "[^/0-9]")
481 (month "/" day "/" year "[^0-9]") 514 (month "/" day "/" year "[^0-9]")
482 (monthname " *" day "[^,0-9]") 515 (monthname " *" day "[^,0-9]")
483 (monthname " *" day ", *" year "[^0-9]") 516 (monthname " *" day ", *" year "[^0-9]")
484 (dayname "\\W")) 517 (dayname "\\W"))
485 "List of pseudo-patterns describing the American patterns of date used. 518 "List of pseudo-patterns describing the American style of dates.
486 See the documentation of `diary-date-forms' for an explanation." 519 The defaults are: MONTH/DAY; MONTH/DAY/YEAR; MONTHNAME DAY;
520 MONTHNAME DAY, YEAR; DAYNAME. Normally you should not customize this,
521 but `diary-date-forms' (which see)."
487 :type '(repeat (choice (cons :tag "Backup" 522 :type '(repeat (choice (cons :tag "Backup"
488 :value (backup . nil) 523 :value (backup . nil)
489 (const backup) 524 (const backup)
490 (repeat (list :inline t :format "%v" 525 (repeat (list :inline t :format "%v"
491 (symbol :tag "Keyword") 526 (symbol :tag "Keyword")
499 '((day "/" month "[^/0-9]") 534 '((day "/" month "[^/0-9]")
500 (day "/" month "/" year "[^0-9]") 535 (day "/" month "/" year "[^0-9]")
501 (backup day " *" monthname "\\W+\\<\\([^*0-9]\\|\\([0-9]+[:aApP]\\)\\)") 536 (backup day " *" monthname "\\W+\\<\\([^*0-9]\\|\\([0-9]+[:aApP]\\)\\)")
502 (day " *" monthname " *" year "[^0-9]") 537 (day " *" monthname " *" year "[^0-9]")
503 (dayname "\\W")) 538 (dayname "\\W"))
504 "List of pseudo-patterns describing the European patterns of date used. 539 "List of pseudo-patterns describing the European style of dates.
505 See the documentation of `diary-date-forms' for an explanation." 540 The defaults are: DAY/MONTH; DAY/MONTH/YEAR; DAY MONTHNAME;
541 DAY MONTHNAME YEAR; DAYNAME. Normally you should not customize this, but
542 `diary-date-forms' (which see)."
506 :type '(repeat (choice (cons :tag "Backup" 543 :type '(repeat (choice (cons :tag "Backup"
507 :value (backup . nil) 544 :value (backup . nil)
508 (const backup) 545 (const backup)
509 (repeat (list :inline t :format "%v" 546 (repeat (list :inline t :format "%v"
510 (symbol :tag "Keyword") 547 (symbol :tag "Keyword")
514 (choice symbol regexp))))) 551 (choice symbol regexp)))))
515 :group 'diary) 552 :group 'diary)
516 553
517 (defvar diary-font-lock-keywords) 554 (defvar diary-font-lock-keywords)
518 555
519 (defcustom diary-date-forms 556 (defcustom diary-date-forms (cond ((eq calendar-date-style 'iso)
520 (if european-calendar-style 557 iso-date-diary-pattern)
521 european-date-diary-pattern 558 ((eq calendar-date-style 'european)
522 american-date-diary-pattern) 559 european-date-diary-pattern)
560 (t american-date-diary-pattern))
523 "List of pseudo-patterns describing the forms of date used in the diary. 561 "List of pseudo-patterns describing the forms of date used in the diary.
524 The patterns on the list must be MUTUALLY EXCLUSIVE and should not match 562 The patterns on the list must be MUTUALLY EXCLUSIVE and should not match
525 any portion of the diary entry itself, just the date component. 563 any portion of the diary entry itself, just the date component.
526 564
527 A pseudo-pattern is a list of regular expressions and the keywords `month', 565 A pseudo-pattern is a list of regular expressions and the keywords `month',
541 579
542 If, to be mutually exclusive, a pseudo-pattern must match a portion of the 580 If, to be mutually exclusive, a pseudo-pattern must match a portion of the
543 diary entry itself, the first element of the pattern MUST be `backup'. This 581 diary entry itself, the first element of the pattern MUST be `backup'. This
544 directive causes the date recognizer to back up to the beginning of the 582 directive causes the date recognizer to back up to the beginning of the
545 current word of the diary entry, so in no case can the pattern match more than 583 current word of the diary entry, so in no case can the pattern match more than
546 a portion of the first word of the diary entry." 584 a portion of the first word of the diary entry.
585
586 For examples of three common styles, see `american-date-diary-pattern',
587 `european-date-diary-pattern', and `iso-date-diary-pattern'."
547 :type '(repeat (choice (cons :tag "Backup" 588 :type '(repeat (choice (cons :tag "Backup"
548 :value (backup . nil) 589 :value (backup . nil)
549 (const backup) 590 (const backup)
550 (repeat (list :inline t :format "%v" 591 (repeat (list :inline t :format "%v"
551 (symbol :tag "Keyword") 592 (symbol :tag "Keyword")
562 ;; to pick up any newly recognized entries. 603 ;; to pick up any newly recognized entries.
563 (and (diary-live-p) 604 (and (diary-live-p)
564 (diary)))) 605 (diary))))
565 :group 'diary) 606 :group 'diary)
566 607
608 ;; Next three are provided to aid in setting calendar-date-display-form.
609 (defcustom iso-calendar-display-form '((format "%s-%.2d-%.2d" year
610 (string-to-number month)
611 (string-to-number day)))
612 "Pseudo-pattern governing the way a date appears in the ISO style.
613 Normally you should not customize this, but `calendar-date-display-form'
614 \(which see)."
615 :type 'sexp
616 :version "23.1"
617 :group 'calendar)
618
567 (defcustom european-calendar-display-form 619 (defcustom european-calendar-display-form
568 '((if dayname (concat dayname ", ")) day " " monthname " " year) 620 '((if dayname (concat dayname ", ")) day " " monthname " " year)
569 "Pseudo-pattern governing the way a date appears in the European style. 621 "Pseudo-pattern governing the way a date appears in the European style.
570 See the documentation of `calendar-date-display-form' for an explanation." 622 Normally you should not customize this, but `calendar-date-display-form'
623 \(which see)."
571 :type 'sexp 624 :type 'sexp
572 :group 'calendar) 625 :group 'calendar)
573 626
574 (defcustom american-calendar-display-form 627 (defcustom american-calendar-display-form
575 '((if dayname (concat dayname ", ")) monthname " " day ", " year) 628 '((if dayname (concat dayname ", ")) monthname " " day ", " year)
576 "Pseudo-pattern governing the way a date appears in the American style. 629 "Pseudo-pattern governing the way a date appears in the American style.
577 See the documentation of `calendar-date-display-form' for an explanation." 630 Normally you should not customize this, but `calendar-date-display-form'
631 \(which see)."
578 :type 'sexp 632 :type 'sexp
579 :group 'calendar) 633 :group 'calendar)
580 634
581 (defcustom calendar-date-display-form 635 (defcustom calendar-date-display-form (cond ((eq calendar-date-style 'iso)
582 (if european-calendar-style 636 iso-calendar-display-form)
583 european-calendar-display-form 637 ((eq calendar-date-style 'european)
584 american-calendar-display-form) 638 european-calendar-display-form)
585 "Pseudo-pattern governing the way a date appears. 639 (t american-calendar-display-form))
586 640 "Pseudo-pattern governing the way a calendar date appears.
587 Used by the function `calendar-date-string', a pseudo-pattern is a list of 641 Used by the function `calendar-date-string' (which see), a pseudo-pattern
588 expressions that can involve the keywords `month', `day', and `year', all 642 is a list of expressions that can involve the keywords `month', `day',
589 numbers in string form, and `monthname' and `dayname', both alphabetic 643 and `year' (all numbers in string form), and `monthname' and `dayname'
590 strings. For example, the ISO standard would use the pseudo- pattern 644 \(both alphabetic strings). For example, a typical American form would be
591
592 '(year \"-\" month \"-\" day)
593
594 while a typical American form would be
595 645
596 '(month \"/\" day \"/\" (substring year -2)) 646 '(month \"/\" day \"/\" (substring year -2))
597 647
598 and 648 whereas
599 649
600 '((format \"%9s, %9s %2s, %4s\" dayname monthname day year)) 650 '((format \"%9s, %9s %2s, %4s\" dayname monthname day year))
601 651
602 would give the usual American style in fixed-length fields. 652 would give the usual American style in fixed-length fields. The variables
603 653 `iso-calendar-display-form', `european-calendar-display-form', and
604 See the documentation of the function `calendar-date-string'." 654 `american-calendar-display-form' provide some defaults for three common
655 styles."
605 :type 'sexp 656 :type 'sexp
606 :group 'calendar) 657 :group 'calendar)
658
659 (defun calendar-set-date-style (style)
660 "Set the style of calendar and diary dates to STYLE (a symbol).
661 The valid styles are described in the documentation of `calendar-date-style'."
662 (interactive (list (intern
663 (completing-read "Date style: "
664 '("american" "european" "iso") nil t
665 nil nil "american"))))
666 (or (memq style '(american european iso))
667 (setq style 'american))
668 (setq calendar-date-style style
669 calendar-date-display-form
670 (symbol-value (intern-soft (format "%s-calendar-display-form" style)))
671 diary-date-forms
672 (symbol-value (intern-soft (format "%s-date-diary-pattern" style))))
673 (update-calendar-mode-line))
607 674
608 (defun european-calendar () 675 (defun european-calendar ()
609 "Set the interpretation and display of dates to the European style." 676 "Set the interpretation and display of dates to the European style."
610 (interactive) 677 (interactive)
611 (setq european-calendar-style t 678 (calendar-set-date-style 'european))
612 calendar-date-display-form european-calendar-display-form 679
613 diary-date-forms european-date-diary-pattern) 680 (make-obsolete 'european-calendar 'calendar-set-date-style "23.1")
614 (update-calendar-mode-line))
615 681
616 (defun american-calendar () 682 (defun american-calendar ()
617 "Set the interpretation and display of dates to the American style." 683 "Set the interpretation and display of dates to the American style."
618 (interactive) 684 (interactive)
619 (setq european-calendar-style nil 685 (calendar-set-date-style 'american))
620 calendar-date-display-form american-calendar-display-form 686
621 diary-date-forms american-date-diary-pattern) 687 (make-obsolete 'american-calendar 'calendar-set-date-style "23.1")
622 (update-calendar-mode-line))
623 688
624 ;; FIXME move to diary-lib and adjust appt. 689 ;; FIXME move to diary-lib and adjust appt.
625 ;; Add appt-make-list as an option? 690 ;; Add appt-make-list as an option?
626 (defcustom diary-hook nil 691 (defcustom diary-hook nil
627 "List of functions called after the display of the diary. 692 "List of functions called after the display of the diary.
629 :type 'hook 694 :type 'hook
630 :group 'diary) 695 :group 'diary)
631 696
632 (defcustom diary-display-hook nil 697 (defcustom diary-display-hook nil
633 "List of functions that handle the display of the diary. 698 "List of functions that handle the display of the diary.
634 If nil (the default), `simple-diary-display' is used. Use `ignore' for no 699 If nil (the default), `simple-diary-display' is used. Use
635 diary display. 700 `ignore' for no diary display.
636 701
637 Ordinarily, this just displays the diary buffer (with holidays indicated in 702 Ordinarily, this just displays the diary buffer (with holidays
638 the mode line), if there are any relevant entries. At the time these 703 indicated in the mode line), if there are any relevant entries.
639 functions are called, the variable `diary-entries-list' is a list, in order 704 At the time these functions are called, the variable
640 by date, of all relevant diary entries in the form of ((MONTH DAY YEAR) 705 `diary-entries-list' is a list, in order by date, of all relevant
641 STRING), where string is the diary entry for the given date. This can be 706 diary entries in the form of ((MONTH DAY YEAR) STRING), where
642 used, for example, a different buffer for display (perhaps combined with 707 string is the diary entry for the given date. This can be used,
643 holidays), or produce hard copy output. 708 for example, a different buffer for display (perhaps combined
644 709 with holidays), or produce hard copy output.
645 A function `fancy-diary-display' is provided as an alternative 710
646 choice for this hook; this function prepares a special noneditable diary 711 A function `fancy-diary-display' is provided for use with this
647 buffer with the relevant diary entries that has neat day-by-day arrangement 712 hook; this function prepares a special noneditable diary buffer
648 with headings. The fancy diary buffer will show the holidays unless the 713 with the relevant diary entries that has neat day-by-day
649 variable `holidays-in-diary-buffer' is set to nil. Ordinarily, the fancy 714 arrangement with headings. The fancy diary buffer will show the
650 diary buffer will not show days for which there are no diary entries, even 715 holidays unless the variable `holidays-in-diary-buffer' is set to
651 if that day is a holiday; if you want such days to be shown in the fancy 716 nil. Ordinarily, the fancy diary buffer will not show days for
652 diary buffer, set the variable `diary-list-include-blanks' to t." 717 which there are no diary entries, even if that day is a holiday;
718 if you want such days to be shown in the fancy diary buffer, set
719 the variable `diary-list-include-blanks' non-nil."
653 :type 'hook 720 :type 'hook
654 :options '(fancy-diary-display) 721 :options '(fancy-diary-display)
655 :initialize 'custom-initialize-default 722 :initialize 'custom-initialize-default
656 :set 'diary-set-maybe-redraw 723 :set 'diary-set-maybe-redraw
657 :group 'diary) 724 :group 'diary)
666 733
667 (defcustom calendar-debug-sexp nil 734 (defcustom calendar-debug-sexp nil
668 "Turn debugging on when evaluating a sexp in the diary or holiday list." 735 "Turn debugging on when evaluating a sexp in the diary or holiday list."
669 :type 'boolean 736 :type 'boolean
670 :group 'calendar) 737 :group 'calendar)
738
739 ;; The various holiday variables are autoloaded because people
740 ;; are used to using them to set calendar-holidays without having to
741 ;; explicitly load this file.
671 742
672 ;;;###autoload 743 ;;;###autoload
673 (defcustom general-holidays 744 (defcustom general-holidays
674 '((holiday-fixed 1 1 "New Year's Day") 745 '((holiday-fixed 1 1 "New Year's Day")
675 (holiday-float 1 1 3 "Martin Luther King Day") 746 (holiday-float 1 1 3 "Martin Luther King Day")