|
From: | Nick Dokos |
Subject: | Re: [O] org-bbdb-birthday reminder |
Date: | Thu, 13 Aug 2015 20:26:35 -0400 |
User-agent: | Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (gnu/linux) |
Here's a quick implementation of the method I described earlier in the thread: --8<---------------cut here---------------start------------->8--- ;;; Return list of anniversaries for today and the next n (default: 7) days. ;;; This is meant to be used in an org file instead of org-bbdb-anniversaries: ;;; ;;; %%(my-anniversaries) ;;; ;;; or ;;; %%(my-anniversaries 3) ;;; ;;; to override the 7-day default. (defun date-list (date &optional n) "Return a list of dates in (m d y) format from 'date' to n days hence." (if (not n) (setq n 7)) (let ((abs (calendar-absolute-from-gregorian date)) (i 0) ret) (while (<= i n) (setq ret (cons (calendar-gregorian-from-absolute (+ abs i)) ret)) (setq i (1+ i))) (reverse ret))) (defun annotate-link-with-date (d l) "Annotate text of each element of l with the anniversary date. The assumption is that the text is a bbdb link of the form [[bbdb:name][Description]] and the annotation is added to the description." (let ((f (lambda (x) (string-match "]]" x) (replace-match (format " -- %d-%d-%d\\&" (caddr d) (car d) (cadr d)) nil nil x)))) (mapcar f l))) (defun my-anniversaries (&optional n) "Return list of anniversaries for today and the next n days (default 7). 'date' is dynamically bound." (let ((dates (date-list date n)) (f (lambda (d) (let ((date d)) (annotate-link-with-date d (org-bbdb-anniversaries)))))) (delete nil (mapcan f dates)))) --8<---------------cut here---------------end--------------->8--- Lightly tested. Hope it helps -- Nick
[Prev in Thread] | Current Thread | [Next in Thread] |