At Thu, 02 Apr 2009 14:45:30 +0900,
Randy Bush wrote:
>
> for an mua, i use wanderlust under emacs and use bbdb as the address
> book maintainer.
>
> bbdb views
> "Bob Jones" <[email protected]>
> as different from
> "'Bob Jones'" <[email protected]>
> and asks me if i want to add/aka, which is annoying.
>
> is there an option or hack where bbdb recognizes the over-quoting and
> ignores it?
I use something like the following for normalizing the names:
(defun my-bbdb-canonicalize-name-hook (name)
"Function used to canonicalize the full names of bbdb entries."
;; (message (format "canonicalize name %s" name))
(cond
;; strip extra quotes (Some MS mailer likes "'full name'")
((string-match "\\`[`'\"]\\(.*\\)[`'\"]\\'" name)
(bbdb-match-substring name 1))
;; replace multiple whitespace with single
((string-match "[ \f\t\n\r\v]\\{2,\\}" name)
(replace-match " " nil t name))
;; remove anything in round brackets, e.g.: "Firstname Surname (E-mail)"
((string-match "[ ]+(.*)" name)
(replace-match "" nil t name))
;; strip leading whitespace (this is a bug in std11 libs?)
((string-match "\\`[ \t]+\\(.*\\)" name)
(bbdb-match-substring name 1))
;; strip trailing whitespace
((string-match "\\(.*\\)[ ]+\\'" name)
(bbdb-match-substring name 1))
;; strip Dr pronoun
((string-match "\\`Dr\\.? \\(.*\\)" name)
(bbdb-match-substring name 1))
;; person and person -> person & person
((string-match "\\`\\(\\w+\\) and \\(\\w.+\\)\\'" name)
(concat (bbdb-match-substring name 1) " & " (bbdb-match-substring name 2)))
;; Surname, Firstname -> Firstname Surname
((string-match "\\`\\(\\w.+\\), \\(\\w.+\\)\\'" name)
(concat (bbdb-match-substring name 2) " " (bbdb-match-substring name 1)))
;; Sometimes get an email address in the name part. Map the username to a
name: <n...@domain> -> Name
((string-match "\\`<\\(.*\\)@.*\\'" name)
(bbdb-match-substring name 1))
;; replace name without any whitespace with empty; I don't want bbdb names
containing only a single name
((string-match "\\`\\(\\w+\\)\\'" name)
;;(message (format "Eliding name %s" name))
"")
(t name)))
That one is hooked in to bbdb-canonicalize-net-hook via customize.
For email address normalization I use:
(defun my-bbdb-canonicalize-address-hook (name)
"Function used to canonicalize the email address of bbdb entries."
;(message (format "canonicalize address %s" name))
(cond
;; strip extra quotes (Some MS mailer likes "'full name'")
((string-match "\\`[`'\"<]\\(.*\\)[`'\">]\\'" name)
(bbdb-match-substring name 1))
;; strip leading whitespace (this is a bug in std11 libs?)
((string-match "\\`[ \t]+\\(.*\\)" name)
(bbdb-match-substring name 1))
;; Surname, Firstname -> Firstname Surname
((string-match "\\`\\(\\w+\\), \\(\\w.+\\)\\'" name)
(concat (bbdb-match-substring name 2) " " (bbdb-match-substring name 1)))
;; strip trailing whitespace
((string-match "\\(.*\\)[ ]+\\'" name)
(bbdb-match-substring name 1))
(t name)))
;; make bbdb-wl-canonicalize-full-name-function behave like
bbdb-canonicalize-net-hook. (much more useful, imo)
(defun my-bbdb-canonicalize-name (name)
(when name ;name is sometimes nil?
(while (not (eq name (setq name (my-bbdb-canonicalize-name-hook name))))
;;(insert-string (concat name "\n"))
))
name)
(setq bbdb-wl-canonicalize-full-name-function 'my-bbdb-canonicalize-name)
I don't remember whether these were pilfered off mailing lists or copy
pasta from bbdb/wl source. Feel free to use/modify as you need.
Cheers,
Len.
------------------------------------------------------------------------------
_______________________________________________
[email protected]
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/