aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2008-03-29 02:44:03 +0000
committerGlenn Morris2008-03-29 02:44:03 +0000
commit8266a036d7ce5f73f448387b704b4a773d8f3da3 (patch)
treefddc4062226325f31dca33223fca6250622a1ca7
parent41099a1bea7b86265499c8a96fe6bceaac4e72e4 (diff)
downloademacs-8266a036d7ce5f73f448387b704b4a773d8f3da3.tar.gz
emacs-8266a036d7ce5f73f448387b704b4a773d8f3da3.zip
(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.
-rw-r--r--lisp/calendar/calendar.el247
1 files changed, 159 insertions, 88 deletions
diff --git a/lisp/calendar/calendar.el b/lisp/calendar/calendar.el
index eb4b204505c..743dc33648f 100644
--- a/lisp/calendar/calendar.el
+++ b/lisp/calendar/calendar.el
@@ -352,19 +352,11 @@ matches any day, month, or year, respectively. If the date does
352not contain a year, it is generic and applies to any year. A 352not contain a year, it is generic and applies to any year. A
353DAYNAME entry applies to the appropriate day of the week in every week. 353DAYNAME entry applies to the appropriate day of the week in every week.
354 354
355The European style (in which the day precedes the month) can be 355You can customize `diary-date-forms' to your preferred format.
356used instead, if you execute `european-calendar' when in the 356Three default styles are provided: `american-date-diary-pattern',
357calendar, or set `european-calendar-style' to t in your .emacs 357`european-date-diary-pattern', and `iso-date-diary-pattern'.
358file. The European forms (see `european-date-diary-pattern') are 358You 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
366To revert to the default American style from the European style, execute
367`american-calendar' in the calendar.
368 360
369A diary entry can be preceded by the character `diary-nonmarking-symbol' 361A 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
@@ -447,43 +439,86 @@ details, see the documentation for the variable `list-diary-entries-hook'."
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.
451If this variable is non-nil, a date 1/2/1990 would be interpreted as 443In this case, a date like 1/2/1990 would be interpreted as
452February 1, 1990. The default European date styles (see 444February 1, 1990. See `european-date-diary-pattern' for the
453`european-date-diary-pattern') are 445default European diary date styles.
454
455 DAY/MONTH
456 DAY/MONTH/YEAR
457 DAY MONTHNAME
458 DAY MONTHNAME YEAR
459 DAYNAME
460
461Names can be capitalized or not, written in full (as specified by the
462variable `calendar-day-name-array'), or abbreviated (as specified by
463`calendar-day-abbrev-array') with or without a period.
464 446
465Setting this variable directly does not take effect (if the 447Setting this variable directly does not take effect (if the
466calendar package is already loaded). Rather, use either 448calendar 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)
478 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.
468The options are:
469`american' - month/day/year
470`european' - day/month/year
471`iso' - year/month/day
472This affects how dates written in your diary are interpreted.
473It also affects date display, as well as those calendar and diary
474functions that take a date as an argument, e.g. `diary-date', by
475changing the order in which the arguments are interpreted.
476
477Setting this variable directly does not take effect (if the
478calendar 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.
497The defaults are: MONTH[-/]DAY; YEAR[-/]MONTH[-/]DAY; MONTHNAME-DAY;
498YEAR-MONTHNAME-DAY; DAYNAME. Normally you should not customize this,
499but `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)
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.
486See the documentation of `diary-date-forms' for an explanation." 519The defaults are: MONTH/DAY; MONTH/DAY/YEAR; MONTHNAME DAY;
520MONTHNAME DAY, YEAR; DAYNAME. Normally you should not customize this,
521but `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)
@@ -501,8 +536,10 @@ See the documentation of `diary-date-forms' for an explanation."
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.
505See the documentation of `diary-date-forms' for an explanation." 540The defaults are: DAY/MONTH; DAY/MONTH/YEAR; DAY MONTHNAME;
541DAY 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)
@@ -516,10 +553,11 @@ See the documentation of `diary-date-forms' for an explanation."
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.
524The patterns on the list must be MUTUALLY EXCLUSIVE and should not match 562The patterns on the list must be MUTUALLY EXCLUSIVE and should not match
525any portion of the diary entry itself, just the date component. 563any portion of the diary entry itself, just the date component.
@@ -543,7 +581,10 @@ If, to be mutually exclusive, a pseudo-pattern must match a portion of the
543diary entry itself, the first element of the pattern MUST be `backup'. This 581diary entry itself, the first element of the pattern MUST be `backup'. This
544directive causes the date recognizer to back up to the beginning of the 582directive causes the date recognizer to back up to the beginning of the
545current word of the diary entry, so in no case can the pattern match more than 583current word of the diary entry, so in no case can the pattern match more than
546a portion of the first word of the diary entry." 584a portion of the first word of the diary entry.
585
586For 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)
@@ -564,62 +605,86 @@ a portion of the first word of the diary entry."
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.
613Normally 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.
570See the documentation of `calendar-date-display-form' for an explanation." 622Normally 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.
577See the documentation of `calendar-date-display-form' for an explanation." 630Normally 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.
587Used by the function `calendar-date-string', a pseudo-pattern is a list of 641Used by the function `calendar-date-string' (which see), a pseudo-pattern
588expressions that can involve the keywords `month', `day', and `year', all 642is a list of expressions that can involve the keywords `month', `day',
589numbers in string form, and `monthname' and `dayname', both alphabetic 643and `year' (all numbers in string form), and `monthname' and `dayname'
590strings. 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
594while a typical American form would be
595 645
596 '(month \"/\" day \"/\" (substring year -2)) 646 '(month \"/\" day \"/\" (substring year -2))
597 647
598and 648whereas
599 649
600 '((format \"%9s, %9s %2s, %4s\" dayname monthname day year)) 650 '((format \"%9s, %9s %2s, %4s\" dayname monthname day year))
601 651
602would give the usual American style in fixed-length fields. 652would give the usual American style in fixed-length fields. The variables
603 653`iso-calendar-display-form', `european-calendar-display-form', and
604See the documentation of the function `calendar-date-string'." 654`american-calendar-display-form' provide some defaults for three common
655styles."
605 :type 'sexp 656 :type 'sexp
606 :group 'calendar) 657 :group 'calendar)
607 658
659(defun calendar-set-date-style (style)
660 "Set the style of calendar and diary dates to STYLE (a symbol).
661The 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))
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?
@@ -631,25 +696,27 @@ Can be used for appointment notification."
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.
634If nil (the default), `simple-diary-display' is used. Use `ignore' for no 699If nil (the default), `simple-diary-display' is used. Use
635diary display. 700`ignore' for no diary display.
636 701
637Ordinarily, this just displays the diary buffer (with holidays indicated in 702Ordinarily, this just displays the diary buffer (with holidays
638the mode line), if there are any relevant entries. At the time these 703indicated in the mode line), if there are any relevant entries.
639functions are called, the variable `diary-entries-list' is a list, in order 704At the time these functions are called, the variable
640by 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
641STRING), where string is the diary entry for the given date. This can be 706diary entries in the form of ((MONTH DAY YEAR) STRING), where
642used, for example, a different buffer for display (perhaps combined with 707string is the diary entry for the given date. This can be used,
643holidays), or produce hard copy output. 708for example, a different buffer for display (perhaps combined
644 709with holidays), or produce hard copy output.
645A function `fancy-diary-display' is provided as an alternative 710
646choice for this hook; this function prepares a special noneditable diary 711A function `fancy-diary-display' is provided for use with this
647buffer with the relevant diary entries that has neat day-by-day arrangement 712hook; this function prepares a special noneditable diary buffer
648with headings. The fancy diary buffer will show the holidays unless the 713with the relevant diary entries that has neat day-by-day
649variable `holidays-in-diary-buffer' is set to nil. Ordinarily, the fancy 714arrangement with headings. The fancy diary buffer will show the
650diary buffer will not show days for which there are no diary entries, even 715holidays unless the variable `holidays-in-diary-buffer' is set to
651if that day is a holiday; if you want such days to be shown in the fancy 716nil. Ordinarily, the fancy diary buffer will not show days for
652diary buffer, set the variable `diary-list-include-blanks' to t." 717which there are no diary entries, even if that day is a holiday;
718if you want such days to be shown in the fancy diary buffer, set
719the 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
@@ -669,6 +736,10 @@ somewhat; setting it to nil makes the diary display faster."
669 :type 'boolean 736 :type 'boolean
670 :group 'calendar) 737 :group 'calendar)
671 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.
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")