LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 968|回复: 0

[共享]Emacs Calendar配置文件

[复制链接]
发表于 2005-11-23 17:52:09 | 显示全部楼层 |阅读模式
经常不记得朋友的生日或者属性,所以整理了一下calendar,写了这个配置文件,感觉还不错,给有需要的朋友共享把。


  1. ;; Emacs Calender
  2. ;;
  3. ;; Emacs 中有日历,而且可以称之为一个系统,因为其中除了最常用的日历之外,
  4. ;; 还有其他的近十种历法,其中有日记、约会提醒、纪念日提示以及节假日提示等
  5. ;; 等。其中的历法包括中国的农历、希伯来历、伊斯兰历、法国革命历、中美玛雅
  6. ;; 历等等,可以根据经纬度告知你的所在的每天日出日落的时间等等。
  7. ;;
  8. ;; holiday-fixed m d        固定阳历节日, m 月 d 日
  9. ;; holiday-float m w n 浮动阳历节日, m 月的第 n 个星期 w%7
  10. ;;                     
  11. ;; ----------------------------------------------
  12. ;; .        跳回当前天
  13. ;; o        跳到某一个月
  14. ;; g d        跳到某年某月某日
  15. ;; g c        跳到某年某星期的星期几
  16. ;; g C        跳到阴历的某一天
  17. ;; p C        显示当前的阴历日期
  18. ;; h        显示当前节日
  19. ;; i d        加入当前这一天的日程安排
  20. ;; i w        加入每周这一天的日程安排
  21. ;; i m        加入每月这一天的日程安排
  22. ;; i y        加入每年这一天的日程安排
  23. ;; i a        加入周年纪念(anniversary),比如生日等
  24. ;; d        察看当前日期的diary
  25. ;; -----------------------------------------------
  26. ;;

  27. (defun animals(birthyear)
  28.   "Calculate the Chinese aninal by year"
  29.   (let ((x (% (- 1997 birthyear) 12)))
  30.     (cond ((or (= x 1) (= x -11))  "鼠")
  31.           ((= x 0)                 "牛")
  32.           ((or (= x 11) (= x -1))  "虎")
  33.           ((or (= x 10) (= x -2))  "兔")
  34.           ((or (= x 9) (= x -3))   "龙")
  35.           ((or (= x 8) (= x -4))   "蛇")
  36.           ((or (= x 7) (= x -5))   "马")
  37.           ((or (= x 6) (= x -6))   "羊")
  38.           ((or (= x 5) (= x -7))   "猴")
  39.           ((or (= x 4) (= x -8))   "鸡")
  40.           ((or (= x 3) (= x -9))   "狗")
  41.           ((or (= x 2) (= x -10))  "猪")
  42.           )
  43.     )
  44.   )

  45. ;; 保存日记的文件
  46. (setq diary-file "~/emacs/data/diary")
  47. (setq diary-mail-addr "guest@gmail.com")
  48. (add-hook 'diary-hook 'appt-make-list)
  49. ;;appointment
  50. (setq appt-issue-message t)

  51. ;; 设置所在地的经纬度和地名,calendar 中按 S,可以根据这些信息告知你每天的
  52. ;; 日出和日落的时间:
  53. (setq calendar-latitude +31.3)
  54. (setq calendar-longitude +120.6)
  55. (setq calendar-location-name "苏州")

  56. (setq calendar-remove-frame-by-deleting t)
  57. (setq calendar-week-start-day 1)              ; 每周第一天是周一
  58. (setq mark-diary-entries-in-calendar t)       ; 标记有记录的日子
  59. (setq mark-holidays-in-calendar nil)          ; 标记节假日
  60. (setq view-calendar-holidays-initially nil)   ; 不显示节日列表

  61. ;;除去基督徒的节日、希伯来人的节日和伊斯兰教的节日。
  62. (setq christian-holidays nil
  63.       hebrew-holidays nil
  64.       islamic-holidays nil
  65.       solar-holidays nil
  66.       bahai-holidays nil
  67.       )

  68. (setq general-holidays '((holiday-fixed 1 1   "元旦")
  69.                          (holiday-fixed 2 14  "情人节")
  70.                          (holiday-fixed 4 1   "愚人节")
  71.                          (holiday-fixed 12 25 "圣诞节")
  72.                          (holiday-fixed 10 1  "国庆节")
  73.                          (holiday-float 5 0 2 "母亲节")   ;5月的第二个星期天
  74.                          (holiday-float 6 0 3 "父亲节")
  75.                          ))

  76. (setq local-holidays '((holiday-chinese 1 15  "元宵节 (正月十五)")
  77.                        (holiday-chinese 5 5   "端午节 (五月初五)")
  78.                        (holiday-chinese 9 9   "重阳节 (九月初九)")
  79.                        (holiday-chinese 8 15  "中秋节 (八月十五)")
  80.                        ;; 生日
  81.                        (birthday-fixed 9 28  "爸爸生日(1950)")
  82.                        (birthday-fixed 10 1  "妈妈生日(1953)")
  83.                        (holiday-chinese 5 29 "老婆生日")           ;阴历生日
  84.                        ))

  85. (setq chinese-calendar-celestial-stem
  86.       ["甲" "乙" "丙" "丁" "戊" "己" "庚" "辛" "壬" "癸"])
  87. (setq chinese-calendar-terrestrial-branch
  88.       ["子" "丑" "寅" "卯" "辰" "巳" "午" "未" "申" "酉" "戌" "亥"])

  89. (setq mark-diary-entries-in-calendar t
  90.       appt-issue-message nil
  91.       mark-holidays-in-calendar t
  92.       view-calendar-holidays-initially nil)

  93. (setq diary-date-forms '((year "/" month "/" day "[^/0-9]"))
  94.       calendar-date-display-form '(year "/" month "/" day)
  95.       calendar-time-display-form
  96.       '(24-hours ":" minutes (if time-zone " (") time-zone (if time-zone ")")))

  97. (add-hook 'today-visible-calendar-hook 'calendar-mark-today)

  98. (autoload 'chinese-year "cal-china" "Chinese year data" t)

  99. (defun holiday-chinese (cmonth cday string)
  100.   "Chinese calendar holiday, month and day in Chinese calendar (CMONTH, CDAY).

  101. If corresponding MONTH and DAY in gregorian calendar is visible,
  102. the value returned is the list \(((MONTH DAY year) STRING)).
  103. Returns nil if it is not visible in the current calendar window."
  104.   (let* ((m displayed-month)
  105.          (y displayed-year)
  106.          (gdate (calendar-gregorian-from-absolute
  107.                  (+ (cadr (assoc cmonth (chinese-year y))) (1- cday))))
  108.          (gm (car gdate))
  109.          (gd (cadr gdate))
  110.          (gy (caddr gdate)))
  111.     (increment-calendar-month m y (- 11 gm))
  112.     (if (> m 9)
  113.         (list (list (list gm gd gy) string)))))

  114. (defun birthday-fixed (month day string)
  115.   "Holiday on MONTH, DAY (Gregorian) called STRING.
  116. If MONTH, DAY is visible, the value returned is the list (((MONTH DAY year)
  117. STRING)).  Returns nil if it is not visible in the current calendar window."
  118.   (let ((m displayed-month)
  119.         (y displayed-year)
  120.         (animal (animals (string-to-number (nth 1 (split-string string "(")))))
  121.         )
  122.     (increment-calendar-month m y (- 11 month))
  123.     (if (> m 9)
  124.       (list (list (list month day y) string animal)))))

  125. ;; 设置颜色显示                       
  126. (setq calendar-load-hook
  127.       '(lambda ()
  128.          (set-face-foreground 'diary-face   "skyblue")
  129.          (set-face-background 'holiday-face "slate blue")
  130.          (set-face-foreground 'holiday-face "white")))


  131. (global-set-key (kbd "<f11>") 'calendar)


复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表