6078 comments
2357 subscribers
6211 on Twitter
Subscribe! Feed reader E-mail

BBDB pinging code

I love tweaking Emacs to fit the way I work. Here’s some code to make it easier to keep track of pinged people.

(defun sacha/bbdb-ping-bbdb-record (bbdb-record text &optional date regrind)
  "Adds a note for today to the current BBDB record.
Call with a prefix to specify date."
  (interactive (list (bbdb-current-record t)
                     (read-string "Notes: ")
                     (if current-prefix-arg (planner-read-date) (planner-today))
                     t))
  (bbdb-record-set-notes bbdb-record (concat date ": " text "\n" (bbdb-record-notes bbdb-record)))
  (if regrind
      (save-excursion
        (set-buffer bbdb-buffer-name)
        (bbdb-redisplay-one-record bbdb-record)))
  nil)

(defun sacha/bbdb-gnus-ping (text)
  "Add a ping for authors/recipients of this message.
Call with a prefix to specify a manual note."
  (interactive (list (if current-prefix-arg (read-string "Notes: "))))
  (let* ((from-me-p
          (string-match gnus-ignored-from-addresses
                        (message-fetch-field "From")))
         (bbdb-get-only-first-address-p nil)
         (bbdb-get-addresses-headers
          (list (assoc (if from-me-p 'recipients 'authors) bbdb-get-addresses-headers)))
         (bbdb/gnus-update-records-mode 'annotating)
         (bbdb-message-cache nil)
         (bbdb-user-mail-names nil)
         (gnus-ignored-from-addresses nil)
         records)
    (setq records (bbdb/gnus-update-records t))
    (if records
        (bbdb-display-records records)
      (bbdb-undisplay-records))
    (while records
      (sacha/bbdb-ping-bbdb-record
       (car records)
       (concat
        (if from-me-p "-> " "<- ")
        (or text (message-fetch-field "Subject")))
       (planner-date-to-filename
        (date-to-time (message-fetch-field "Date"))))
      (setq records (cdr records)))
    (setq records (bbdb/gnus-update-records t))
    (if records
        (bbdb-display-records records)
      (bbdb-undisplay-records))))

On Technorati: , ,

/home/sacha/notebook/emacs/bbdb-config.el

Random Japanese sentence: 猫がソファの上に寝ている。 A cat is lying on the sofa.

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

On This Day...

  • 2012: Quantified Awesome: Back to buying our own fruits and vegetables — We decided to skip the community-supported agriculture program this season in order to try buying the vegetables ourselves. Without the [...]
  • 2011: Monthly reviews: April and May 2011 — Time flies! Travel throws me a little off track when it comes to reviewing, but that’s okay – I’m back [...]
  • 2010: Influence map; introspection — My mom asked me to make an influence map. Here’s my first draft: (click for a bigger version) The map is an [...]
  • 2009: Gardening — W- and I took the day off to set up our vegetable plot, with lots of great help from Laura [...]
  • 2007: High school — Reconnecting with old friends—the sudden, arresting realization of the motion of time. And then of course there’s the update—who’s where [...]
  • 2006: Anxiety — Photo by Automatt, licensed under Creative Commons (Attribution) After reading my post about being a girl, one of my closest friends [...]
  • 2006: Blackberries and such — John Sullivan said: You’ve really got to get a comment system working on your blog :) There are a lot of new [...]
  • 2006: David Crow 2.0 — My experience of Toronto has always been that of a vibrant tech life, but everyone tells me that this really [...]
  • 2006: Reading list — Peter Dawson just sent me his knowledge management reading list for the second quarter. What an excellent idea! I should read [...]
  • 2004: Operating systems as anime characters — Mario wrote: Something cute i found. Basically, its a short flash movie intro and ending to a hypothetical anime where the characters [...]
  • 2003: Teaching journal — I promise to keep a teaching journal on this site. At the very least, it will make me reflect, yes? You [...]
  • 2003: Ooooh! =) —   First of all, I want to congratulate you for being 19 and successful in your career. I wish that I can [...]
  • 2003: Direct credit payroll account — - at least ten months contract with the University
  • 2003: sample popping up — (x-popup-menu `((0 0) ,(get-window-with-predicate (lambda (win) t))) (tmm-get-keybind [menu-bar])) keymap prompt (keymap-prompt (cadr (tmm-get-keybind [menu-bar])))
  • 2003: Menu caching — The menu bar does not recalculate which items are enabled every time you look at a menu. This is because the [...]
  • 2003: real-binding — If REAL-BINDING is a symbol and has a non-`nil’ `menu-enable’ property, that property is an expression that controls whether the menu item [...]
  • 2003: yatm hmms — Hmm, I will need to store the menu somewhere, as it changes when I’m in the yatm buffer.

Get the highlights as a PDF!

Stories from my Twenties: Highlights from a Decade of Blogging