Mercurial > emacs
comparison lisp/calendar/cal-china.el @ 92579:8ddfb879916b
Unquote lambda functions. Add autoload cookies to functions formerly
autoloaded in calendar.el. Set `generated-autoload-file' to
"cal-loaddefs.el".
(chinese-calendar): Move custom group here from calendar.el.
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Make constants.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Sat, 08 Mar 2008 03:39:49 +0000 |
parents | 0ef74aab4b13 |
children | 52850e6ad92b |
comparison
equal
deleted
inserted
replaced
92578:8b2b620788b7 | 92579:8ddfb879916b |
---|---|
49 (defvar displayed-month) | 49 (defvar displayed-month) |
50 (defvar displayed-year) | 50 (defvar displayed-year) |
51 | 51 |
52 (require 'lunar) | 52 (require 'lunar) |
53 | 53 |
54 (defvar chinese-calendar-celestial-stem | 54 (defgroup chinese-calendar nil |
55 ["Jia" "Yi" "Bing" "Ding" "Wu" "Ji" "Geng" "Xin" "Ren" "Gui"]) | 55 "Chinese calendar support." |
56 | 56 :group 'calendar) |
57 (defvar chinese-calendar-terrestrial-branch | |
58 ["Zi" "Chou" "Yin" "Mao" "Chen" "Si" "Wu" "Wei" "Shen" "You" "Xu" "Hai"]) | |
59 | 57 |
60 (defcustom chinese-calendar-time-zone | 58 (defcustom chinese-calendar-time-zone |
61 '(if (< year 1928) | 59 '(if (< year 1928) |
62 (+ 465 (/ 40.0 60.0)) | 60 (+ 465 (/ 40.0 60.0)) |
63 480) | 61 480) |
128 (defcustom chinese-calendar-daylight-savings-ends-time 0 | 126 (defcustom chinese-calendar-daylight-savings-ends-time 0 |
129 "Number of minutes after midnight that daylight saving time ends for | 127 "Number of minutes after midnight that daylight saving time ends for |
130 Chinese calendar. Default is for no daylight saving time." | 128 Chinese calendar. Default is for no daylight saving time." |
131 :type 'integer | 129 :type 'integer |
132 :group 'chinese-calendar) | 130 :group 'chinese-calendar) |
131 | |
132 ;;; End of user options. | |
133 | |
134 | |
135 (defconst chinese-calendar-celestial-stem | |
136 ["Jia" "Yi" "Bing" "Ding" "Wu" "Ji" "Geng" "Xin" "Ren" "Gui"]) | |
137 | |
138 (defconst chinese-calendar-terrestrial-branch | |
139 ["Zi" "Chou" "Yin" "Mao" "Chen" "Si" "Wu" "Wei" "Shen" "You" "Xu" "Hai"]) | |
133 | 140 |
134 (defun chinese-zodiac-sign-on-or-after (d) | 141 (defun chinese-zodiac-sign-on-or-after (d) |
135 "Absolute date of first new Zodiac sign on or after absolute date d. | 142 "Absolute date of first new Zodiac sign on or after absolute date d. |
136 The Zodiac signs begin when the sun's longitude is a multiple of 30 degrees." | 143 The Zodiac signs begin when the sun's longitude is a multiple of 30 degrees." |
137 (let* ((year (extract-calendar-year | 144 (let* ((year (extract-calendar-year |
372 (list | 379 (list |
373 (list chinese-new-year | 380 (list chinese-new-year |
374 (format "Chinese New Year (%s)" | 381 (format "Chinese New Year (%s)" |
375 (calendar-chinese-sexagesimal-name (+ y 57)))))))))) | 382 (calendar-chinese-sexagesimal-name (+ y 57)))))))))) |
376 | 383 |
384 ;;;###autoload | |
377 (defun calendar-chinese-date-string (&optional date) | 385 (defun calendar-chinese-date-string (&optional date) |
378 "String of Chinese date of Gregorian DATE. | 386 "String of Chinese date of Gregorian DATE. |
379 Defaults to today's date if DATE is not given." | 387 Defaults to today's date if DATE is not given." |
380 (let* ((a-date (calendar-absolute-from-gregorian | 388 (let* ((a-date (calendar-absolute-from-gregorian |
381 (or date (calendar-current-date)))) | 389 (or date (calendar-current-date)))) |
413 ..., N congruent to 60 gives the sixtieth name." | 421 ..., N congruent to 60 gives the sixtieth name." |
414 (format "%s-%s" | 422 (format "%s-%s" |
415 (aref chinese-calendar-celestial-stem (% (1- n) 10)) | 423 (aref chinese-calendar-celestial-stem (% (1- n) 10)) |
416 (aref chinese-calendar-terrestrial-branch (% (1- n) 12)))) | 424 (aref chinese-calendar-terrestrial-branch (% (1- n) 12)))) |
417 | 425 |
426 ;;;###autoload | |
418 (defun calendar-print-chinese-date () | 427 (defun calendar-print-chinese-date () |
419 "Show the Chinese date equivalents of date." | 428 "Show the Chinese date equivalents of date." |
420 (interactive) | 429 (interactive) |
421 (message "Computing Chinese date...") | 430 (message "Computing Chinese date...") |
422 (message "Chinese date: %s" | 431 (message "Chinese date: %s" |
423 (calendar-chinese-date-string (calendar-cursor-to-date t)))) | 432 (calendar-chinese-date-string (calendar-cursor-to-date t)))) |
424 | 433 |
434 ;;;###autoload | |
425 (defun calendar-goto-chinese-date (date &optional noecho) | 435 (defun calendar-goto-chinese-date (date &optional noecho) |
426 "Move cursor to Chinese date DATE. | 436 "Move cursor to Chinese date DATE. |
427 Echo Chinese date unless NOECHO is t." | 437 Echo Chinese date unless NOECHO is t." |
428 (interactive | 438 (interactive |
429 (let* ((c (calendar-chinese-from-absolute | 439 (let* ((c (calendar-chinese-from-absolute |
430 (calendar-absolute-from-gregorian | 440 (calendar-absolute-from-gregorian |
431 (calendar-current-date)))) | 441 (calendar-current-date)))) |
432 (cycle (calendar-read | 442 (cycle (calendar-read |
433 "Chinese calendar cycle number (>44): " | 443 "Chinese calendar cycle number (>44): " |
434 '(lambda (x) (> x 44)) | 444 (lambda (x) (> x 44)) |
435 (int-to-string (car c)))) | 445 (int-to-string (car c)))) |
436 (year (calendar-read | 446 (year (calendar-read |
437 "Year in Chinese cycle (1..60): " | 447 "Year in Chinese cycle (1..60): " |
438 '(lambda (x) (and (<= 1 x) (<= x 60))) | 448 (lambda (x) (and (<= 1 x) (<= x 60))) |
439 (int-to-string (car (cdr c))))) | 449 (int-to-string (car (cdr c))))) |
440 (month-list (make-chinese-month-assoc-list | 450 (month-list (make-chinese-month-assoc-list |
441 (chinese-months cycle year))) | 451 (chinese-months cycle year))) |
442 (month (cdr (assoc | 452 (month (cdr (assoc |
443 (completing-read "Chinese calendar month: " | 453 (completing-read "Chinese calendar month: " |
451 (list cycle year month 1)))))))) | 461 (list cycle year month 1)))))))) |
452 30 | 462 30 |
453 29)) | 463 29)) |
454 (day (calendar-read | 464 (day (calendar-read |
455 (format "Chinese calendar day (1-%d): " last) | 465 (format "Chinese calendar day (1-%d): " last) |
456 '(lambda (x) (and (<= 1 x) (<= x last)))))) | 466 (lambda (x) (and (<= 1 x) (<= x last)))))) |
457 (list (list cycle year month day)))) | 467 (list (list cycle year month day)))) |
458 (calendar-goto-date (calendar-gregorian-from-absolute | 468 (calendar-goto-date (calendar-gregorian-from-absolute |
459 (calendar-absolute-from-chinese date))) | 469 (calendar-absolute-from-chinese date))) |
460 (or noecho (calendar-print-chinese-date))) | 470 (or noecho (calendar-print-chinese-date))) |
461 | 471 |
462 (defun chinese-months (c y) | 472 (defun chinese-months (c y) |
463 "A list of the months in cycle C, year Y of the Chinese calendar." | 473 "A list of the months in cycle C, year Y of the Chinese calendar." |
464 (let* ((l (memq 1 (append | 474 (let* ((l (memq 1 (append |
465 (mapcar '(lambda (x) | 475 (mapcar (lambda (x) |
466 (car x)) | 476 (car x)) |
467 (chinese-year (extract-calendar-year | 477 (chinese-year (extract-calendar-year |
468 (calendar-gregorian-from-absolute | 478 (calendar-gregorian-from-absolute |
469 (calendar-absolute-from-chinese | 479 (calendar-absolute-from-chinese |
470 (list c y 1 1)))))) | 480 (list c y 1 1)))))) |
471 (mapcar '(lambda (x) | 481 (mapcar (lambda (x) |
472 (if (> (car x) 11) (car x))) | 482 (if (> (car x) 11) (car x))) |
473 (chinese-year (extract-calendar-year | 483 (chinese-year (extract-calendar-year |
474 (calendar-gregorian-from-absolute | 484 (calendar-gregorian-from-absolute |
475 (calendar-absolute-from-chinese | 485 (calendar-absolute-from-chinese |
476 (list (if (= y 60) (1+ c) c) | 486 (list (if (= y 60) (1+ c) c) |
496 "Chinese calendar equivalent of date diary entry." | 506 "Chinese calendar equivalent of date diary entry." |
497 (format "Chinese date: %s" (calendar-chinese-date-string date))) | 507 (format "Chinese date: %s" (calendar-chinese-date-string date))) |
498 | 508 |
499 (provide 'cal-china) | 509 (provide 'cal-china) |
500 | 510 |
501 ;;; arch-tag: 7e5b7e0d-676c-47e3-8696-93e7ea0ab644 | 511 ;; Local Variables: |
512 ;; generated-autoload-file: "cal-loaddefs.el" | |
513 ;; End: | |
514 | |
515 ;; arch-tag: 7e5b7e0d-676c-47e3-8696-93e7ea0ab644 | |
502 ;;; cal-china.el ends here | 516 ;;; cal-china.el ends here |