On Sun Dec 1 2013 Eric Abrahamsen wrote:
> It might be worth looking at the code in org-bbdb.el:
> org-bbdb-make-anniv-hash builds a hash table of all anniversaries in the
> BBDB, which would be a useful starting place. Key is (month date), value
> is ((year record-name anniversary-type) (year record-name
> anniversary-type) etc). Load org-bbdb.el and populate the hash with
> org-bbdb-make-anniv-hash.

There are various possibilities to achieve such a goal in more or
less dirty ways using different hooks, see also GNU Emacs bug#15987.
(I do not see the need to populate a hash table as an intermediate
step, as it requires more coding efforts to keep such a hash table
up to date when BBDB records get modified.)  Yet I wish that, first
of all, diary/calendar would "officially" support such a thing so
that BBDB and org-mode need not hook into diary/calendar in some
dirty ways.

As a general strategy, with the new BBDB I want to avoid trying to
be smarter than the "main Emacs" which BBDB builds upon.  In my
humble opinion, the old BBDB contained too many patches of that
kind.

> Then some setup:
> 
> (add-hook 'calendar-move-hook
>         (lambda ()
>           (maphash (lambda (k v)
>           (calendar-mark-visible-date
>            `(,(car k) ,(cadr k) ,displayed-year)) ; later add custom face
>         org-bbdb-anniv-hash)))
> 
> And then this, a mashup of calendar-cursor-holidays and
> bbdb-anniv-diary-entries:
> 
> (defun bbdb-anniv-cursor-anniv (&optional date)
>   (interactive)
>   (or date (setq date (calendar-cursor-to-date t)))
>   (let* ((date-string (calendar-date-string date))
>        (m (car date))
>        (d (second date))
>        (anniv-list (gethash (list m d) org-bbdb-anniv-hash))
>        leaps msg)
>     ;; leap year handling from bbdb-anniv
>     (when (and (= m 3) (= d 1)
>                (not (null (gethash (list 2 29) org-bbdb-anniv-hash)))
>                (not (calendar-leap-year-p y)))
>       (setq leaps (gethash (list 2 29) org-bbdb-anniv-hash))
>       (mapcar (lambda (l)
>               (push l anniv-list)) leaps))
>     
>     (when anniv-list
>       (setq msg
>           (format "%s:  %s" date-string
>                   (mapconcat
>                    (lambda (a)
>                      (let ((form (cdr (assoc (intern (nth 2 a))
> bbdb-anniv-alist)))
>                            yy text ord)
>                        (setq yy (if (car a) 
>                                    (- (calendar-extract-year date) (car a))
>                                   100)
>                              ord (when (> yy 0) (diary-ordinal-suffix yy))
>                              text (or form
>                                       "unspecified for %n")
>                              text (replace-regexp-in-string "\\`[ \t]+" ""
> text)
>                              text (replace-regexp-in-string "[ \t]+\\'" ""
> text)
>                              text (replace-regexp-in-string "%n" (nth 1 a)
> text))
>                        (if (and yy ord)
>                            (format text yy ord)
>                          text)))
>                    anniv-list ";  ")))
>       
>       (message "%s" msg))))
> 
> (add-hook 'calendar-mode-hook
>         (lambda ()
>           (define-key calendar-mode-map (kbd "b")
>             'bbdb-anniv-cursor-anniv)))
> 
> 
> This is the simplest hack, but obviously we wouldn't want to borrow org
> code, and bbdb-anniv could probably use some refactoring. But it's a
> starting place. Would a separate anniversary hash table be something
> desirable in BBDB itself? Or
> 
> Anyway, food for thought.

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
bbdb-info@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/

Reply via email to