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

More Emacs goodness: Refresh your memory when you e-mail using notes from BBDB

Inspired by an e-mail-based customer relationship management system briefly described by Daniel Charles of digital ketchup at Shoeless Joe’s last Friday, I decided to hack together a system that would allow me to see the notes from my contact database (aptly named the Big Brother Database, or BBDB) when I write e-mail using the Gnus mail client in Emacs.

The first thing I needed to build, of course, was something that
removed my notes from outgoing messages. People really don’t need to
see the kinds of notes I keep on them. ;) Well, they’re fairly
innocuous notes: how we met and what they’re interested in, usually,
although sometimes I’ll have notes on people’s food preferences or
shoe sizes. I’ve recently started keeping track of the subjects of
e-mail I send them, too.

(defun sacha/gnus-remove-notes ()
  "Remove everything from --- NOTES --- to the signature."
  (goto-char (point-min))
  (when (re-search-forward "^--- NOTES ---" nil t)
    (let ((start (match-beginning 0))
          (end (and (re-search-forward "^--- END NOTES ---") (match-end 0))))
      (delete-region start end))))
(add-hook 'message-send-hook 'sacha/gnus-remove-notes)

Then it was easy to write another function that composed individual
messages to all the people currently displayed in the BBDB buffer,
adding notes to each message.

(defun sacha/gnus-send-message-to-all (subject)
  "Compose message to everyone, with notes."
  (interactive "MSubject: ")
  (let ((records bbdb-records))
    (while records
      (when (bbdb-record-net (caar records))
        (bbdb-send-mail (caar records) subject)
        (when (bbdb-record-notes (caar records))
          (save-excursion
            (insert "\n--- NOTES ---\n"
                    (bbdb-record-notes (caar records))
                    "\n--- END NOTES ---\n"))))
      (setq records (cdr records)))))

I use BBDB to display only the people I want to e-mail, then I call
M-x sacha/gnus-send-message-to-all and specify a message subject. This
creates a gazillion message buffers which I can then edit. If I feel
particularly paranoid, I can remove the notes section myself with C-c
C-z (message-kill-to-signature), but sacha/gnus-remove-notes does it
as long as it’s in message-send-hook.

This code works particularly well with these other customizations:

It supersedes More Emacs fun: Composing mail to everyone with notes.

On Technorati: , , , , ,

../emacs/dotgnus.el

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

On This Day...

  • 2012: International cooking — I was thinking about going to the Canadian National Exhibition to watch the airshow with friends and check out the [...]
  • 2011: Notes on transcription with and without a foot pedal — I finally sat down and transcribed the interview on discovering yourself through blogging, where Holly Tse puts up with my [...]
  • 2010: Book: Leading Outside the Lines — I want to get really good at being a fast zebra. The metaphor comes from Leading Outside the Lines, Jon [...]
  • 2008: Squee! Won Slideshare’s Best Presentation Contest! — My introduction-in-verse won the Slideshare Best Presentation Contest Category for “About Me”! Which probably means that at some point, I [...]
  • 2006: Wanted: real-time calendaring for get-togethers — My social calendar tends to stay relatively full. I have to consciously schedule breaks into it because otherwise I just pack [...]
  • 2006: A passion for social systems – clues to my next short-term step? — Each day brings an opportunity for me to reaffirm my decision that connecting with people is important to me and that [...]
  • 2006: Free Software and Open Source Symposium, Toronto, Oct 26-27 — Via Kelly Drahzal: there’ll be a Free Software and Open Source Symposium in Toronto from Oct 26 to 27. Admission [...]
  • 2006: Networking tips: Bring your own nametag — I bought myself a pack of inkjet/laser self-adhesive name tags, which turned out to be a remarkably good idea. Before heading [...]
  • 2005: Teaching Carnival — Check out the Teaching Carnival for excellent blog posts about education. Good stuff! Picked up the link from Marcia Hansen’s blog. [...]
  • 2005: Penguin powwow — We, the Penguins of Sacha Chua, are delighted to welcome four additions to the Penguin Circle. Penguin powwow Candle-penguin tried its best [...]
  • 2005: Waaaaaaaaaaaaaaaaaaahoooooooooooo! Published! — Bob Erb wrote: Reading Linux Journal at work today, I get to the article about todo lists, browsing through it, getting [...]
  • 2005: Book notes: Life Matters — Title Life Matters Authors A. Roger Merrill, Rebecca R. Merrill I totally, totally, totally like this book. It’s just _packed_ with gems. A few pages [...]
  • 2005: Book notes: Rules for the Road — Title Rules for the Road Author Eve Luppert ISBN 0-399-52411-8 Luppert’s guide to surviving an entry-level job is a good read for fresh graduates who need tips [...]
  • 2005: Book notes: Financial Freedom on $5 a Day — Title Financial Freedom on $5 a Day Author Chuck Chakrapani ISBN 0-88908-952-3 Like most personal finance books, Financial Freedom on $5 a Day suggests a regular savings [...]
  • 2004: Reply from Mom — For your info, the two Perla bars are real laundry SOAP - not detergent. They would be less convenient to [...]
  • 2003: Communication problems — I talked to 1 today because he and 2 aren’t getting along very well and I feel that something must be [...]
  • 2003: Array review — cs21a, education — Drew from ACM problems today – used a simplified Lights Out! for their array game tomorrow.
  • 2003: Open content textbooks — http://textbook.wikipedia.org/
  • 2003: Created WearableComputingPlans — WearableComputing contains the general public stuff. =)
  • 2003: More about life, the universe, and everything — Jerome seems to have been rather busy. He was here just yesterday, (errata: Saturday, it turns out, so things aren’t that [...]
  • 2003: What “Finding Nemo” Character Are You? — What Finding Nemo Character are You? brought to you by Quizilla
  • 2003: Mozilla Firebird — - http://www.mozillatips.com/ - What’s “Caret Browsing”?
  • 2003: Disabling automatic typeahead find — // If you set this pret to true, typing can automatically start Find As You Type. // If false (default), you [...]
  • 2003: Message IDs on Mom’s mail — For some reason, the internal IP address is getting out. I thought Eudora was supposed to automatically handle that…
  • 2003: Migrating from Solaris to Linux — Dominique Cimafranca links to http://www.techonline.com/community/26599
  • 2003: programming kata — Miguel Paraz said: No surprise. About your journal entry for today, I think this is applicable: http://pragprog.com/pragdave/Practices/Kata/KataThirteen.rdoc,v I’m currently practicing the Katas [...]
  • 2003: Poetry — Rainy days invite one to slumber. If the sun does not wake, why should I? So it happens this morn in September: *I* [...]

Get the highlights as a PDF!

Stories from my Twenties: Highlights from a Decade of Blogging

Free sample!