Ever get annoyed that your bbdb database is full of naked addresses?  I've
just written a simple little hook for bbdb-notice-hook that grabs the
username off the network address and uses that as the bbdb-record-name
until you can come up with something better.  Sometimes the username is
quite clear, but just as often it's a number or just an alphanumeric
string, but it seems to be better than nothing.

Here's the hook:

(add-hook 'bbdb-notice-hook
          '(lambda (record)
             ;; if the record-name is empty, grok the username from the 
             ;; bbdb-record-net field (as long as it is not empty too)
             (if (null (bbdb-record-name record))
                 (let ((net (car (bbdb-record-net record))))
                   (if net
                       (let ((username (car (bbdb-split net "@"))))
                         (bbdb-record-set-firstname record username)
                         (bbdb-puthash (downcase (bbdb-record-name record))
                                       record)
                         (message "added \"%s\" as name for \"%s\"" username net)
                         ))))
             ))

Jack Vinson                     [EMAIL PROTECTED]     
The Purple Puddle Eater   and   Captain Jack
"Yo ee oo, we owe.  No we don't, we own."-The Simpson's 21 October 1993 episode

Reply via email to