I've been needing these forever and I can't believe it's taken me so long
to spend the 20 minutes to write them.


If you don't have insert-hooks, my hook-advice.el is at the end and
implements in with defadvice.  So give somebody an `auto-fcc' property, and
when you send them mail it will automatically be fcc'd to that folder.
This works in general with sendmail, but it is a little vm-centric (uses
vm-folder-directory).

(insert-hooks 'bbdb-mail-abbrev-expand-hook nil
              'after-bbdb-mail-abbrev-expand-hook)
(add-hook 'after-bbdb-mail-abbrev-expand-hook 'bbdb-auto-fcc)
(defun bbdb-auto-fcc ()
  (mapcar (lambda (net)
            (let ((folder (bbdb-record-getprop (bbdb-search-simple nil net)
                                               'auto-fcc)))
              (if folder
                  (mail-fcc (expand-file-name folder vm-folder-directory)))))
          records))

This little piece of advice makes VM look at the `mail-folder' property of
a msg's sender for the default folder for the msg, before vm-auto-folder-alist.

(defadvice vm-auto-select-folder (around bbdb-auto-select activate compile)
  "If the message sender's BBDB entry has a `mail-folder' property, use that."
  (let* ((record (bbdb/vm-update-record t))
         (folder (and record (bbdb-record-getprop record 'mail-folder))))
    (if folder
        (setq ad-return-value (expand-file-name folder vm-folder-directory))
      ;; ad-do-it is the original body of vm-auto-select-folder.
      ad-do-it)))

Reply via email to