emacs-pretest-bug
[Top][All Lists]
Advanced

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

Re: mail-mode doesn't encode Subject


From: Kevin Rodgers
Subject: Re: mail-mode doesn't encode Subject
Date: Tue, 28 Nov 2006 10:58:22 -0700
User-agent: Thunderbird 1.5.0.8 (Windows/20061025)

Dan Jacobson wrote:
I note message-mode makes
Subject: =?utf-8?B?5Y+w5Lit5biC6Ieq55Sx6Lev6YKj6bq85aSn?=
whereas mail-mode just puts the raw utf-8 there. Isn't that improper
or something?

Yes.  If the following hook function works for you, perhaps it could be
adapted and called directly from mail-send or sendmail-send-it:

(defun mail-encode-subject-field ()
  "Encode the Subject field according to RFC 2047."
  (save-excursion
    (when (mail-position-on-field "Subject" t)
      (let* ((field-end (point))
             (case-fold-search t)
             (field-beg (progn
                          (re-search-backward "^Subject: [ \t]*")
                          (match-end 0)))
             (subject (buffer-substring field-end field-beg)))
        (when (string-match "[^\000-\177]" subject)
          (delete-region field-beg field-end)
          (goto-char field-beg)
          (insert (rfc2047-encode-string subject)))))))

(add-hook 'mail-send-hook 'mail-encode-subject-field)

--
Kevin





reply via email to

[Prev in Thread] Current Thread [Next in Thread]