农历生日快乐提醒

平时不会关注农历日期,生日用农历记法有个好处——今天过生日自己也不知道,如果有收到礼物那就完全算是惊喜;如果什么事都没发生也意识不到,倒也无所谓。

试试让 Emacs 祝自己生日快乐。

(defun chunyang-birthday-p ()
  "Return t if today is my birthday, i.e., 农历九月廿三."
  ;; Adapted from `calendar-chinese-date-string'
  (require 'cal-china)
  (pcase-let ((`(_ _ ,m ,d) (calendar-chinese-from-absolute
                             (calendar-absolute-from-gregorian
                              (calendar-current-date)))))
    ;; Note: For leap months M is a float.
    (equal (list (floor m) d) '(9 23))))

(defun chunyang-happy-birthday ()
  ;; Avoid slowing down Emacs startup
  (run-with-idle-timer
   1
   nil
   (lambda ()
     (when (chunyang-birthday-p)
       (let ((cursor-type nil))
         (animate-birthday-present user-full-name))))))

(add-hook 'emacs-startup-hook #'chunyang-happy-birthday)
9 个赞

这个比较有意思,应该也算比较实用。

伸手党无耻的问一声,大佬有没有可能做个包出来,做为一种重大事件提醒的手段来使用。

另,@xuchunyang, happy Birthday !

1 个赞

So. 生日快乐!

1 个赞

不清楚,但 Emacs 自带了个预约功能 (emacs) Appointments,不过我没用过。

1 个赞