emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs/lisp ChangeLog calendar/cal-china.el


From: Glenn Morris
Subject: [Emacs-diffs] emacs/lisp ChangeLog calendar/cal-china.el
Date: Sat, 05 Sep 2009 21:07:19 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Glenn Morris <gm>       09/09/05 21:07:18

Modified files:
        lisp           : ChangeLog 
        lisp/calendar  : cal-china.el 

Log message:
        (holiday-chinese): Make it slightly more efficient.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/ChangeLog?cvsroot=emacs&r1=1.16102&r2=1.16103
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/calendar/cal-china.el?cvsroot=emacs&r1=1.54&r2=1.55

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.16102
retrieving revision 1.16103
diff -u -b -r1.16102 -r1.16103
--- ChangeLog   5 Sep 2009 21:00:39 -0000       1.16102
+++ ChangeLog   5 Sep 2009 21:07:15 -0000       1.16103
@@ -1,5 +1,8 @@
 2009-09-05  Glenn Morris  <address@hidden>
 
+       * calendar/cal-china.el (holiday-chinese): Make it slightly more
+       efficient.
+
        * font-lock.el (lisp-font-lock-keywords-2): Add letf.
 
        * emacs-lisp/bytecomp.el (emacs-lisp-file-regexp): Doc fix.

Index: calendar/cal-china.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/calendar/cal-china.el,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -b -r1.54 -r1.55
--- calendar/cal-china.el       5 Jan 2009 03:20:31 -0000       1.54
+++ calendar/cal-china.el       5 Sep 2009 21:07:18 -0000       1.55
@@ -517,8 +517,14 @@
 If MONTH, DAY (Chinese) is visible, returns the corresponding
 Gregorian date as the list (((month day year) STRING)).
 Returns nil if it is not visible in the current calendar window."
-  ;; This is calendar-nongregorian-visible-p adapted for the form of
-  ;; chinese dates: (cycle year month day) as opposed to (month day year).
+  (let ((date
+         (calendar-gregorian-from-absolute
+          ;; A basic optimization.  Chinese year can only change if
+          ;; Jan or Feb are visible.  FIXME can we do more?
+          (if (memq displayed-month '(12 1 2 3))
+              ;; This is calendar-nongregorian-visible-p adapted for
+              ;; the form of chinese dates: (cycle year month day) as
+              ;; opposed to (month day year).
   (let* ((m1 displayed-month)
          (y1 displayed-year)
          (m2 displayed-month)
@@ -526,28 +532,27 @@
          ;; Absolute date of first/last dates in calendar window.
          (start-date (progn
                        (calendar-increment-month m1 y1 -1)
-                       (calendar-absolute-from-gregorian (list m1 1 y1))))
+                                   (calendar-absolute-from-gregorian
+                                    (list m1 1 y1))))
          (end-date (progn
                      (calendar-increment-month m2 y2 1)
                      (calendar-absolute-from-gregorian
-                      (list m2 (calendar-last-day-of-month m2 y2) y2))))
+                                  (list m2 (calendar-last-day-of-month m2 y2)
+                                        y2))))
          ;; Local date of first/last date in calendar window.
          (local-start (calendar-chinese-from-absolute start-date))
-         ;; A basic optimization.  We only care about the year part,
-         ;; and the Chinese year can only change if Jan or Feb are
-         ;; visible.  FIXME can we do more?
-         (local-end (if (memq displayed-month '(12 1 2 3))
-                        (calendar-chinese-from-absolute end-date)
-                      local-start))
-         ;; When Chinese New Year is visible on the far right of the
-         ;; calendar, what is the earliest Chinese month in the
-         ;; previous year that might still visible?  This test doesn't
-         ;; have to be precise.
+                     (local-end (calendar-chinese-from-absolute end-date))
+                     ;; When Chinese New Year is visible on the far
+                     ;; right of the calendar, what is the earliest
+                     ;; Chinese month in the previous year that might
+                     ;; still visible?  This test doesn't have to be precise.
          (local (if (< month 10) local-end local-start))
          (cycle (car local))
-         (year (cadr local))
-         (date (calendar-gregorian-from-absolute
-                (calendar-chinese-to-absolute (list cycle year month day)))))
+                     (year (cadr local)))
+                (calendar-chinese-to-absolute (list cycle year month day)))
+            ;; Simple form for when new years are not visible.
+            (+ (cadr (assoc month (calendar-chinese-year displayed-year)))
+               (1- day))))))
     (if (calendar-date-is-visible-p date)
         (list (list date string)))))
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]