emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nick Dokos <ndokos@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: org-bbdb-birthday reminder
Date: Thu, 13 Aug 2015 20:26:35 -0400	[thread overview]
Message-ID: <871tf690lg.fsf@pierrot.dokosmarshall.org> (raw)
In-Reply-To: 87lhdftjzy.fsf@fastmail.fm

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

  reply	other threads:[~2015-08-14  0:26 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-29 13:41 org-bbdb-birthday reminder Julien Cubizolles
2015-08-12 20:55 ` Matt Lundin
2015-08-13  1:36   ` Nick Dokos
2015-08-13  6:35   ` Julien Cubizolles
2015-08-13 13:07     ` Matt Lundin
2015-08-14  0:26       ` Nick Dokos [this message]
2015-08-14 14:30         ` Matt Lundin
2015-08-15 18:24           ` Julien Cubizolles
2015-08-16 17:25             ` [PATCH] Allow early-warning anniversaries in agends [was: Re: org-bbdb-birthday reminder] Nick Dokos
2015-08-17  9:16               ` Nicolas Goaziou
2015-08-17 16:42                 ` Nick Dokos
2015-08-17 16:57                   ` Rasmus
2015-08-17 17:35                     ` Nicolas Goaziou
2015-10-06 15:11                       ` Nick Dokos
2015-10-07 19:58                         ` Nicolas Goaziou
2015-10-13 15:54                           ` Nick Dokos
2015-10-14 23:21                           ` Nick Dokos
2015-08-16 13:46           ` org-bbdb-birthday reminder Bastien Guerry

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871tf690lg.fsf@pierrot.dokosmarshall.org \
    --to=ndokos@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).