Mercurial > emacs
comparison lisp/calendar/calendar.el @ 92858:7096add7a945
Whitespace only.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Thu, 13 Mar 2008 06:27:14 +0000 |
parents | f5f51a11e3da |
children | 379d912c3710 |
comparison
equal
deleted
inserted
replaced
92857:ab9ec247b4ff | 92858:7096add7a945 |
---|---|
492 (monthname " *" day ", *" year "[^0-9]") | 492 (monthname " *" day ", *" year "[^0-9]") |
493 (dayname "\\W")) | 493 (dayname "\\W")) |
494 "List of pseudo-patterns describing the American patterns of date used. | 494 "List of pseudo-patterns describing the American patterns of date used. |
495 See the documentation of `diary-date-forms' for an explanation." | 495 See the documentation of `diary-date-forms' for an explanation." |
496 :type '(repeat (choice (cons :tag "Backup" | 496 :type '(repeat (choice (cons :tag "Backup" |
497 :value (backup . nil) | 497 :value (backup . nil) |
498 (const backup) | 498 (const backup) |
499 (repeat (list :inline t :format "%v" | 499 (repeat (list :inline t :format "%v" |
500 (symbol :tag "Keyword") | 500 (symbol :tag "Keyword") |
501 (choice symbol regexp)))) | 501 (choice symbol regexp)))) |
502 (repeat (list :inline t :format "%v" | 502 (repeat (list :inline t :format "%v" |
503 (symbol :tag "Keyword") | 503 (symbol :tag "Keyword") |
504 (choice symbol regexp))))) | 504 (choice symbol regexp))))) |
505 :group 'diary) | 505 :group 'diary) |
506 | 506 |
507 (defcustom european-date-diary-pattern | 507 (defcustom european-date-diary-pattern |
508 '((day "/" month "[^/0-9]") | 508 '((day "/" month "[^/0-9]") |
509 (day "/" month "/" year "[^0-9]") | 509 (day "/" month "/" year "[^0-9]") |
511 (day " *" monthname " *" year "[^0-9]") | 511 (day " *" monthname " *" year "[^0-9]") |
512 (dayname "\\W")) | 512 (dayname "\\W")) |
513 "List of pseudo-patterns describing the European patterns of date used. | 513 "List of pseudo-patterns describing the European patterns of date used. |
514 See the documentation of `diary-date-forms' for an explanation." | 514 See the documentation of `diary-date-forms' for an explanation." |
515 :type '(repeat (choice (cons :tag "Backup" | 515 :type '(repeat (choice (cons :tag "Backup" |
516 :value (backup . nil) | 516 :value (backup . nil) |
517 (const backup) | 517 (const backup) |
518 (repeat (list :inline t :format "%v" | 518 (repeat (list :inline t :format "%v" |
519 (symbol :tag "Keyword") | 519 (symbol :tag "Keyword") |
520 (choice symbol regexp)))) | 520 (choice symbol regexp)))) |
521 (repeat (list :inline t :format "%v" | 521 (repeat (list :inline t :format "%v" |
522 (symbol :tag "Keyword") | 522 (symbol :tag "Keyword") |
523 (choice symbol regexp))))) | 523 (choice symbol regexp))))) |
524 :group 'diary) | 524 :group 'diary) |
525 | 525 |
526 (defvar diary-font-lock-keywords) | 526 (defvar diary-font-lock-keywords) |
527 | 527 |
528 (defcustom diary-date-forms | 528 (defcustom diary-date-forms |
552 diary entry itself, the first element of the pattern MUST be `backup'. This | 552 diary entry itself, the first element of the pattern MUST be `backup'. This |
553 directive causes the date recognizer to back up to the beginning of the | 553 directive causes the date recognizer to back up to the beginning of the |
554 current word of the diary entry, so in no case can the pattern match more than | 554 current word of the diary entry, so in no case can the pattern match more than |
555 a portion of the first word of the diary entry." | 555 a portion of the first word of the diary entry." |
556 :type '(repeat (choice (cons :tag "Backup" | 556 :type '(repeat (choice (cons :tag "Backup" |
557 :value (backup . nil) | 557 :value (backup . nil) |
558 (const backup) | 558 (const backup) |
559 (repeat (list :inline t :format "%v" | 559 (repeat (list :inline t :format "%v" |
560 (symbol :tag "Keyword") | 560 (symbol :tag "Keyword") |
561 (choice symbol regexp)))) | 561 (choice symbol regexp)))) |
562 (repeat (list :inline t :format "%v" | 562 (repeat (list :inline t :format "%v" |
563 (symbol :tag "Keyword") | 563 (symbol :tag "Keyword") |
564 (choice symbol regexp))))) | 564 (choice symbol regexp))))) |
565 :initialize 'custom-initialize-default | 565 :initialize 'custom-initialize-default |
566 :set (lambda (symbol value) | 566 :set (lambda (symbol value) |
567 (unless (equal value (eval symbol)) | 567 (unless (equal value (eval symbol)) |
568 (custom-set-default symbol value) | 568 (custom-set-default symbol value) |
569 (setq diary-font-lock-keywords (diary-font-lock-keywords)) | 569 (setq diary-font-lock-keywords (diary-font-lock-keywords)) |
704 (put 'general-holidays 'risky-local-variable t) | 704 (put 'general-holidays 'risky-local-variable t) |
705 | 705 |
706 ;;;###autoload | 706 ;;;###autoload |
707 (defcustom oriental-holidays | 707 (defcustom oriental-holidays |
708 '((if (fboundp 'atan) | 708 '((if (fboundp 'atan) |
709 (holiday-chinese-new-year))) | 709 (holiday-chinese-new-year))) |
710 "Oriental holidays. | 710 "Oriental holidays. |
711 See the documentation for `calendar-holidays' for details." | 711 See the documentation for `calendar-holidays' for details." |
712 :type 'sexp | 712 :type 'sexp |
713 :group 'holidays) | 713 :group 'holidays) |
714 ;;;###autoload | 714 ;;;###autoload |
963 '((holiday-fixed | 963 '((holiday-fixed |
964 3 21 | 964 3 21 |
965 (format "Baha'i New Year (Naw-Ruz) %d" (- displayed-year (1- 1844)))) | 965 (format "Baha'i New Year (Naw-Ruz) %d" (- displayed-year (1- 1844)))) |
966 (holiday-fixed 4 21 "First Day of Ridvan") | 966 (holiday-fixed 4 21 "First Day of Ridvan") |
967 (if all-bahai-calendar-holidays | 967 (if all-bahai-calendar-holidays |
968 (holiday-fixed 4 22 "Second Day of Ridvan")) | 968 (holiday-fixed 4 22 "Second Day of Ridvan")) |
969 (if all-bahai-calendar-holidays | 969 (if all-bahai-calendar-holidays |
970 (holiday-fixed 4 23 "Third Day of Ridvan")) | 970 (holiday-fixed 4 23 "Third Day of Ridvan")) |
971 (if all-bahai-calendar-holidays | 971 (if all-bahai-calendar-holidays |
972 (holiday-fixed 4 24 "Fourth Day of Ridvan")) | 972 (holiday-fixed 4 24 "Fourth Day of Ridvan")) |
973 (if all-bahai-calendar-holidays | 973 (if all-bahai-calendar-holidays |
974 (holiday-fixed 4 25 "Fifth Day of Ridvan")) | 974 (holiday-fixed 4 25 "Fifth Day of Ridvan")) |
975 (if all-bahai-calendar-holidays | 975 (if all-bahai-calendar-holidays |
976 (holiday-fixed 4 26 "Sixth Day of Ridvan")) | 976 (holiday-fixed 4 26 "Sixth Day of Ridvan")) |
977 (if all-bahai-calendar-holidays | 977 (if all-bahai-calendar-holidays |
978 (holiday-fixed 4 27 "Seventh Day of Ridvan")) | 978 (holiday-fixed 4 27 "Seventh Day of Ridvan")) |
979 (if all-bahai-calendar-holidays | 979 (if all-bahai-calendar-holidays |
980 (holiday-fixed 4 28 "Eighth Day of Ridvan")) | 980 (holiday-fixed 4 28 "Eighth Day of Ridvan")) |
981 (holiday-fixed 4 29 "Ninth Day of Ridvan") | 981 (holiday-fixed 4 29 "Ninth Day of Ridvan") |
982 (if all-bahai-calendar-holidays | 982 (if all-bahai-calendar-holidays |
983 (holiday-fixed 4 30 "Tenth Day of Ridvan")) | 983 (holiday-fixed 4 30 "Tenth Day of Ridvan")) |
984 (if all-bahai-calendar-holidays | 984 (if all-bahai-calendar-holidays |
985 (holiday-fixed 5 1 "Eleventh Day of Ridvan")) | 985 (holiday-fixed 5 1 "Eleventh Day of Ridvan")) |
986 (holiday-fixed 5 2 "Twelfth Day of Ridvan") | 986 (holiday-fixed 5 2 "Twelfth Day of Ridvan") |
987 (holiday-fixed 5 23 "Declaration of the Bab") | 987 (holiday-fixed 5 23 "Declaration of the Bab") |
988 (holiday-fixed 5 29 "Ascension of Baha'u'llah") | 988 (holiday-fixed 5 29 "Ascension of Baha'u'llah") |
989 (holiday-fixed 7 9 "Martyrdom of the Bab") | 989 (holiday-fixed 7 9 "Martyrdom of the Bab") |
990 (holiday-fixed 10 20 "Birth of the Bab") | 990 (holiday-fixed 10 20 "Birth of the Bab") |
991 (holiday-fixed 11 12 "Birth of Baha'u'llah") | 991 (holiday-fixed 11 12 "Birth of Baha'u'llah") |
992 (if all-bahai-calendar-holidays | 992 (if all-bahai-calendar-holidays |
993 (holiday-fixed 11 26 "Day of the Covenant")) | 993 (holiday-fixed 11 26 "Day of the Covenant")) |
994 (if all-bahai-calendar-holidays | 994 (if all-bahai-calendar-holidays |
995 (holiday-fixed 11 28 "Ascension of `Abdu'l-Baha"))) | 995 (holiday-fixed 11 28 "Ascension of `Abdu'l-Baha"))) |
996 "Baha'i holidays. | 996 "Baha'i holidays. |
997 See the documentation for `calendar-holidays' for details." | 997 See the documentation for `calendar-holidays' for details." |
998 :type 'sexp | 998 :type 'sexp |
999 :group 'holidays) | 999 :group 'holidays) |
1000 ;;;###autoload | 1000 ;;;###autoload |
1001 (put 'bahai-holidays 'risky-local-variable t) | 1001 (put 'bahai-holidays 'risky-local-variable t) |
1002 | 1002 |
1003 ;;;###autoload | 1003 ;;;###autoload |
1004 (defcustom solar-holidays | 1004 (defcustom solar-holidays |
1005 '((if (fboundp 'atan) | 1005 '((if (fboundp 'atan) |
1006 (solar-equinoxes-solstices)) | 1006 (solar-equinoxes-solstices)) |
1007 (if (require 'cal-dst) | 1007 (if (require 'cal-dst) |
1008 (funcall | 1008 (funcall |
1009 'holiday-sexp | 1009 'holiday-sexp |
1010 calendar-daylight-savings-starts | 1010 calendar-daylight-savings-starts |
1011 '(format "Daylight Saving Time Begins %s" | 1011 '(format "Daylight Saving Time Begins %s" |
1429 (set-window-vscroll nil 0) | 1429 (set-window-vscroll nil 0) |
1430 ;; Adjust the window to exactly fit the displayed calendar. | 1430 ;; Adjust the window to exactly fit the displayed calendar. |
1431 (fit-window-to-buffer nil nil calendar-minimum-window-height)) | 1431 (fit-window-to-buffer nil nil calendar-minimum-window-height)) |
1432 (sit-for 0)) | 1432 (sit-for 0)) |
1433 (if (and (boundp 'font-lock-mode) | 1433 (if (and (boundp 'font-lock-mode) |
1434 font-lock-mode) | 1434 font-lock-mode) |
1435 (font-lock-fontify-buffer)) | 1435 (font-lock-fontify-buffer)) |
1436 (and mark-holidays-in-calendar | 1436 (and mark-holidays-in-calendar |
1437 ;;; (calendar-date-is-valid-p today) ; useful for BC dates | 1437 ;;; (calendar-date-is-valid-p today) ; useful for BC dates |
1438 (calendar-mark-holidays) | 1438 (calendar-mark-holidays) |
1439 (and in-calendar-window (sit-for 0))) | 1439 (and in-calendar-window (sit-for 0))) |
1440 (unwind-protect | 1440 (unwind-protect |
1468 (let* ((blank-days ; at start of month | 1468 (let* ((blank-days ; at start of month |
1469 (mod | 1469 (mod |
1470 (- (calendar-day-of-week (list month 1 year)) | 1470 (- (calendar-day-of-week (list month 1 year)) |
1471 calendar-week-start-day) | 1471 calendar-week-start-day) |
1472 7)) | 1472 7)) |
1473 (last (calendar-last-day-of-month month year))) | 1473 (last (calendar-last-day-of-month month year))) |
1474 (goto-char (point-min)) | 1474 (goto-char (point-min)) |
1475 (calendar-insert-indented | 1475 (calendar-insert-indented |
1476 (calendar-string-spread | 1476 (calendar-string-spread |
1477 (list (format "%s %d" (calendar-month-name month) year)) ? 20) | 1477 (list (format "%s %d" (calendar-month-name month) year)) ? 20) |
1478 indent t) | 1478 indent t) |
1494 (calendar-for-loop i from 1 to last do | 1494 (calendar-for-loop i from 1 to last do |
1495 (insert (format "%2d " i)) | 1495 (insert (format "%2d " i)) |
1496 (add-text-properties | 1496 (add-text-properties |
1497 (- (point) 3) (1- (point)) | 1497 (- (point) 3) (1- (point)) |
1498 '(mouse-face highlight | 1498 '(mouse-face highlight |
1499 help-echo "mouse-2: menu of operations for this date")) | 1499 help-echo "mouse-2: menu of operations for this date")) |
1500 (and (zerop (mod (+ i blank-days) 7)) | 1500 (and (zerop (mod (+ i blank-days) 7)) |
1501 (/= i last) | 1501 (/= i last) |
1502 (calendar-insert-indented "" 0 t) ; force onto following line | 1502 (calendar-insert-indented "" 0 t) ; force onto following line |
1503 (calendar-insert-indented "" indent))))) ; go to proper spot | 1503 (calendar-insert-indented "" indent))))) ; go to proper spot |
1504 | 1504 |
1694 | 1694 |
1695 ;; After calendar-mode-map. | 1695 ;; After calendar-mode-map. |
1696 (defcustom calendar-mode-line-format | 1696 (defcustom calendar-mode-line-format |
1697 (list | 1697 (list |
1698 (propertize "<" | 1698 (propertize "<" |
1699 'help-echo "mouse-1: previous month" | 1699 'help-echo "mouse-1: previous month" |
1700 'mouse-face 'mode-line-highlight | 1700 'mouse-face 'mode-line-highlight |
1701 'keymap (make-mode-line-mouse-map 'mouse-1 | 1701 'keymap (make-mode-line-mouse-map 'mouse-1 |
1702 'calendar-scroll-right)) | 1702 'calendar-scroll-right)) |
1703 "Calendar" | 1703 "Calendar" |
1704 (concat | 1704 (concat |
1705 (propertize | 1705 (propertize |
1706 (substitute-command-keys | 1706 (substitute-command-keys |
1707 "\\<calendar-mode-map>\\[calendar-goto-info-node] info") | 1707 "\\<calendar-mode-map>\\[calendar-goto-info-node] info") |
1713 (substitute-command-keys | 1713 (substitute-command-keys |
1714 " \\<calendar-mode-map>\\[calendar-other-month] other") | 1714 " \\<calendar-mode-map>\\[calendar-other-month] other") |
1715 'help-echo "mouse-1: choose another month" | 1715 'help-echo "mouse-1: choose another month" |
1716 'mouse-face 'mode-line-highlight | 1716 'mouse-face 'mode-line-highlight |
1717 'keymap (make-mode-line-mouse-map | 1717 'keymap (make-mode-line-mouse-map |
1718 'mouse-1 'mouse-calendar-other-month)) | 1718 'mouse-1 'mouse-calendar-other-month)) |
1719 " / " | 1719 " / " |
1720 (propertize | 1720 (propertize |
1721 (substitute-command-keys | 1721 (substitute-command-keys |
1722 "\\<calendar-mode-map>\\[calendar-goto-today] today") | 1722 "\\<calendar-mode-map>\\[calendar-goto-today] today") |
1723 'help-echo "mouse-1: go to today's date" | 1723 'help-echo "mouse-1: go to today's date" |
1724 'mouse-face 'mode-line-highlight | 1724 'mouse-face 'mode-line-highlight |
1725 'keymap (make-mode-line-mouse-map 'mouse-1 #'calendar-goto-today))) | 1725 'keymap (make-mode-line-mouse-map 'mouse-1 #'calendar-goto-today))) |
1726 '(calendar-date-string (calendar-current-date) t) | 1726 '(calendar-date-string (calendar-current-date) t) |
1727 (propertize ">" | 1727 (propertize ">" |
1728 'help-echo "mouse-1: next month" | 1728 'help-echo "mouse-1: next month" |
1729 'mouse-face 'mode-line-highlight | 1729 'mouse-face 'mode-line-highlight |
1730 'keymap (make-mode-line-mouse-map | 1730 'keymap (make-mode-line-mouse-map |
1731 'mouse-1 'calendar-scroll-left))) | 1731 'mouse-1 'calendar-scroll-left))) |
1732 "The mode line of the calendar buffer. | 1732 "The mode line of the calendar buffer. |
1733 | 1733 |
1734 This must be a list of items that evaluate to strings--those strings are | 1734 This must be a list of items that evaluate to strings--those strings are |
1735 evaluated and concatenated together, evenly separated by blanks. The variable | 1735 evaluated and concatenated together, evenly separated by blanks. The variable |
1736 `date' is available for use as the date under (or near) the cursor; `date' | 1736 `date' is available for use as the date under (or near) the cursor; `date' |
1843 (defun calendar-window-list () | 1843 (defun calendar-window-list () |
1844 "List of all calendar-related windows." | 1844 "List of all calendar-related windows." |
1845 (let ((calendar-buffers (calendar-buffer-list)) | 1845 (let ((calendar-buffers (calendar-buffer-list)) |
1846 list) | 1846 list) |
1847 (walk-windows (lambda (w) | 1847 (walk-windows (lambda (w) |
1848 (if (memq (window-buffer w) calendar-buffers) | 1848 (if (memq (window-buffer w) calendar-buffers) |
1849 (push w list))) | 1849 (push w list))) |
1850 nil t) | 1850 nil t) |
1851 list)) | 1851 list)) |
1852 | 1852 |
1853 (defun calendar-buffer-list () | 1853 (defun calendar-buffer-list () |
1854 "List of all calendar-related buffers." | 1854 "List of all calendar-related buffers." |
2120 (if (eq noday t) | 2120 (if (eq noday t) |
2121 (list month nil year) | 2121 (list month nil year) |
2122 (list month year)) | 2122 (list month year)) |
2123 (list month | 2123 (list month |
2124 (calendar-read (format "Day (1-%d): " last) | 2124 (calendar-read (format "Day (1-%d): " last) |
2125 (lambda (x) (and (< 0 x) (<= x last)))) | 2125 (lambda (x) (and (< 0 x) (<= x last)))) |
2126 year)))) | 2126 year)))) |
2127 | 2127 |
2128 (defun calendar-interval (mon1 yr1 mon2 yr2) | 2128 (defun calendar-interval (mon1 yr1 mon2 yr2) |
2129 "The number of months difference between MON1, YR1 and MON2, YR2. | 2129 "The number of months difference between MON1, YR1 and MON2, YR2. |
2130 The result is positive if the second date is later than the first. | 2130 The result is positive if the second date is later than the first. |
2151 array (append array (list elem)))) | 2151 array (append array (list elem)))) |
2152 (vconcat array))) | 2152 (vconcat array))) |
2153 | 2153 |
2154 (defvar calendar-font-lock-keywords | 2154 (defvar calendar-font-lock-keywords |
2155 `((,(concat (regexp-opt (mapcar 'identity calendar-month-name-array) t) | 2155 `((,(concat (regexp-opt (mapcar 'identity calendar-month-name-array) t) |
2156 " -?[0-9]+") | 2156 " -?[0-9]+") |
2157 . font-lock-function-name-face) ; month and year | 2157 . font-lock-function-name-face) ; month and year |
2158 (,(regexp-opt | 2158 (,(regexp-opt |
2159 (list (substring (aref calendar-day-name-array 6) 0 2) | 2159 (list (substring (aref calendar-day-name-array 6) 0 2) |
2160 (substring (aref calendar-day-name-array 0) 0 2))) | 2160 (substring (aref calendar-day-name-array 0) 0 2))) |
2161 ;; Saturdays and Sundays are highlighted differently. | 2161 ;; Saturdays and Sundays are highlighted differently. |
2162 . font-lock-comment-face) | 2162 . font-lock-comment-face) |
2163 ;; First two chars of each day are used in the calendar. | 2163 ;; First two chars of each day are used in the calendar. |
2164 (,(regexp-opt (mapcar (lambda (x) (substring x 0 2)) | 2164 (,(regexp-opt (mapcar (lambda (x) (substring x 0 2)) |
2165 calendar-day-name-array)) | 2165 calendar-day-name-array)) |
2381 If N>0, return the Nth DAYNAME after MONTH DAY, YEAR (inclusive). | 2381 If N>0, return the Nth DAYNAME after MONTH DAY, YEAR (inclusive). |
2382 | 2382 |
2383 If DAY is omitted, it defaults to 1 if N>0, and MONTH's last day otherwise." | 2383 If DAY is omitted, it defaults to 1 if N>0, and MONTH's last day otherwise." |
2384 (if (> n 0) | 2384 (if (> n 0) |
2385 (+ (* 7 (1- n)) | 2385 (+ (* 7 (1- n)) |
2386 (calendar-dayname-on-or-before | 2386 (calendar-dayname-on-or-before |
2387 dayname | 2387 dayname |
2388 (+ 6 (calendar-absolute-from-gregorian | 2388 (+ 6 (calendar-absolute-from-gregorian |
2389 (list month (or day 1) year))))) | 2389 (list month (or day 1) year))))) |
2390 (+ (* 7 (1+ n)) | 2390 (+ (* 7 (1+ n)) |
2391 (calendar-dayname-on-or-before | 2391 (calendar-dayname-on-or-before |
2392 dayname | 2392 dayname |
2393 (calendar-absolute-from-gregorian | 2393 (calendar-absolute-from-gregorian |
2394 (list month | 2394 (list month |
2395 (or day (calendar-last-day-of-month month year)) | 2395 (or day (calendar-last-day-of-month month year)) |
2396 year)))))) | 2396 year)))))) |
2397 | 2397 |
2398 (defun calendar-nth-named-day (n dayname month year &optional day) | 2398 (defun calendar-nth-named-day (n dayname month year &optional day) |
2399 "The date of Nth DAYNAME in MONTH, YEAR before/after optional DAY. | 2399 "The date of Nth DAYNAME in MONTH, YEAR before/after optional DAY. |
2400 A DAYNAME of 0 means Sunday, 1 means Monday, and so on. If N<0, | 2400 A DAYNAME of 0 means Sunday, 1 means Monday, and so on. If N<0, |
2401 return the Nth DAYNAME before MONTH DAY, YEAR (inclusive). | 2401 return the Nth DAYNAME before MONTH DAY, YEAR (inclusive). |