emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Matt Lundin <mdl@imapmail.org>
To: Org Mode <emacs-orgmode@gnu.org>
Subject: [PATCH] Fix org-bbdb anniversaries to work with the new BBDB
Date: Sat, 7 Apr 2012 07:21:57 -0500	[thread overview]
Message-ID: <87bon3raqo.fsf@fastmail.fm> (raw)

* lisp/org-bbdb.el: (org-bbdb-anniv-extract-date)
  (org-bbdb-make-anniv-hash) Fix org-bbdb anniversary functionality to
  accommodate bbdb 3.x.  There are two major changes in bbdb 3.x that
  need to be taken into account.  The first is that bbdb-split
  reverses the order of its parameters in 3.x. The second is that
  bbdb-record-getprop is replaced by bbdb-record-note in 3.x.
---
 lisp/org-bbdb.el |   18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/lisp/org-bbdb.el b/lisp/org-bbdb.el
index ef53a35..f320d56 100644
--- a/lisp/org-bbdb.el
+++ b/lisp/org-bbdb.el
@@ -273,7 +273,7 @@ italicized, in all other cases it is left unchanged."
   "Convert YYYY-MM-DD to (month date year).
 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 "-"))
+  (multiple-value-bind (a b c) (values-list (org-split-string time-str "-"))
     (if (eq c nil)
         (list (string-to-number a)
               (string-to-number b)
@@ -300,13 +300,19 @@ The hash table is created on first use.")
 (defun org-bbdb-make-anniv-hash ()
   "Create a hash with anniversaries extracted from BBDB, for fast access.
 The anniversaries are assumed to be stored `org-bbdb-anniversary-field'."
-
-  (let (split tmp annivs)
+  (let ((old-bbdb (fboundp 'bbdb-record-getprop))
+	split tmp annivs)
     (clrhash org-bbdb-anniv-hash)
     (dolist (rec (bbdb-records))
-      (when (setq annivs (bbdb-record-getprop
-                          rec org-bbdb-anniversary-field))
-        (setq annivs (bbdb-split annivs "\n"))
+      (when (setq annivs (if old-bbdb
+			     (bbdb-record-getprop
+			      rec org-bbdb-anniversary-field)
+			   (bbdb-record-note
+			    rec org-bbdb-anniversary-field)))
+        (setq annivs (if old-bbdb
+			 (bbdb-split annivs "\n")
+		       ;; parameter order is reversed in new bbdb
+		       (bbdb-split "\n" annivs)))
         (while annivs
           (setq split (org-bbdb-anniv-split (pop annivs)))
           (multiple-value-bind (m d y)
-- 
1.7.10

             reply	other threads:[~2012-04-07 12:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-07 12:21 Matt Lundin [this message]
2012-04-09 10:53 ` [PATCH] Fix org-bbdb anniversaries to work with the new BBDB Bastien

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=87bon3raqo.fsf@fastmail.fm \
    --to=mdl@imapmail.org \
    --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).