From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: org-bbdb-birthday reminder Date: Thu, 13 Aug 2015 20:26:35 -0400 Message-ID: <871tf690lg.fsf@pierrot.dokosmarshall.org> References: <87a8ufdqte.fsf@free.fr> <871tf89qh8.fsf@fastmail.fm> <87wpwzlmpn.fsf@free.fr> <87lhdftjzy.fsf@fastmail.fm> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:33519) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZQ2pf-00037Z-2I for emacs-orgmode@gnu.org; Thu, 13 Aug 2015 20:26:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZQ2pb-0001ES-S1 for emacs-orgmode@gnu.org; Thu, 13 Aug 2015 20:26:51 -0400 Received: from plane.gmane.org ([80.91.229.3]:51920) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZQ2pb-0001EI-KQ for emacs-orgmode@gnu.org; Thu, 13 Aug 2015 20:26:47 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1ZQ2pX-0003Vd-08 for emacs-orgmode@gnu.org; Fri, 14 Aug 2015 02:26:43 +0200 Received: from pool-108-20-41-232.bstnma.fios.verizon.net ([108.20.41.232]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 14 Aug 2015 02:26:42 +0200 Received: from ndokos by pool-108-20-41-232.bstnma.fios.verizon.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 14 Aug 2015 02:26:42 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org 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