Emacs: Show only people whom I haven’t pinged since…

One of the things I want in a contact management system is a quick way to find out who I haven't pinged in a while. The following code filters currently-displayed contacts to show who I might want to get back in touch with. Call it from a *BBDB* window and specify the date (could be 2006.01.01 for annual, -7 for the last seven days, etc.). This works incredibly well with the following hacks:

I should write a small book about how to build a contact management system with Emacs. ;) It's insanely powerful, you know.

(require 'planner)
(require 'bbdb)
(defun sacha/bbdb-show-only-no-contact-since (date)
  "Show only people who haven't been pinged since DATE or at all."
  (interactive (list (planner-read-date)))
  (let ((records bbdb-records)
    (while records
      ;; Find the latest date mentioned in the entry
      (setq notes (or (bbdb-record-notes (caar records)) ""))
      (setq last-match nil omit nil)
      (while (string-match
              (or last-match 0))
        (unless (string> date (match-string 0 notes))
          (setq omit t)
          (setq last-match (length notes)))
        (setq last-match (match-end 0)))
      (unless (and last-match omit)
        (add-to-list 'new-records (caar records) t))
      (setq records (cdr records)))
    (bbdb-display-records new-records)))

One of the other things I'd like to smooth over is keeping track of who owes whom e-mail... <laugh>

On Technorati: , , , , , ,