diff lisp/calendar/diary-lib.el @ 116:9f59509498e1 r20-1b10

Import from CVS: tag r20-1b10
author cvs
date Mon, 13 Aug 2007 09:23:06 +0200
parents 131b0175ea99
children
line wrap: on
line diff
--- a/lisp/calendar/diary-lib.el	Mon Aug 13 09:21:56 2007 +0200
+++ b/lisp/calendar/diary-lib.el	Mon Aug 13 09:23:06 2007 +0200
@@ -359,8 +359,7 @@
     (save-excursion;; Prepare the fancy diary buffer.
       (set-buffer (get-buffer-create fancy-diary-buffer))
       (setq buffer-read-only nil)
-      (make-local-variable 'mode-line-format)
-      (calendar-set-mode-line "Diary Entries")
+      (setq modeline-buffer-identification '("Diary Entries"))
       (erase-buffer)
       (let ((entry-list diary-entries-list)
             (holiday-list)
@@ -1102,6 +1101,13 @@
                   order of the parameters should be changed to D1, M1, Y1,
                   D2, M2, Y2.)
 
+      %%(diary-countdown BEFORE AFTER M1 D1 Y1) text
+                  Entry will appear on dates between BEFORE days before
+                  and AFTER days after specified date.  (If
+                  `european-calendar-style' is t, the order of the
+                  parameters should be changed to BEFORE, AFTER, D1, M1,
+                  Y1.)
+
       %%(diary-anniversary MONTH DAY YEAR) text
                   Entry will appear on anniversary dates of MONTH DAY, YEAR.
                   (If `european-calendar-style' is t, the order of the
@@ -1261,7 +1267,7 @@
 (defun diary-block (m1 d1 y1 m2 d2 y2)
   "Block diary entry.
 Entry applies if date is between two dates.  Order of the parameters is
-M1, D1, Y1, M2, D2, Y2 `european-calendar-style' is nil, and
+M1, D1, Y1, M2, D2, Y2 if `european-calendar-style' is nil, and
 D1, M1, Y1, D2, M2, Y2 if `european-calendar-style' is t."
   (let ((date1 (calendar-absolute-from-gregorian
                 (if european-calendar-style
@@ -1275,6 +1281,28 @@
     (if (and (<= date1 d) (<= d date2))
         entry)))
 
+(defun diary-countdown (before after m1 d1 y1)
+  "Countdown diary entry.
+Entry applies if date is between BEFORE days before and AFTER days after
+specified date.  Order of the parameters is BEFORE, AFTER, M1, D1, Y1 if
+`european-calendar-style' is nil, and BEFORE, AFTER, D1, M1, Y1 if
+`european-calendar-style' is t."
+  (let* ((date1 (calendar-absolute-from-gregorian
+                 (if european-calendar-style
+                     (list d1 m1 y1)
+                   (list m1 d1 y1))))
+         (d (calendar-absolute-from-gregorian date))
+         (diff (- d date1)))
+    (cond
+     ((and (<= (- before) diff) (< diff 0))
+      (concat (format "It is %d day%s before " 
+                      (- diff) (if (= diff -1) "" "s")) entry))
+     ((= diff 0) (concat (format "TODAY: " diff) entry))
+     ((and (<= diff after) (> diff 0)) 
+      (concat (format "It is %d day%s after " 
+                      diff (if (= diff 1) "" "s")) entry))
+     (t nil))))
+
 (defun diary-float (month dayname n)
   "Floating diary entry--entry applies if date is the nth dayname of month.
 Parameters are MONTH, DAYNAME, N.  MONTH can be a list of months, the constant