[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: BBDBv3



At Thu, 22 Aug 2013 05:14:26 -0500,
Daniel E. Doherty wrote:
> All,
> 
> I notice that gnus has implemented support for bbdbv3, but WL has not
> yet.
> 
> I much prefer WL, but I would like to get to the place where all my
> contacts are in sync.  There is an Asynk program that will sync bbdb
> and Google contacts (therefore, my phone contacts), but it only works
> in a degraded form with bbdbv2.
> 
> Any plans to implement bbdb-wl for version 3?

Hi Daniel,

This is not a direct answer to your question, but here is how I
auto-complete in WL using google contacts
(http://julien.danjou.info/projects/emacs-packages#google-contacts)
*and* using mu (http://www.djcbsoftware.nl/code/mu/)

This will prefer a google contact, but if no completion is available,
will complete using contacts returned by mu. You can of course use
only one or the other by changing the value of
completion-at-point-functions.

best, Erik

(require 'google-contacts-message)

(setq google-contacts-message-use-primary nil)

(defun wl-draft-in-address-field ()
  (save-excursion
    (if (not (looking-at std11-field-head-regexp))
        (re-search-backward std11-field-head-regexp nil t))
    (looking-at 
     "^\\(Resent-To\\|To\\|B?Cc\\|Reply-To\\|From\\|Mail-Followup-To\\|Mail-Copies-To\\|Disposition-Notification-To\\|Return-Receipt-To\\):")))

(defun wl-complete-address-via-google-contacts ()
  (if (not (wl-draft-in-address-field))
      nil
      (append (google-contacts-complete-name) '(:exclusive no))))

(defvar wl-mu-contacts
  nil)

(defun wl-mu-get-contacts ()
  (if (null wl-mu-contacts)
      (let* ((contacts-raw (cdr (split-string
                                 (shell-command-to-string "mu cfind --format mutt-ab")
                                 "[\n\r]+")))
             (contacts (mapcar (lambda (raw)
                                 (let* ((s (split-string raw "\t"))
                                        (addr (car s))
                                        (nm (car (cdr s))))
                                   (format "%s <%s>" nm addr)))
                               contacts-raw)))
        (setq wl-mu-contacts contacts)))
  wl-mu-contacts)

(defun wl-complete-address-via-mu (&optional start)
  "Complete the text at START with a contact.
Ie. either 'name <email>' or 'email')."
  (if (not (wl-draft-in-address-field))
      nil
    (let* ((end (point))
           (start
            (or start
                (save-excursion
                  (re-search-backward "\\(\\`\\|[\n:,]\\)[ \t]*")
                  (goto-char (match-end 0))
                  (point)))))
        (list start end (completion-table-case-fold (wl-mu-get-contacts)) :exclusive 'no))))

(add-hook 'wl-mail-setup-hook
          (lambda ()
            (add-to-list 'completion-at-point-functions
                         'wl-complete-address-via-mu)
            (add-to-list 'completion-at-point-functions
                         'wl-complete-address-via-google-contacts)
            (define-key (current-local-map) "\t" 'completion-at-point)))
Sent from my free software system <http://fsf.org/>.