Emacs hacks: Snail mail surprise

I like sending snail mail. This Emacs Lisp snippet displays all the
contacts for whom I have addresses, sorted according to country. This
makes it easy for me to, say, jump to all the USA contacts whom I
should mail before heading back over the border.

(defun sacha/bbdb-filter-records-for-address (records)
  "Filter records for addresses."
  (sort
   (delq nil
         (mapcar
          (lambda (rec) (and (bbdb-record-addresses rec) rec))
          records))
   (lambda (a b)
     (string< (bbdb-address-country (car (bbdb-record-addresses a)))
              (bbdb-address-country (car (bbdb-record-addresses b)))))))

;; Do the actual work here
(bbdb-display-records (sacha/bbdb-filter-records-for-address (bbdb-records)))

On Technorati: ,

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>