emacs-devel
[Top][All Lists]
Advanced

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

improve rmail's MIME handling


From: Kenichi Handa
Subject: improve rmail's MIME handling
Date: Fri, 12 Nov 2010 21:28:07 +0900

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
address@hidden


2010-11-11  Kenichi Handa  <address@hidden>

        * 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")))




reply via email to

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