[mew-int 00426] Re: Filing outgoing messages automatically

David A. Panariti davep at example.com
Tue Aug 28 08:18:35 JST 2001


Rueben,

Here's some code I posted a while ago to do what you want.
I don't know how to have mew do this without the added code.
But I had most of it left over from my mhe setup.
It uses the same rules to file outgoing mail as the `o' command would
in summary mode, with one difference: it only uses the
mew-refile-guess-alist instead of all of the other guess methods,
since I preferred a single default (+sent_mail) vs the other guesses
mew produced.
You may be able to change the code around the call to 
mew-refile-guess-by-alist to make it use mew-refile-guess, but I am
not too familiar with that function.  From a quick glance, it looks
like you'd need to post-process the output in order to make it
suitable for the call to dp-replace-fcc, which expects a string with
all of the fcc folders in it.

-davep

----

Here is the code.  I've grabbed the code from various elisp files,
so let me know if I've missed anything.

Enjoy.

(defvar dp-mail-header-terminator "^--------$"
  "RE to find end of mail headers.")

(defun dp-replace-fcc (fcc-val hdr-terminator)
  "Replace or add an fcc header."
  (save-excursion
    (goto-char (point-min))
    (if (re-search-forward "^[fF]cc:.*$" nil t)
	(replace-match (concat "Fcc: " fcc-val))
      (if (re-search-forward hdr-terminator nil t)
	  (progn
	    (beginning-of-line)
	    (insert (concat "Fcc: " fcc-val "\n")))
	(message "Cannot find Fcc: field or header delimitter.")))))

(defun dp-mew-send-hook ()
  "Send hook.  Compute destination fcc folder by guessing with
mew-refile-guess-by-alist."
  (interactive)
  ;; may want to use mew-refile-guess here
  (let ((fcc-list (or (mew-refile-guess-by-alist) '("+sent_mail")))
	fcc-val)
    (setq fcc-val (mapconcat (function identity) fcc-list ", "))
    (dp-replace-fcc fcc-val dp-mail-header-terminator)))

;; Set a hook like so:
(add-hook 'mew-send-hook 'dp-mew-send-hook)



More information about the Mew-int mailing list