X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=utils%2Fbbdb-wl.el;h=b40e4c24550e6f9da90517214e9be0ba8a68ab12;hb=fb40159a1fc3d4fb1400f8fe3befb1056bc75b8c;hp=10a73e0041ca2dc295049502d3053ce017d93219;hpb=b39b0f98d5876a90ceae2f4507f9d3595e2f3b0a;p=elisp%2Fwanderlust.git diff --git a/utils/bbdb-wl.el b/utils/bbdb-wl.el index 10a73e0..b40e4c2 100644 --- a/utils/bbdb-wl.el +++ b/utils/bbdb-wl.el @@ -33,12 +33,24 @@ (defvar bbdb-wl-folder-regexp nil) (defvar bbdb-wl-ignore-folder-regexp nil) +(defvar bbdb-wl-canonicalize-full-name-function + #'bbdb-wl-canonicalize-spaces-and-dots + "Way to canonicalize full name.") + +(defun bbdb-wl-canonicalize-spaces-and-dots (string) + (while (and string (string-match " +\\|[\f\t\n\r\v]+\\|\\." string)) + (setq string (replace-match " " nil t string))) + (and string (string-match "^ " string) + (setq string (replace-match "" nil t string))) + string) + ;;;###autoload (defun bbdb-wl-setup () (add-hook 'wl-message-redisplay-hook 'bbdb-wl-get-update-record) (add-hook 'wl-summary-exit-hook 'bbdb-wl-hide-bbdb-buffer) (add-hook 'wl-message-window-deleted-hook 'bbdb-wl-hide-bbdb-buffer) (add-hook 'wl-exit-hook 'bbdb-wl-exit) + (add-hook 'wl-save-hook 'bbdb-offer-save) (add-hook 'wl-summary-toggle-disp-off-hook 'bbdb-wl-hide-bbdb-buffer) (add-hook 'wl-summary-toggle-disp-folder-on-hook 'bbdb-wl-hide-bbdb-buffer) (add-hook 'wl-summary-toggle-disp-folder-off-hook 'bbdb-wl-hide-bbdb-buffer) @@ -56,14 +68,9 @@ (lambda () ;;; (local-set-key "\M-\t" 'bbdb-complete-name) (define-key (current-local-map) "\M-\t" 'bbdb-complete-name)))) - ;; BBDB 2.00.06 or earlier: - ;; auto-autoloads.el includes (provide 'bbdb-autoloads) - ;; Don't exist bbdb-autoloads.el - (when (and (not (featurep 'bbdb-autoloads)) - (module-installed-p 'bbdb-autoloads)) - ;; BBDB 2.20: bbdb-autoloads.el NOT includes (provide 'bbdb-autoloads) - (load "bbdb-autoloads")) - + (require 'bbdb) + (bbdb-initialize) + (if (not (boundp 'bbdb-get-addresses-from-headers)) (defvar bbdb-get-addresses-from-headers '("From" "Resent-From" "Reply-To"))) @@ -180,10 +187,11 @@ For BBDB 2.33 or earlier." (eword-decode-string (decode-mime-charset-string fn wl-mime-charset)))) + fn (funcall bbdb-wl-canonicalize-full-name-function fn) ad (std11-address-string structure)) ;; ignore uninteresting addresses, this is kinda gross! (when (or (not (stringp uninteresting-senders)) - (not + (not (or (and fn (string-match uninteresting-senders fn)) (and ad (string-match uninteresting-senders ad))))) @@ -205,7 +213,7 @@ For BBDB 2.34 or later." (let ((headers bbdb-get-addresses-headers) (uninteresting-senders bbdb-user-mail-names) addrlist header structures structure fn ad - header-type header-fields) + header-type header-fields header-content) (while headers (setq header-type (caar headers) header-fields (cdar headers)) @@ -216,7 +224,7 @@ For BBDB 2.34 or later." (std11-unfold-string header-content))) (while (and (setq structure (car structures)) (eq (car structure) 'mailbox)) - (setq fn (std11-full-name-string structure) + (setq fn (std11-full-name-string structure) fn (and fn (with-temp-buffer ; to keep raw buffer unibyte. (elmo-set-buffer-multibyte @@ -224,11 +232,11 @@ For BBDB 2.34 or later." (eword-decode-string (decode-mime-charset-string fn wl-mime-charset)))) + fn (funcall bbdb-wl-canonicalize-full-name-function fn) ad (std11-address-string structure)) - ;; ignore uninteresting addresses, this is kinda gross! (when (or (not (stringp uninteresting-senders)) - (not + (not (or (and fn (string-match uninteresting-senders fn))