6098 comments
2357 subscribers
6256 on Twitter
Subscribe! Feed reader E-mail

Contact report

I started tracking e-mail sent on 2006.09.01 with a
nifty piece of Emacs Lisp code I wrote just for the
purpose. Now I have two months of interesting data which include not
only e-mail but also the occasional in-person contact or phone call
that I remember to note. It’s not complete – e-mail’s the only thing
that gets automatically tracked – but it does give me interesting
information. Here’s the contact report for your amusement:

Contact report

It’s sorted by overall frequency and then by regular frequency.
Warning! Parentheses follow.

(defun sacha/count-matches (regexp string)
  (let ((count 0)
        (start 0))
    (while (string-match regexp string start)
      (setq start (match-end 0)
            count (1+ count)))
    count))

(defun sacha/bbdb-contact-report-as-alist (&rest regexps)
  "Creates a list of (name count-regexp1 count-regexp2 count-regexp3)..."
  (setq regexps (reverse regexps))
  (delq nil
        (mapcar
         (lambda (rec)
           (when (bbdb-record-name (car rec))
             (let ((reg regexps)
                   (notes (bbdb-record-notes (car rec)))
                   list)
               (while reg
                 (setq list (cons (sacha/count-matches (car reg) notes)
                                  list))
                 (setq reg (cdr reg)))
               (cons (sacha/planner-bbdb-annotation-from-bbdb rec)
                     list))))
         bbdb-records)))

(defun sacha/bbdb-alist-sort-by-total (alist)
  "Sort ALIST by total contact."
  (sort alist 'sacha/bbdb-contact-sort-predicate))

(defun sacha/bbdb-contact-sort-predicate (a b)
  (and a b
       (let ((count-a (apply '+ (cdr a)))
             (count-b (apply '+ (cdr b))))
         (or
          (> count-a count-b)
          (and (= count-a count-b)
               ;; If equal, look at the subtotal of the rest
               (sacha/bbdb-contact-sort-predicate (cdr a) (cdr b)))))))

(defun sacha/bbdb-kill-contact-barchart (alist)
  "Kill a barchart with the contact report for ALIST."
  (kill-new
   (mapconcat
    (lambda (entry)
      (concat
       (car entry)
       " | "
       (mapconcat (lambda (count)
                    (if (= count 0)
                        " "
                      (make-string count ?-)))
                  (cdr entry)
                  " | ")))
    alist
    "\n")))

;; Usage: (sacha/bbdb-kill-contact-barchart
;;         (sacha/bbdb-alist-sort-by-total
;;          (sacha/bbdb-contact-report-as-alist "2006.09" "2006.10")))
;; Then yank (paste) this into another buffer

On Technorati: , , , ,

Random Emacs symbol: standard-display-cyrillic-translit – Command: Display a cyrillic buffer using a transliteration.

Short URL: http://sachachua.com/blog/p/3996

On This Day...

  • 2012: Business experience report: Filing taxes! — I filed my corporate taxes and HST today, well ahead of the deadlines. The money will earn negligible interest in [...]
  • 2011: Planning an Emacs-based personal wiki – Org? Muse? Hmm… — I miss my Planner wiki! I think it’s time to organize things into a personal wiki again. Blogs are great [...]
  • 2010: Book: Choose to be happily married: How everyday decisions can lead to lasting love — Bonnie Jacobson, PhD., with Alexia Paul 2010 Adams Media, Avon, Massachusetts ISBN 13: 978-1-60550-625-8 The book [...]
  • 2009: Book: Closing the Innovation Gap —   The best talent embodies the five core values and has the right combination of aptitude, skill, judgment, passion, and drive. [...]
  • 2008: Learning languages — My recent trip to Tel Aviv was a good reason to learn a little Hebrew. I listened to the Hebrew [...]
  • 2008: Weekly review: Week ending Nov 2, 2008 — This week was half travel, half catching up. I flew to Tel Aviv for a customer workshop at which I [...]
  • 2006: Learning a foreign language — Another idea for the activity matrix: learning a foreign language. Japanese? Spanish? Maybe Spanish – I know a few people who can [...]
  • 2006: Tweaked blog design — I tweaked my blog design slightly, using a real-life photo instead of my icon and taking a few things off my [...]
  • 2006: In other news… — I’m back on the wagon of tracking every expense. There’s a certain satisfaction in knowing that every cent is accounted for. [...]
  • 2006: Hack Night — A few days ago, I posted a matrix of great ways to spend time. Simon liked the idea, so last night, we [...]
  • 2006: Microsoft evangelism – tempting! — I had hot chocolate and a terrific conversation with John Oxley, director of community evangelism at Microsoft Canada. He told me about [...]
  • 2005: More about teaching — Teaching is the most humbling of experiences. There is nothing like standing there in front of the students and finding yourself [...]
  • 2005: ACM controversy — For the most part, Ateneo handled their first ACM Intercollegiate Programming Competition wonderfully. But there was one thing that perhaps could have [...]
  • 2003: Oooh, Perl is cool — perl -e 'print "*" x 80 . "\n"' I didn’t know about x number…
  • 2003: Intrams and Pisay Curriculum — This rant’s from Julius B. Legaspi III: Thank you for those who sent their comments so far. Rest assured I will try [...]
  • 2001: Playing with planner (linux, emacs) — Today’s been a busy day. I don’t suppose I can get planner to nicely work with all the rest of [...]

Get the highlights as a PDF!

Stories from my Twenties: Highlights from a Decade of Blogging

Free sample!