From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kenichi Handa Newsgroups: gmane.emacs.devel Subject: improve rmail's MIME handling Date: Fri, 12 Nov 2010 21:28:07 +0900 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1289564906 10455 80.91.229.12 (12 Nov 2010 12:28:26 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 12 Nov 2010 12:28:26 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Nov 12 13:28:22 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PGsju-0007NV-7j for ged-emacs-devel@m.gmane.org; Fri, 12 Nov 2010 13:28:22 +0100 Original-Received: from localhost ([127.0.0.1]:47089 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PGsjt-0004AB-Ok for ged-emacs-devel@m.gmane.org; Fri, 12 Nov 2010 07:28:21 -0500 Original-Received: from [140.186.70.92] (port=52476 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PGsjn-00049t-SV for emacs-devel@gnu.org; Fri, 12 Nov 2010 07:28:16 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PGsjm-00007f-L9 for emacs-devel@gnu.org; Fri, 12 Nov 2010 07:28:15 -0500 Original-Received: from mx1.aist.go.jp ([150.29.246.133]:43731) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PGsjm-00004r-51 for emacs-devel@gnu.org; Fri, 12 Nov 2010 07:28:14 -0500 Original-Received: from rqsmtp2.aist.go.jp (rqsmtp2.aist.go.jp [150.29.254.123]) by mx1.aist.go.jp with ESMTP id oACCS8x7022701 for ; Fri, 12 Nov 2010 21:28:08 +0900 (JST) env-from (handa@m17n.org) Original-Received: from smtp2.aist.go.jp by rqsmtp2.aist.go.jp with ESMTP id oACCS89L024984 for ; Fri, 12 Nov 2010 21:28:08 +0900 (JST) env-from (handa@m17n.org) Original-Received: by smtp2.aist.go.jp with ESMTP id oACCS7Yf025551 for ; Fri, 12 Nov 2010 21:28:07 +0900 (JST) env-from (handa@m17n.org) Original-Received: from handa by etlken with local (Exim 4.71) (envelope-from ) id 1PGsjf-00033W-O5 for emacs-devel@gnu.org; Fri, 12 Nov 2010 21:28:07 +0900 X-detected-operating-system: by eggs.gnu.org: Solaris 9 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:132564 Archived-At: A while ago, I reported that I need various settings to make rmail handle MIME better (i.e. subject decoding/encoding), and showed my settings including some additional functions, but it seems that no one is working on this field. So, I started to work on it. The attached is the first (and easy) patch for summary lines. Nowadays, not handling MIME properly is regarded as a bug, and thus I want to install it for Emacs 23. What do you think? --- Kenichi Handa handa@m17n.org 2010-11-11 Kenichi Handa * mail/rmailsum.el (rmail-header-summary): Handle multiline Subject: field. (rmail-summary-line-decoder): Set the default to rfc2047-decode-string. === modified file 'lisp/mail/rmailsum.el' --- lisp/mail/rmailsum.el 2010-08-29 16:17:13 +0000 +++ lisp/mail/rmailsum.el 2010-11-11 02:33:42 +0000 @@ -364,12 +364,15 @@ (aset rmail-summary-vector (1- msgnum) line)) line)) -(defcustom rmail-summary-line-decoder (function identity) +(require 'rfc2047) + +(defcustom rmail-summary-line-decoder (function rfc2047-decode-string) "Function to decode a Rmail summary line. It receives the summary line for one message as a string and should return the decoded string. -By default, it is `identity', which returns the string unaltered." +By default, it is `rfc2047-decode-string', which decodes MIME-encoded +subject." :type 'function :group 'rmail-summary) @@ -589,10 +592,17 @@ (t (- mch 14)))) (min len (+ lo 25))))))))) (concat (if (re-search-forward "^Subject:" nil t) - (progn (skip-chars-forward " \t") - (buffer-substring (point) - (progn (end-of-line) - (point)))) + (let (pos str) + (skip-chars-forward " \t") + (setq pos (point)) + (forward-line 1) + (setq str (buffer-substring pos (1- (point)))) + (while (looking-at "\\s ") + (setq str (concat str " " + (buffer-substring (match-end 0) + (line-end-position)))) + (forward-line 1)) + str) (re-search-forward "[\n][\n]+" nil t) (buffer-substring (point) (progn (end-of-line) (point)))) "\n")))