comparison 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
comparison
equal deleted inserted replaced
115:f109f7dabbe2 116:9f59509498e1
357 (display-buffer holiday-buffer) 357 (display-buffer holiday-buffer)
358 (message "No diary entries for %s" date-string))) 358 (message "No diary entries for %s" date-string)))
359 (save-excursion;; Prepare the fancy diary buffer. 359 (save-excursion;; Prepare the fancy diary buffer.
360 (set-buffer (get-buffer-create fancy-diary-buffer)) 360 (set-buffer (get-buffer-create fancy-diary-buffer))
361 (setq buffer-read-only nil) 361 (setq buffer-read-only nil)
362 (make-local-variable 'mode-line-format) 362 (setq modeline-buffer-identification '("Diary Entries"))
363 (calendar-set-mode-line "Diary Entries")
364 (erase-buffer) 363 (erase-buffer)
365 (let ((entry-list diary-entries-list) 364 (let ((entry-list diary-entries-list)
366 (holiday-list) 365 (holiday-list)
367 (holiday-list-last-month 1) 366 (holiday-list-last-month 1)
368 (holiday-list-last-year 1) 367 (holiday-list-last-year 1)
1100 Entry will appear on dates between M1/D1/Y1 and M2/D2/Y2, 1099 Entry will appear on dates between M1/D1/Y1 and M2/D2/Y2,
1101 inclusive. (If `european-calendar-style' is t, the 1100 inclusive. (If `european-calendar-style' is t, the
1102 order of the parameters should be changed to D1, M1, Y1, 1101 order of the parameters should be changed to D1, M1, Y1,
1103 D2, M2, Y2.) 1102 D2, M2, Y2.)
1104 1103
1104 %%(diary-countdown BEFORE AFTER M1 D1 Y1) text
1105 Entry will appear on dates between BEFORE days before
1106 and AFTER days after specified date. (If
1107 `european-calendar-style' is t, the order of the
1108 parameters should be changed to BEFORE, AFTER, D1, M1,
1109 Y1.)
1110
1105 %%(diary-anniversary MONTH DAY YEAR) text 1111 %%(diary-anniversary MONTH DAY YEAR) text
1106 Entry will appear on anniversary dates of MONTH DAY, YEAR. 1112 Entry will appear on anniversary dates of MONTH DAY, YEAR.
1107 (If `european-calendar-style' is t, the order of the 1113 (If `european-calendar-style' is t, the order of the
1108 parameters should be changed to DAY, MONTH, YEAR.) Text 1114 parameters should be changed to DAY, MONTH, YEAR.) Text
1109 can contain %d or %d%s; %d will be replaced by the number 1115 can contain %d or %d%s; %d will be replaced by the number
1259 nil)))) 1265 nil))))
1260 1266
1261 (defun diary-block (m1 d1 y1 m2 d2 y2) 1267 (defun diary-block (m1 d1 y1 m2 d2 y2)
1262 "Block diary entry. 1268 "Block diary entry.
1263 Entry applies if date is between two dates. Order of the parameters is 1269 Entry applies if date is between two dates. Order of the parameters is
1264 M1, D1, Y1, M2, D2, Y2 `european-calendar-style' is nil, and 1270 M1, D1, Y1, M2, D2, Y2 if `european-calendar-style' is nil, and
1265 D1, M1, Y1, D2, M2, Y2 if `european-calendar-style' is t." 1271 D1, M1, Y1, D2, M2, Y2 if `european-calendar-style' is t."
1266 (let ((date1 (calendar-absolute-from-gregorian 1272 (let ((date1 (calendar-absolute-from-gregorian
1267 (if european-calendar-style 1273 (if european-calendar-style
1268 (list d1 m1 y1) 1274 (list d1 m1 y1)
1269 (list m1 d1 y1)))) 1275 (list m1 d1 y1))))
1272 (list d2 m2 y2) 1278 (list d2 m2 y2)
1273 (list m2 d2 y2)))) 1279 (list m2 d2 y2))))
1274 (d (calendar-absolute-from-gregorian date))) 1280 (d (calendar-absolute-from-gregorian date)))
1275 (if (and (<= date1 d) (<= d date2)) 1281 (if (and (<= date1 d) (<= d date2))
1276 entry))) 1282 entry)))
1283
1284 (defun diary-countdown (before after m1 d1 y1)
1285 "Countdown diary entry.
1286 Entry applies if date is between BEFORE days before and AFTER days after
1287 specified date. Order of the parameters is BEFORE, AFTER, M1, D1, Y1 if
1288 `european-calendar-style' is nil, and BEFORE, AFTER, D1, M1, Y1 if
1289 `european-calendar-style' is t."
1290 (let* ((date1 (calendar-absolute-from-gregorian
1291 (if european-calendar-style
1292 (list d1 m1 y1)
1293 (list m1 d1 y1))))
1294 (d (calendar-absolute-from-gregorian date))
1295 (diff (- d date1)))
1296 (cond
1297 ((and (<= (- before) diff) (< diff 0))
1298 (concat (format "It is %d day%s before "
1299 (- diff) (if (= diff -1) "" "s")) entry))
1300 ((= diff 0) (concat (format "TODAY: " diff) entry))
1301 ((and (<= diff after) (> diff 0))
1302 (concat (format "It is %d day%s after "
1303 diff (if (= diff 1) "" "s")) entry))
1304 (t nil))))
1277 1305
1278 (defun diary-float (month dayname n) 1306 (defun diary-float (month dayname n)
1279 "Floating diary entry--entry applies if date is the nth dayname of month. 1307 "Floating diary entry--entry applies if date is the nth dayname of month.
1280 Parameters are MONTH, DAYNAME, N. MONTH can be a list of months, the constant 1308 Parameters are MONTH, DAYNAME, N. MONTH can be a list of months, the constant
1281 t, or an integer. The constant t means all months. If N is negative, count 1309 t, or an integer. The constant t means all months. If N is negative, count