From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Baumann Subject: Re: [PATCH] org-bbdb: allow anniversaries with unknown years Date: Tue, 08 Feb 2011 17:05:49 +0100 Message-ID: References: <7A37ACA4-DE3B-4745-A1FC-98ED62A53982@gmail.com> <1297078995-9030-1-git-send-email-cwg@falma.de> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from [140.186.70.92] (port=44939 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pmq4t-0005P5-Gy for emacs-orgmode@gnu.org; Tue, 08 Feb 2011 11:06:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pmq4r-00030e-8B for emacs-orgmode@gnu.org; Tue, 08 Feb 2011 11:06:07 -0500 Received: from lo.gmane.org ([80.91.229.12]:33009) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pmq4q-00030B-Sv for emacs-orgmode@gnu.org; Tue, 08 Feb 2011 11:06:05 -0500 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1Pmq4o-0001ag-03 for emacs-orgmode@gnu.org; Tue, 08 Feb 2011 17:06:02 +0100 Received: from pd95529e3.dip.t-dialin.net ([217.85.41.227]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 08 Feb 2011 17:06:01 +0100 Received: from dtbaumann by pd95529e3.dip.t-dialin.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 08 Feb 2011 17:06:01 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Cc: Carsten Dominik Christoph Groth writes: > Anniversaries in BBDB can be now also specified in the format MM-DD > next to YYYY-MM-DD. > --- > doc/org.texi | 11 ++++++----- > lisp/org-bbdb.el | 27 ++++++++++++++++++--------- > 2 files changed, 24 insertions(+), 14 deletions(-) > > diff --git a/doc/org.texi b/doc/org.texi > index b406d29..bfcef06 100644 > --- a/doc/org.texi > +++ b/doc/org.texi > @@ -7098,14 +7098,15 @@ following to one your your agenda files: > > You can then go ahead and define anniversaries for a BBDB record. Basically, > you need to press @kbd{C-o anniversary @key{RET}} with the cursor in a BBDB > -record and then add the date in the format @code{YYYY-MM-DD}, followed by a > -space and the class of the anniversary (@samp{birthday} or @samp{wedding}, or > -a format string). If you omit the class, it will default to @samp{birthday}. > -Here are a few examples, the header for the file @file{org-bbdb.el} contains > -more detailed information. > +record and then add the date in the format @code{YYYY-MM-DD} or @code{MM-DD}, > +followed by a space and the class of the anniversary (@samp{birthday} or > +@samp{wedding}, or a format string). If you omit the class, it will default to > +@samp{birthday}. Here are a few examples, the header for the file > +@file{org-bbdb.el} contains more detailed information. > > @example > 1973-06-22 > +06-22 > 1955-08-02 wedding > 2008-04-14 %s released version 6.01 of org-mode, %d years ago > @end example > diff --git a/lisp/org-bbdb.el b/lisp/org-bbdb.el > index 4155f58..c04b7ff 100644 > --- a/lisp/org-bbdb.el > +++ b/lisp/org-bbdb.el > @@ -136,12 +136,12 @@ > '(("birthday" lambda > (name years suffix) > (concat "Birthday: [[bbdb:" name "][" name " (" > - (number-to-string years) > + (format "%s" years) ; handles numbers as well as strings > suffix ")]]")) > ("wedding" lambda > (name years suffix) > (concat "[[bbdb:" name "][" name "'s " > - (number-to-string years) > + (format "%s" years) > suffix " wedding anniversary]]"))) > "How different types of anniversaries should be formatted. > An alist of elements (STRING . FORMAT) where STRING is the name of an > @@ -239,11 +239,16 @@ italicized, in all other cases it is left unchanged." > > (defun org-bbdb-anniv-extract-date (time-str) > "Convert YYYY-MM-DD to (month date year). > -Argument TIME-STR is the value retrieved from BBDB." > - (multiple-value-bind (y m d) (values-list (bbdb-split time-str "-")) > - (list (string-to-number m) > - (string-to-number d) > - (string-to-number y)))) > +Argument TIME-STR is the value retrieved from BBDB. If YYYY- is omitted > +it will be considered unknown." > + (multiple-value-bind (a b c) (values-list (bbdb-split time-str "-")) > + (if (eq c nil) > + (list (string-to-number a) > + (string-to-number b) > + nil) > + (list (string-to-number b) > + (string-to-number c) > + (string-to-number a))))) > > (defun org-bbdb-anniv-split (str) > "Split multiple entries in the BBDB anniversary field. > @@ -326,8 +331,12 @@ This is used by Org to re-create the anniversary hash table." > class org-bbdb-anniversary-format-alist t)) > class)) ; (as format string) > (name (nth 1 rec)) > - (years (- y (car rec))) > - (suffix (diary-ordinal-suffix years)) > + (years (if (eq (car rec) nil) > + "unknown" > + (- y (car rec)))) > + (suffix (if (eq (car rec) nil) > + "" > + (diary-ordinal-suffix years))) > (tmp (cond > ((functionp form) > (funcall form name years suffix)) Thanks for adding this feature. Carsten, could you please check this in? The ChangeLog should mention that any customized "org-bbdb-anniversary-format-alist" has to be updated, otherwise there will be an "Bad sexp at line 637 in /home/tb/org/diary.org: (org-bbdb-anniversaries)" error with the new format. Thomas