diff -uNrb mutt-1.4.2.1.orig/Makefile.in mutt-1.4.2.1/Makefile.in
--- mutt-1.4.2.1.orig/Makefile.in	Thu Feb 12 17:52:26 2004
+++ mutt-1.4.2.1/Makefile.in	Thu Feb 12 21:04:57 2004
@@ -10,6 +10,7 @@
 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 # PARTICULAR PURPOSE.
 
+# This line is a dummy to adjust timestamp.
 
 SHELL = @SHELL@
 
diff -uNrb mutt-1.4.2.1.orig/acconfig.h mutt-1.4.2.1/acconfig.h
--- mutt-1.4.2.1.orig/acconfig.h	Wed Jan 16 07:08:12 2002
+++ mutt-1.4.2.1/acconfig.h	Thu Feb 12 21:04:57 2004
@@ -55,3 +55,5 @@
  * all return values other than (size_t)(-1) as equivalent. */
 #undef ICONV_NONTRANS
 
+/* Define if you use Japanese setting as default. */
+#undef DEFAULT_JAPANESE
diff -uNrb mutt-1.4.2.1.orig/aclocal.m4 mutt-1.4.2.1/aclocal.m4
--- mutt-1.4.2.1.orig/aclocal.m4	Thu Feb 12 17:51:54 2004
+++ mutt-1.4.2.1/aclocal.m4	Thu Feb 12 21:04:57 2004
@@ -12,6 +12,8 @@
 
 # Like AC_CONFIG_HEADER, but automatically create stamp file.
 
+# This line is a dummy to adjust timestamp.
+
 AC_DEFUN([AM_CONFIG_HEADER],
 [AC_PREREQ([2.12])
 AC_CONFIG_HEADER([$1])
diff -uNrb mutt-1.4.2.1.orig/charset.c mutt-1.4.2.1/charset.c
--- mutt-1.4.2.1.orig/charset.c	Sat Jun  1 01:59:39 2002
+++ mutt-1.4.2.1/charset.c	Thu Feb 12 22:30:09 2004
@@ -414,6 +414,9 @@
   if (!s || !*s)
     return 0;
 
+  if (option (OPTSANITIZEJACHARS) && !ascii_strncasecmp (from, "iso-2022-jp", 11))
+    mutt_sanitize_ja_chars (s, mutt_strlen(s), 0);
+
   if (to && from && (cd = mutt_iconv_open (to, from, flags)) != (iconv_t)-1)
   {
     int len;
@@ -560,3 +563,273 @@
     iconv_close (fc->cd);
   safe_free ((void **) _fc);
 }
+
+/*
+ * mutt_sanitize_ja_chars() 
+ *   Adapted by TAKIZAWA Takashi <taki@cyber.email.ne.jp>
+ *
+ * - It replaces undefined KANJI characters to GETA mark.
+ * - It replaces character of 'JIS X 0201 kana' to '?'.
+ * - If $charset is EUC-JP, it replaces third character 'J' of 
+ *   escape sequence switching to 'JIS X 0201 latin' to 'B' indicating
+ *   'US-ASCII'.
+ * - If $charset is Shift_JIS, it replaces third character 'B' of 
+ *   escape sequence switching to 'US-ASCII' to 'J' indicating
+ *   'JIS X 0201 latin'.
+ */
+
+#define ASCII 0
+#define JISX0201LATIN 1
+#define JISX0201KANA 2
+#define JISX0208 3
+#define OTHER_CS 4
+
+void mutt_sanitize_ja_chars(char *s, size_t len, int keep_state)
+{
+  static int cs = ASCII;
+  static int kanji_cont = 0;
+  static int illegal_kanji = 0;
+  static int es = 0;
+  static char pes = '\0';
+  static char ascii_3rd_char = 'B';
+  static char jisx0201_3rd_char = 'J';
+
+  char *p = s;
+  char *p1 = NULL;
+  unsigned char c;
+
+  if (!keep_state || *p == 0x1b) /* consideration about mbstate's buffer */
+  {
+    if (!ascii_strcasecmp (Charset, "euc-jp"))
+      jisx0201_3rd_char = 'B';
+    else if (!ascii_strcasecmp (Charset, "shift_jis"))
+      ascii_3rd_char = 'J';
+    cs = ASCII;
+    kanji_cont = 0;
+    illegal_kanji = 0;
+    es = 0;
+    pes = '\0';
+  }
+  
+  for (;p - s < len;p++)
+  {
+    if (es == 0)
+    {
+      if (*p == 0x1b)
+	es++;
+      else
+      {
+	switch (cs)
+	{
+	case ASCII:
+	case JISX0201LATIN:
+	  break;
+	case JISX0201KANA:
+	  *p = '?';
+	  break;
+	case JISX0208:
+	  /* replace ku-ten code from 9 to 15 and 85 or more to "GETA MARK" */
+	  c = (unsigned char)*p;
+	  if (! kanji_cont)
+	  {
+	    if ((size_t)(p - s + 1) == len)
+	      return; /* the last character is a primary byte of KANJI */
+	    if (c <= 0x20 || (c >= 0x29 && c <= 0x2f) 
+		|| (c >= 0x75 && c <= 0xa0))
+	      illegal_kanji = 1;
+	    kanji_cont = 1;
+	    p1 = p;
+	  }
+	  else
+	  {
+	    if (c <= 0x20 || c >= 0x7f)
+	      illegal_kanji = 1;
+	    if (illegal_kanji && p1)
+	      *p1 = 0x22, *p = 0x2e;
+	    kanji_cont = 0;
+	    illegal_kanji = 0;
+	  }
+	  break;
+	}
+      }
+    }
+    else if (es == 1)
+    {
+      if (*p == '$' || (*p >= '(' && *p <= '/' && *p != ','))
+      {
+	es++;
+	pes = *p;
+      }
+      else
+      {
+	es = 0;
+	return; /* broken */
+      }
+    }
+    else if (es == 2)
+    {
+      if (pes == '(')
+      {
+	switch (*p)
+	{
+	case 'B':
+	  cs = ASCII, *p = ascii_3rd_char;
+	  break;
+	case 'J':
+	  cs = JISX0201LATIN, *p = jisx0201_3rd_char;
+	  break;
+	case 'I':
+	  /* ready to replace character to '?' */
+	  cs = JISX0201KANA, *p = ascii_3rd_char;
+	  break;
+	default:
+	  cs = OTHER_CS;
+	}
+	es = 0;
+      }
+      else if (pes == '$')
+      {
+	switch (*p)
+	{
+	case '@': /* JIS X 0208-1978 */
+	case 'B': /* JIS X 0208-1983 */
+	  cs = JISX0208;
+	  es = 0;
+	  break;
+	case 'A':
+	  cs = OTHER_CS; /* GB 2312 */
+	  es = 0;
+	  break;
+	case '(':
+	case ')':
+	case '*':
+	case '+':
+	case '-':
+	case '.':
+	case '/':
+	  es++;
+	  break;
+	default:
+	  es = 0;
+	  return; /* broken */
+	}
+      }
+      else
+      {
+	cs = OTHER_CS;
+	es = 0;
+      }
+    }
+    else /* es == 3 */
+    {
+      cs = OTHER_CS;
+      es = 0;
+    }
+  }
+}
+
+char *mutt_get_first_charset (const char *charset)
+{
+  static char fcharset[SHORT_STRING];
+  const char *c, *c1;
+  
+  c = charset;
+  if (!mutt_strlen(c))
+    return "us-ascii";	  
+  if (!(c1 = strchr (c, ':')))
+    return charset;
+  strfcpy (fcharset, c, c1 - c + 1);
+  return fcharset;
+}
+
+static size_t convert_string (ICONV_CONST char *f, size_t flen,
+			      const char *from, const char *to,
+			      char **t, size_t *tlen)
+{
+  iconv_t cd;
+  char *buf, *ob;
+  size_t obl, n;
+  int e;
+
+  if (option (OPTSANITIZEJACHARS) && !ascii_strncasecmp (from, "iso-2022-jp", 11))
+    mutt_sanitize_ja_chars ((char *) f, flen, 0);
+
+  cd = mutt_iconv_open (to, from, 0);
+  if (cd == (iconv_t)(-1))
+    return (size_t)(-1);
+  obl = 4 * flen + 1;
+  ob = buf = safe_malloc (obl);
+  n = iconv (cd, &f, &flen, &ob, &obl);
+  if (n == (size_t)(-1) || iconv (cd, 0, 0, &ob, &obl) == (size_t)(-1))
+  {
+    e = errno;
+    safe_free ((void **) &buf);
+    iconv_close (cd);
+    errno = e;
+    return (size_t)(-1);
+  }
+  *ob = '\0';
+  
+  *tlen = ob - buf;
+
+  safe_realloc ((void **) &buf, ob - buf + 1);
+  *t = buf;
+  iconv_close (cd);
+
+  return n;
+}
+
+int mutt_convert_nomime_string (char **ps)
+{
+  const char *c, *c1;
+
+  for (c = AssumedCharset; c; c = c1 ? c1 + 1 : 0)
+  {
+    char *u = *ps;
+    char *s;
+    char *fromcode;
+    size_t m, n;
+    size_t ulen = mutt_strlen (*ps);
+    size_t slen;
+
+    if (!u || !*u)
+      return 0;
+
+    c1 = strchr (c, ':');
+    n = c1 ? c1 - c : mutt_strlen (c);
+    if (!n)
+      continue;
+    fromcode = safe_malloc (n + 1);
+    strfcpy (fromcode, c, n + 1);
+    m = convert_string (u, ulen, fromcode, Charset, &s, &slen);
+    safe_free ((void **) &fromcode);
+    if (m != (size_t)(-1))
+    {
+      safe_free ((void **) ps);
+      *ps = s;
+      return 0;
+    }
+  }
+  return -1;
+}
+
+int mutt_copy_bytes_sanitize_ja (FILE *in, FILE *out, size_t size)
+{
+  char buf[2048];
+  size_t chunk;
+
+  mutt_sanitize_ja_chars (NULL, 0, 0);
+  while (size > 0)
+  {
+    chunk = (size > sizeof (buf)) ? sizeof (buf) : size;
+    if ((chunk = fread (buf, 1, chunk, in)) < 1)
+      break;
+    mutt_sanitize_ja_chars (buf, chunk, 1);
+    if (fwrite (buf, 1, chunk, out) != chunk)
+      return (-1);
+    size -= chunk;
+  }
+
+  return 0;
+}
+
diff -uNrb mutt-1.4.2.1.orig/charset.h mutt-1.4.2.1/charset.h
--- mutt-1.4.2.1.orig/charset.h	Sat Jun  1 01:59:39 2002
+++ mutt-1.4.2.1/charset.h	Thu Feb 12 21:04:57 2004
@@ -35,6 +35,10 @@
 #endif
 
 int mutt_convert_string (char **, const char *, const char *, int);
+void mutt_sanitize_ja_chars (char *, size_t, int);
+char *mutt_get_first_charset (const char *);
+int mutt_convert_nomime_string (char **);
+int mutt_copy_bytes_sanitize_ja (FILE *, FILE *, size_t);
 
 iconv_t mutt_iconv_open (const char *, const char *, int);
 size_t mutt_iconv (iconv_t, ICONV_CONST char **, size_t *, char **, size_t *, ICONV_CONST char **, const char *);
diff -uNrb mutt-1.4.2.1.orig/config.h.in mutt-1.4.2.1/config.h.in
--- mutt-1.4.2.1.orig/config.h.in	Wed Feb 11 19:12:17 2004
+++ mutt-1.4.2.1/config.h.in	Thu Feb 12 21:04:57 2004
@@ -517,3 +517,5 @@
  * all return values other than (size_t)(-1) as equivalent. */
 #undef ICONV_NONTRANS
 
+/* Define if you use Japanese setting as default. */
+#undef DEFAULT_JAPANESE
diff -uNrb mutt-1.4.2.1.orig/configure mutt-1.4.2.1/configure
--- mutt-1.4.2.1.orig/configure	Thu Feb 12 17:51:57 2004
+++ mutt-1.4.2.1/configure	Thu Feb 12 21:13:32 2004
@@ -18,6 +18,8 @@
 ac_help="$ac_help
   --with-slang[=DIR]         Use S-Lang instead of ncurses"
 ac_help="$ac_help
+  --with-slanglib[=NAME]     Name of S-Lang library"
+ac_help="$ac_help
   --with-curses=DIR          Where ncurses is installed "
 ac_help="$ac_help
   --with-regex               Use the GNU regex library "
@@ -64,6 +66,8 @@
 ac_help="$ac_help
   --enable-exact-address     Enable regeneration of email addresses"
 ac_help="$ac_help
+  --enable-default-japanese  Enable Japanese setting as default"
+ac_help="$ac_help
   --disable-iconv           Disable iconv support"
 ac_help="$ac_help
   --with-libiconv-prefix=DIR  search for libiconv in DIR/include and DIR/lib"
@@ -2273,14 +2277,28 @@
         MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS resize.o"
 
         
-        echo $ac_n "checking for SLtt_get_terminfo in -lslang""... $ac_c" 1>&6
-echo "configure:2278: checking for SLtt_get_terminfo in -lslang" >&5
-ac_lib_var=`echo slang'_'SLtt_get_terminfo | sed 'y%./+-%__p_%'`
+        # Check whether --with-slanglib or --without-slanglib was given.
+if test "${with_slanglib+set}" = set; then
+  withval="$with_slanglib"
+  :
+else
+  with_slanglib=yes
+fi
+
+        if test $with_slanglib = yes; then
+                slanglib_name=slang
+        else
+                slanglib_name=$with_slanglib
+        fi
+
+        echo $ac_n "checking for SLtt_get_terminfo in -l$slanglib_name""... $ac_c" 1>&6
+echo "configure:2278: checking for SLtt_get_terminfo in -l$slanglib_name" >&5
+ac_lib_var=`echo $slanglib_name'_'SLtt_get_terminfo | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_save_LIBS="$LIBS"
-LIBS="-lslang -lm $LIBS"
+LIBS="-l$slanglib_name -lm $LIBS"
 cat > conftest.$ac_ext <<EOF
 #line 2286 "configure"
 #include "confdefs.h"
@@ -2308,7 +2326,7 @@
 fi
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  MUTTLIBS="$MUTTLIBS -lslang -lm"
+  MUTTLIBS="$MUTTLIBS -l$slanglib_name -lm"
 else
   echo "$ac_t""no" 1>&6
 { echo "configure: error: unable to compile.  check config.log" 1>&2; exit 1; }
@@ -5776,6 +5794,16 @@
 fi
 
 
+# Check whether --enable-default-japanese or --disable-default-japanese was given.
+if test "${enable_default_japanese+set}" = set; then
+  enableval="$enable_default_japanese"
+  if test $enableval = yes; then
+                cat >> confdefs.h <<\EOF
+#define DEFAULT_JAPANESE 1
+EOF
+
+        fi
+fi
 
 
 
diff -uNrb mutt-1.4.2.1.orig/configure.in mutt-1.4.2.1/configure.in
--- mutt-1.4.2.1.orig/configure.in	Thu Feb 12 17:51:53 2004
+++ mutt-1.4.2.1/configure.in	Thu Feb 12 21:14:06 2004
@@ -162,10 +162,21 @@
         AC_DEFINE(HAVE_COLOR,1,[ Define if your curses library supports color. ])
         MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS resize.o"
 
+        dnl --- Check name of S-Lang library
+
+        AC_ARG_WITH(slanglib,
+                [  --with-slanglib[=NAME]     Name of S-Lang library], ,
+                with_slanglib=yes)
+        if test $with_slanglib = yes; then
+                slanglib_name=slang
+        else
+                slanglib_name=$with_slanglib
+        fi
+
         dnl --- now that we've found it, check the link
 
-        AC_CHECK_LIB(slang, SLtt_get_terminfo,
-                [MUTTLIBS="$MUTTLIBS -lslang -lm"],
+        AC_CHECK_LIB($slanglib_name, SLtt_get_terminfo,
+                [MUTTLIBS="$MUTTLIBS -l$slanglib_name -lm"],
                 [AC_MSG_ERROR(unable to compile.  check config.log)], -lm)
 
         ],
@@ -660,6 +671,11 @@
                 AC_DEFINE(EXACT_ADDRESS)
         fi])
 
+AC_ARG_ENABLE(default-japanese, [  --enable-default-japanese  Enable Japanese setting as default],
+        [if test $enableval = yes; then
+                AC_DEFINE(DEFAULT_JAPANESE)
+        fi])
+
 AC_SUBST(MUTTLIBS)
 AC_SUBST(MUTT_LIB_OBJECTS)
 AC_SUBST(LIBIMAP)
diff -uNrb mutt-1.4.2.1.orig/curs_lib.c mutt-1.4.2.1/curs_lib.c
--- mutt-1.4.2.1.orig/curs_lib.c	Wed Oct 10 21:49:37 2001
+++ mutt-1.4.2.1/curs_lib.c	Thu Feb 12 21:04:58 2004
@@ -135,6 +135,19 @@
     CLEARLINE (LINES-1);
 }
 
+static void fix_end_of_file (const char *data)
+{
+  FILE *fp;
+  int c;
+  
+  if ((fp = safe_fopen (data, "a+")) == NULL)
+    return;
+  fseek (fp,-1,SEEK_END);
+  if ((c = fgetc(fp)) != '\n')
+    fputc ('\n', fp);
+  safe_fclose (&fp);
+}
+
 void mutt_edit_file (const char *editor, const char *data)
 {
   char cmd[LONG_STRING];
@@ -143,6 +156,7 @@
   mutt_expand_file_fmt (cmd, sizeof (cmd), editor, data);
   if (mutt_system (cmd) == -1)
     mutt_error (_("Error running \"%s\"!"), cmd);
+  fix_end_of_file (data);
   keypad (stdscr, TRUE);
   clearok (stdscr, TRUE);
 }
@@ -553,7 +567,7 @@
       wc = replacement_char ();
     }
     if (arboreal && wc < M_TREE_MAX)
-      w = 1; /* hack */
+      w = mutt_mbswidth ((char *)s,1); /* hack */
     else
     {
       if (!IsWPrint (wc))
diff -uNrb mutt-1.4.2.1.orig/globals.h mutt-1.4.2.1/globals.h
--- mutt-1.4.2.1.orig/globals.h	Fri Jan  4 05:57:19 2002
+++ mutt-1.4.2.1/globals.h	Thu Feb 12 21:04:58 2004
@@ -32,6 +32,7 @@
 
 WHERE char *AliasFile;
 WHERE char *AliasFmt;
+WHERE char *AssumedCharset;
 WHERE char *AttachSep;
 WHERE char *Attribution;
 WHERE char *AttachFormat;
@@ -44,6 +45,7 @@
 WHERE char *DsnReturn;
 WHERE char *Editor;
 WHERE char *EscChar;
+WHERE char *FileCharset;
 WHERE char *FolderFormat;
 WHERE char *ForwFmt;
 WHERE char *Fqdn;
@@ -63,6 +65,7 @@
 WHERE char *MailcapPath;
 WHERE char *Maildir;
 WHERE char *MhFlagged;
+WHERE char *MhPath;
 WHERE char *MhReplied;
 WHERE char *MhUnseen;
 WHERE char *MsgFmt;
@@ -100,6 +103,7 @@
 WHERE char *Shell;
 WHERE char *Signature;
 WHERE char *SimpleSearch;
+WHERE char *Spoiler;
 WHERE char *Spoolfile;
 #if defined(USE_SSL) || defined(USE_NSS)
 WHERE char *SslCertFile INITVAL (NULL);
@@ -109,6 +113,20 @@
 WHERE char *Status;
 WHERE char *Tempdir;
 WHERE char *Tochars;
+WHERE char *TreeChars[M_TREE_MAX];
+WHERE char *TreeLLCorner;
+WHERE char *TreeULCorner;
+WHERE char *TreeLTee;
+WHERE char *TreeHLine;
+WHERE char *TreeVLine;
+WHERE char *TreeSpace;
+WHERE char *TreeRArrow;
+WHERE char *TreeStar;
+WHERE char *TreeHidden;
+WHERE char *TreeEquals;
+WHERE char *TreeTTee;
+WHERE char *TreeBTee;
+WHERE char *TreeMissing;
 WHERE char *Username;
 WHERE char *Visual;
 
@@ -157,6 +175,9 @@
 WHERE short ScoreThresholdRead;
 WHERE short ScoreThresholdFlag;
 
+WHERE size_t TreeWidth[M_TREE_MAX];
+WHERE size_t TreeUTF8Width[M_TREE_MAX];
+
 #ifdef USE_IMAP
 WHERE short ImapKeepalive;
 #endif
diff -uNrb mutt-1.4.2.1.orig/handler.c mutt-1.4.2.1/handler.c
--- mutt-1.4.2.1.orig/handler.c	Tue Mar 26 18:49:51 2002
+++ mutt-1.4.2.1/handler.c	Thu Feb 12 21:04:58 2004
@@ -102,6 +102,9 @@
     return;
   }
 
+  if (option (OPTSANITIZEJACHARS) && strchr (bufi, 0x1b))
+      mutt_sanitize_ja_chars (bufi, *l, 1);
+
   ib = bufi, ibl = *l;
   for (;;)
   {
@@ -1498,6 +1501,7 @@
   FILE *fperr = NULL;
   int piped = FALSE;
   pid_t thepid;
+  char *charset;
 
   snprintf (type, sizeof (type), "%s/%s", TYPE (a), a->subtype);
   rfc1524_mailcap_lookup (a, type, entry, M_AUTOVIEW);
@@ -1528,6 +1532,10 @@
       return;
     }
     
+    charset = mutt_get_parameter ("charset", a->parameter);
+    if (charset && option (OPTSANITIZEJACHARS) && !ascii_strncasecmp (charset, "iso-2022-jp", 11))
+      mutt_copy_bytes_sanitize_ja (s->fpin, fpin, a->length);
+    else
     mutt_copy_bytes (s->fpin, fpin, a->length);
 
     if(!piped)
@@ -1711,12 +1719,22 @@
   int istext = mutt_is_text_type (b->type, b->subtype);
   iconv_t cd = (iconv_t)(-1);
 
-  if (istext && s->flags & M_CHARCONV)
+  if (istext)
+  {
+    if(s->flags & M_CHARCONV)
   {
     char *charset = mutt_get_parameter ("charset", b->parameter);
+      if (!option (OPTSTRICTMIME) && !charset)
+        charset = mutt_get_first_charset (AssumedCharset);
     if (charset && Charset)
       cd = mutt_iconv_open (Charset, charset, M_ICONV_HOOK_FROM);
   }
+    else
+    {
+      if (b->file_charset)
+        cd = mutt_iconv_open (Charset, b->file_charset, M_ICONV_HOOK_FROM);
+    }
+  }
 
   fseek (s->fpin, b->offset, 0);
   switch (b->encoding)
diff -uNrb mutt-1.4.2.1.orig/hdrline.c mutt-1.4.2.1/hdrline.c
--- mutt-1.4.2.1.orig/hdrline.c	Mon Mar 25 20:29:32 2002
+++ mutt-1.4.2.1/hdrline.c	Thu Feb 12 21:04:58 2004
@@ -256,6 +256,7 @@
 #define THREAD_NEW (threads && hdr->collapsed && hdr->num_hidden > 1 && mutt_thread_contains_unread (ctx, hdr) == 1)
 #define THREAD_OLD (threads && hdr->collapsed && hdr->num_hidden > 1 && mutt_thread_contains_unread (ctx, hdr) == 2)
   size_t len;
+  char *subj;
 
   hdr = hfi->hdr;
   ctx = hfi->ctx;
@@ -532,11 +533,12 @@
 
     case 's':
       
+      subj = option (OPTDELETEPREFIX) ? hdr->env->real_subj : hdr->env->subject;
       if (flags & M_FORMAT_TREE && !hdr->collapsed)
       {
 	if (flags & M_FORMAT_FORCESUBJ)
 	{
-	  mutt_format_s (dest, destlen, "", NONULL (hdr->env->subject));
+	  mutt_format_s (dest, destlen, "", NONULL (subj));
 	  snprintf (buf2, sizeof (buf2), "%s%s", hdr->tree, dest);
 	  mutt_format_s_tree (dest, destlen, prefix, buf2);
 	}
@@ -544,7 +546,7 @@
 	  mutt_format_s_tree (dest, destlen, prefix, hdr->tree);
       }
       else
-	mutt_format_s (dest, destlen, prefix, NONULL (hdr->env->subject));
+	mutt_format_s (dest, destlen, prefix, NONULL (subj));
       break;
 
     case 'S':
diff -uNrb mutt-1.4.2.1.orig/imap/Makefile.in mutt-1.4.2.1/imap/Makefile.in
--- mutt-1.4.2.1.orig/imap/Makefile.in	Thu Feb 12 17:52:46 2004
+++ mutt-1.4.2.1/imap/Makefile.in	Thu Feb 12 21:04:58 2004
@@ -10,6 +10,7 @@
 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 # PARTICULAR PURPOSE.
 
+# This line is a dummy to adjust timestamp.
 
 SHELL = @SHELL@
 
diff -uNrb mutt-1.4.2.1.orig/init.c mutt-1.4.2.1/init.c
--- mutt-1.4.2.1.orig/init.c	Wed Jul 24 17:41:29 2002
+++ mutt-1.4.2.1/init.c	Thu Feb 12 21:04:58 2004
@@ -20,12 +20,12 @@
 #include "mapping.h"
 #include "mutt_curses.h"
 #include "mutt_regex.h"
+#include "mutt_menu.h"
 #include "history.h"
 #include "keymap.h"
 #include "mbyte.h"
 #include "charset.h"
 
-
 #ifdef HAVE_PGP
 #include "pgp.h"
 #endif
@@ -935,6 +935,8 @@
 	  *((char **) MuttVars[idx].data) = safe_strdup (tmp->data);
 	  if (mutt_strcmp (MuttVars[idx].option, "charset") == 0)
 	    mutt_set_charset (Charset);
+	  if (mutt_strncmp (MuttVars[idx].option, "tree_", 5) == 0)
+	    mutt_set_treechars ();
         }
         else
         {
@@ -1911,6 +1913,11 @@
   FREE (&AliasFile);
   AliasFile = safe_strdup (NONULL(Muttrc));
 
+  strfcpy (buffer, NONULL(MhPath), sizeof (buffer));
+  FREE (&MhPath);
+  mutt_expand_path (buffer, sizeof (buffer));
+  MhPath = safe_strdup (buffer);
+
   /* Process the global rc file if it exists and the user hasn't explicity
      requested not to via "-n".  */
   if (!skip_sys_rc)
@@ -1962,6 +1969,9 @@
       mutt_exit(1);
   }
 
+  mutt_init_treechars ();
+  mutt_set_treechars ();
+
 #if 0
   set_option (OPTWEED); /* turn weeding on by default */
 #endif
diff -uNrb mutt-1.4.2.1.orig/init.h mutt-1.4.2.1/init.h
--- mutt-1.4.2.1.orig/init.h	Wed Jul 24 17:41:29 2002
+++ mutt-1.4.2.1/init.h	Thu Feb 12 21:04:58 2004
@@ -193,6 +193,28 @@
   ** If set, Mutt will prompt you for carbon-copy (Cc) recipients before
   ** editing the body of an outgoing message.
   */  
+#ifdef DEFAULT_JAPANESE
+  { "assumed_charset", DT_STR, R_NONE, UL &AssumedCharset, UL "iso-2022-jp:euc-jp:shift_jis:utf-8"},
+#else
+  { "assumed_charset", DT_STR, R_NONE, UL &AssumedCharset, UL "us-ascii"},
+#endif
+  /*
+  ** .pp
+  ** [mutt-ja]
+  ** This variable is a colon-separated list of character encoding 
+  ** schemes for messages without character encoding indication.
+  ** Header field values and message body content without character encoding 
+  ** indication would be assumed that they are written in one of this list.
+  ** By default, all the header fields and message body without any charset 
+  ** indication are assumed to be in "us-ascii". 
+  ** .pp
+  ** For example, Japanese users might prefer this:
+  ** .pp
+  **   set assumed_charset="iso-2022-jp:euc-jp:shift_jis:utf-8"
+  ** .pp
+  ** However, only the first content is valid for the message body. 
+  ** This variable is valid only if $$strict_mime is unset.
+  */
   { "attach_format",	DT_STR,  R_NONE, UL &AttachFormat, UL "%u%D%I %t%4n %T%.40d%> [%.7m/%.10M, %.6e%?C?, %C?, %s] " },
   /*
   ** .pp
@@ -273,7 +295,11 @@
   ** When this variable is set, mutt will include Delivered-To headers when
   ** bouncing messages.  Postfix users may wish to unset this variable.
   */
+#ifdef DEFAULT_JAPANESE
+  { "charset",  	DT_STR,  R_NONE, UL &Charset, UL "euc-jp" },
+#else
   { "charset",		DT_STR,	 R_NONE, UL &Charset, UL 0 },
+#endif
   /*
   ** .pp
   ** Character set your terminal uses to display and enter textual data.
@@ -346,6 +372,19 @@
   ** will be saved for later references.  Also see ``$$record'',
   ** ``$$save_name'', ``$$force_name'' and ``$fcc-hook''.
   */
+  { "create_rfc2047_parameters", DT_BOOL, R_NONE, OPTCREATERFC2047PARAMS, 0 },
+  /*
+  ** .pp
+  ** [mutt-ja]
+  ** When this variable is set, Mutt will add the following RFC-2047-encoded 
+  ** MIME parameter to Content-Type header field as filename for attachment:
+  ** name="=?iso-2022-jp?B?GyRCO244MxsoQi50eHQ=?="
+  ** .pp 
+  ** Note: this use of RFC 2047's encoding is explicitly prohibited 
+  ** by the standard. You may set this variable only if a mailer
+  ** of recipients can not parse RFC 2231 parameters.
+  ** This variable is valid only if $$strict_mime is unset.
+  */
   { "date_format",	DT_STR,	 R_BOTH, UL &DateFmt, UL "!%a, %b %d, %Y at %I:%M:%S%p %Z" },
   /*
   ** .pp
@@ -396,6 +435,21 @@
   ** If this option is \fIset\fP, mutt's revattach menu will not show the subparts of
   ** individual messages in a digest.  To see these subparts, press 'v' on that menu.
   */
+  { "delete_prefix",	DT_BOOL, R_NONE, OPTDELETEPREFIX, 0 },
+  /*
+  ** .pp
+  ** [mutt-ja]
+  ** If set, prefix in Subject: field generated by some mailing lists 
+  ** (something like "Subject: [foo-ML:0012] real-subject") can be deleted 
+  ** when displaying in index-mode and editing in message reply. 
+  ** Deletion pattern can be configured by $$delete_regexp variable.
+  */
+  { "delete_regexp",	DT_RX,	 R_NONE, UL &DeleteRegexp, UL "^(\\[[A-Za-z0-9_.: \\-]*\\][ ]*)" },
+  /*
+  ** .pp
+  ** [mutt-ja]
+  ** A regular expression used in $$delete_prefix function.
+  */
   { "display_filter",	DT_PATH, R_PAGER, UL &DisplayFilter, UL "" },
   /*
   ** .pp
@@ -446,7 +500,11 @@
   ** that it thinks they are duplicates of each other with an equals sign
   ** in the thread diagram.
   */
+#ifdef DEFAULT_JAPANESE
+  { "edit_headers",	DT_BOOL, R_NONE, OPTEDITHDRS, 1 },
+#else
   { "edit_headers",	DT_BOOL, R_NONE, OPTEDITHDRS, 0 },
+#endif
   /*
   ** .pp
   ** This option allows you to edit the header of your outgoing messages
@@ -509,6 +567,25 @@
   ** unsigned, even when the actual message is encrypted and/or signed.
   */
 #endif
+#ifdef DEFAULT_JAPANESE
+  { "file_charset",	DT_STR,	 R_NONE, UL &FileCharset, UL "iso-2022-jp:euc-jp:shift_jis:utf-8" },
+#else
+  { "file_charset",	DT_STR,	 R_NONE, UL &FileCharset, UL 0 },
+#endif
+  /*
+  ** .pp
+  ** [mutt-ja]
+  ** This variable is a colon-separated list of character encoding 
+  ** schemes for text file attatchments. 
+  ** If unset, $$charset value will be used instead. 
+  ** For example, the following configuration would work for Japanese 
+  ** text handling:
+  ** .pp
+  **   set file_charset="iso-2022-jp:euc-jp:shift_jis:utf-8"
+  ** .pp
+  ** Note: "iso-2022-*" must be put at the head of the value as shown above 
+  ** if included. 
+  */
   { "folder",		DT_PATH, R_NONE, UL &Maildir, UL "~/Mail" },
   /*
   ** .pp
@@ -1040,6 +1117,18 @@
   ** .pp
   ** The name of the MH sequence used for unseen messages.
   */
+  { "mh_path",		DT_PATH, R_NONE, UL &MhPath, 0 },
+  /*
+  ** .pp
+  ** [mutt-ja]
+  **  If set, folder detection routine considers any subdirectory 
+  ** under "mh_path" directory as an MH folder even if no other MH folder marker
+  ** (like "cur" subdirectory for MAILDIR folder, or .mh_sequences for 
+  ** MH folder) is found in this directory AND no subdirectory exists 
+  ** beneath this directory. Useful to decrease "xxx is not a mailbox." 
+  ** error for those who are using some other semi-MH-compatible mailer 
+  ** or dealing with MH folder by one's own shell script.
+  */
   { "mime_forward",	DT_QUAD, R_NONE, OPT_MIMEFWD, M_NO },
   /*
   ** .pp
@@ -1114,6 +1203,20 @@
   { "msg_format",	DT_SYN,  R_NONE, UL "message_format", 0 },
   /*
   */
+  { "msgid",		DT_BOOL, R_NONE, OPTMSGID, 1 },
+  /*
+  ** .pp
+  ** [mutt-ja]
+  ** Mutt will generate Message-ID: field by itself when 
+  ** set(default). Unset to let MTA generate Message-ID: field.
+  */
+  { "msgid_use_from",	DT_BOOL, R_NONE, OPTMSGIDUSEFROM, 1 },
+  /*
+  ** .pp
+  ** [mutt-ja]
+  ** Use $$from value instead of $$hostname for Message-ID: generation.
+  ** Uniqueness of Message-ID: increases (especially for dialup-users).
+  */
   { "pager",		DT_PATH, R_NONE, UL &Pager, UL "builtin" },
   /*
   ** .pp
@@ -1165,6 +1268,34 @@
   ** when you are at the end of a message and invoke the \fInext-page\fP
   ** function.
   */
+  { "pager_hdrs_only",	DT_BOOL, R_NONE, OPTPAGERHDRSONLY, 0 },
+  /*
+  ** .pp
+  ** [mutt-ja]
+  ** Determines whether to display message body immediately. 
+  ** When set, only headers are displayed first, and message body is 
+  ** shown after page scroll or line scroll are done.
+  */
+  { "pager_spoil",	DT_BOOL, R_NONE, OPTPAGERSPOIL, 0 },
+  /*
+  ** .pp
+  ** [mutt-ja]
+  ** Determines the style of $$pager_hdrs_only. 
+  ** When set, message body characters are substituted by the characters 
+  ** by $$pager_spoiler. Empty lines are shown when not set.
+  ** .pp
+  ** Note: When not set, line count of message body is calculated according 
+  ** to the lines of the original message. File atattchments or displaying 
+  ** in a mismatch between the empty-line count and the line count of the 
+  ** message actually displayed.
+  */
+  { "pager_spoiler",	DT_STR,	 R_NONE, UL &Spoiler, UL "*" },
+  /*
+  ** .pp
+  ** [mutt-ja]
+  ** Specify substituting character for $$pager_hdrs_only and 
+  ** $$pager_spoil. (valid only if both are set)
+  */
   
 
 #ifdef HAVE_PGP
@@ -1829,7 +1960,11 @@
   ** possibly including eventual real names.  When it is unset, mutt will
   ** override any such realnames with the setting of the $realname variable.
   */
+#ifdef DEFAULT_JAPANESE
+  { "rfc2047_parameters", DT_BOOL, R_NONE, OPTRFC2047PARAMS, 1 },
+#else
   { "rfc2047_parameters", DT_BOOL, R_NONE, OPTRFC2047PARAMS, 0 },
+#endif
   /*
   ** .pp
   ** When this variable is set, Mutt will decode RFC-2047-encoded MIME 
@@ -1847,6 +1982,33 @@
   ** that mutt \fIgenerates\fP this kind of encoding.  Instead, mutt will
   ** unconditionally use the encoding specified in RFC 2231.
   */
+#ifdef DEFAULT_JAPANESE
+  { "sanitize_ja_chars",	DT_BOOL, R_NONE, OPTSANITIZEJACHARS, 1 },
+#else
+  { "sanitize_ja_chars",	DT_BOOL, R_NONE, OPTSANITIZEJACHARS, 0 },
+#endif
+  /*
+  ** .pp
+  ** [mutt-ja]
+  ** When set, Japanese "platform dependent characters" (illegal 
+  ** characters for iso-2022-jp charset; mainly used by MS-Windows 
+  ** mailers) are substituted to special character, GETA mark ('ESC $$ B " . 
+  ** ESC ( B' in iso-2022-jp), and JIS X 0201 kana characters 
+  ** (only for "ESC ) I" cases) are also substituted to "?" to 
+  ** prevent garbage characters. JIS X 0201 kana characters are 
+  ** not substituted if they appear in 8bit form.
+  ** .pp
+  ** This fixes another Japanese encoding issue. In case $$charset 
+  ** is set to "EUC-JP", which does not contain JIS X 0201 roman 
+  ** character set, the JIS X 0201 roman part of received messages 
+  ** encoded in iso-2022-jp can not be converted to EUC-JP. 
+  ** On the other hand, the ASCII part can not be converted to 
+  ** Shift_JIS, which does not contain ASCII character set. Thus, 
+  ** the converted characters are garbled in these cases. When this 
+  ** option is set, the JIS X 0201 roman escape sequence and the 
+  ** ASCII escape sequence are replaced appropriately to prevent 
+  ** the output from being garbled.
+  */
   { "save_address",	DT_BOOL, R_NONE, OPTSAVEADDRESS, 0 },
   /*
   ** .pp
@@ -1907,7 +2069,11 @@
   ** mutt scores are always greater than or equal to zero, the default setting
   ** of this variable will never mark a message read.
   */
+#ifdef DEFAULT_JAPANESE
+  { "send_charset",	DT_STR,  R_NONE, UL &SendCharset, UL "us-ascii:iso-2022-jp"},
+#else
   { "send_charset",	DT_STR,  R_NONE, UL &SendCharset, UL "us-ascii:iso-8859-1:utf-8" },
+#endif
   /*
   ** .pp
   ** A list of character sets for outgoing messages. Mutt will use the
@@ -2181,6 +2347,24 @@
   ** Setting this variable causes the ``status bar'' to be displayed on
   ** the first line of the screen rather than near the bottom.
   */
+#ifdef DEFAULT_JAPANESE
+  { "strict_mime",    DT_BOOL, R_NONE, OPTSTRICTMIME, 0 },
+#else
+  { "strict_mime",    DT_BOOL, R_NONE, OPTSTRICTMIME, 1 },
+#endif
+  /*
+  ** .pp
+  ** [mutt-ja]
+  ** When unset, non MIME-compliant messages that doesn't have any 
+  ** charset indication in Content-Type: field can be displayed 
+  ** (non MIME-compliant messages are often generated by old mailers 
+  ** or buggy mailers like MS Outlook Express).
+  ** See also $$assumed_charset.
+  ** .pp
+  ** This option also replaces linear-white-space between encoded-word 
+  ** and *text to a single space to prevent the display of MIME-encoded 
+  ** Subject: field from being devided into multiple lines.
+  */
   { "strict_threads",	DT_BOOL, R_RESORT|R_RESORT_INIT|R_INDEX, OPTSTRICTTHREADS, 0 },
   /*
   ** .pp
@@ -2214,7 +2398,11 @@
   ** When set, mutt uses the date received rather than the date sent
   ** to thread messages by subject.
   */
+#ifdef DEFAULT_JAPANESE
+  { "thorough_search",	DT_BOOL, R_NONE, OPTTHOROUGHSRC, 1 },
+#else
   { "thorough_search",	DT_BOOL, R_NONE, OPTTHOROUGHSRC, 0 },
+#endif
   /*
   ** .pp
   ** Affects the \fI~b\fP and \fI~h\fP search operations described in
@@ -2256,6 +2444,100 @@
   ** by \fIyou\fP.  The sixth character is used to indicate when a mail
   ** was sent to a mailing-list you subscribe to (default: L).
   */
+  { "tree_chars",	DT_BOOL, R_BOTH, OPTTREECHARS, 0 },
+  /*
+  ** .pp
+  ** [mutt-ja]
+  ** Many terminals not compatible with vt-100 can't display ACS-characters. 
+  ** This option can set any character for displaying tree structure in 
+  ** index-thread or file-attatchments. 
+  ** For example, Japanese users can use JIS X 0208 ruled line characters 
+  ** for this purpose. The characters actually used are set by 
+  ** $$tree_llcorner, $$tree_ulcorner, $$tree_ltee, $$tree_hline, 
+  ** $$tree_vline, $$tree_ttee, $$tree_btee, $$tree_space, $$tree_rarrow,
+  ** $$tree_star, $$tree_hidden, $$tree_equals and $$tree_missing variables. 
+  ** These values must be written in the same encoding as the $$charset 
+  ** value. When $$tree_chars is not set (default), the characters 
+  ** with $$ascii_chars are used.
+  */
+  { "tree_llcorner",	DT_STR,  R_BOTH, UL &TreeLLCorner, UL "`" },
+  /*
+  ** .pp
+  ** [mutt-ja]
+  ** See ``$$tree_chars''.
+  */
+  { "tree_ulcorner",	DT_STR,  R_BOTH, UL &TreeULCorner, UL "," },
+  /*
+  ** .pp
+  ** [mutt-ja]
+  ** See ``$$tree_chars''.
+  */
+  { "tree_ltee",	DT_STR,  R_BOTH, UL &TreeLTee, UL "|" },
+  /*
+  ** .pp
+  ** [mutt-ja]
+  ** See ``$$tree_chars''.
+  */
+  { "tree_hline",	DT_STR,  R_BOTH, UL &TreeHLine, UL "-" },
+  /*
+  ** .pp
+  ** [mutt-ja]
+  ** See ``$$tree_chars''.
+  */
+  { "tree_vline",	DT_STR,  R_BOTH, UL &TreeVLine, UL "|" },
+  /*
+  ** .pp
+  ** [mutt-ja]
+  ** See ``$$tree_chars''.
+  */
+  { "tree_ttee",	DT_STR,  R_BOTH, UL &TreeTTee, UL "-" },
+  /*
+  ** .pp
+  ** [mutt-ja]
+  ** See ``$$tree_chars''.
+  */
+  { "tree_btee",	DT_STR,  R_BOTH, UL &TreeBTee, UL "-" },
+  /*
+  ** .pp
+  ** [mutt-ja]
+  ** See ``$$tree_chars''.
+  */
+  { "tree_space",	DT_STR,  R_BOTH, UL &TreeSpace, UL " " },
+  /*
+  ** .pp
+  ** [mutt-ja]
+  ** See ``$$tree_chars''.
+  */
+  { "tree_rarrow",	DT_STR,  R_BOTH, UL &TreeRArrow, UL ">" },
+  /*
+  ** .pp
+  ** [mutt-ja]
+  ** See ``$$tree_chars''.
+  */
+  { "tree_star",	DT_STR,  R_BOTH, UL &TreeStar, UL "*" },
+  /*
+  ** .pp
+  ** [mutt-ja]
+  ** See ``$$tree_chars''.
+  */
+  { "tree_hidden",	DT_STR,  R_BOTH, UL &TreeHidden, UL "&" },
+  /*
+  ** .pp
+  ** [mutt-ja]
+  ** See ``$$tree_chars''.
+  */
+  { "tree_equals",	DT_STR,  R_BOTH, UL &TreeEquals, UL "=" },
+  /*
+  ** .pp
+  ** [mutt-ja]
+  ** See ``$$tree_chars''.
+  */
+  { "tree_missing",	DT_STR,  R_BOTH, UL &TreeMissing, UL "?" },
+  /*
+  ** .pp
+  ** [mutt-ja]
+  ** See ``$$tree_chars''.
+  */
 #ifdef USE_SOCKET
   { "tunnel",            DT_STR, R_NONE, UL &Tunnel, UL 0 },
   /*
@@ -2295,6 +2577,18 @@
   ** generated unless the user explicitly sets one using the ``$my_hdr''
   ** command.
   */
+#ifndef HAVE_WC_FUNCS
+#ifdef DEFAULT_JAPANESE
+  { "use_jisx0208",		DT_BOOL, R_NONE, OPTUSEJISX0208, 1 },
+#else
+  { "use_jisx0208",		DT_BOOL, R_NONE, OPTUSEJISX0208, 0 },
+#endif
+  /*
+  ** .pp
+  ** When \fIset\fP, Mutt will decide that Symbols, Greek and Cyrillic 
+  ** in JIS X 0208 have a column width of 2 in UTF-8 locale.
+  */
+#endif
 #ifdef HAVE_GETADDRINFO
   { "use_ipv6",		DT_BOOL, R_NONE, OPTUSEIPV6, 1},
   /*
diff -uNrb mutt-1.4.2.1.orig/m4/Makefile.in mutt-1.4.2.1/m4/Makefile.in
--- mutt-1.4.2.1.orig/m4/Makefile.in	Thu Feb 12 17:52:27 2004
+++ mutt-1.4.2.1/m4/Makefile.in	Thu Feb 12 21:04:58 2004
@@ -10,6 +10,7 @@
 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 # PARTICULAR PURPOSE.
 
+# This line is a dummy to adjust timestamp.
 
 SHELL = @SHELL@
 
diff -uNrb mutt-1.4.2.1.orig/main.c mutt-1.4.2.1/main.c
--- mutt-1.4.2.1.orig/main.c	Tue Jul 16 16:28:00 2002
+++ mutt-1.4.2.1/main.c	Thu Feb 12 21:04:58 2004
@@ -59,6 +59,11 @@
 Lots of others not mentioned here contributed lots of code,\n\
 fixes, and suggestions.\n\
 \n\
+ja patch:\n\
+Copyright (C) 2000-2002 TAKIZAWA Takashi <taki@cyber.email.ne.jp>\n\
+Copyright (C) 2000      Yukinori YOSHIDA <yyo@pjs.nevt.nec.co.jp>\n\
+Copyright (C) 2000      Kawaguti Ginga <ginga@athena.club.ne.jp>\n\
+\n\
     This program is free software; you can redistribute it and/or modify\n\
     it under the terms of the GNU General Public License as published by\n\
     the Free Software Foundation; either version 2 of the License, or\n\
diff -uNrb mutt-1.4.2.1.orig/mbyte.c mutt-1.4.2.1/mbyte.c
--- mutt-1.4.2.1.orig/mbyte.c	Tue Mar 26 18:49:51 2002
+++ mutt-1.4.2.1/mbyte.c	Thu Feb 12 21:04:58 2004
@@ -368,6 +368,12 @@
 	return k;
     }
   }
+  else if (option (OPTUSEJISX0208))
+  {
+    int k = wcwidth_ja (wc);
+    if (k != -1)
+      return k;
+  }
   return wcwidth_ucs (wc);
 }
 
diff -uNrb mutt-1.4.2.1.orig/menu.c mutt-1.4.2.1/menu.c
--- mutt-1.4.2.1.orig/menu.c	Wed Feb 11 19:07:17 2004
+++ mutt-1.4.2.1/menu.c	Thu Feb 12 21:04:58 2004
@@ -30,6 +30,70 @@
 
 extern int Charset_is_utf8; /* FIXME: bad modularisation */
 
+static const char TreeAsciiChars[] = 
+{ 
+  0, /* not used */
+  '`', /* M_TREE_LLCORNER */
+  ',', /* M_TREE_ULCORNER */
+  '|', /* M_TREE_LTEE */
+  '-', /* M_TREE_HLINE */
+  '|', /* M_TREE_VLINE */
+  ' ', /* M_TREE_SPACE */
+  '>', /* M_TREE_RARROW */
+  '*', /* M_TREE_STAR */
+  '&', /* M_TREE_HIDDEN */
+  '=', /* M_TREE_EQUALS */
+  '-', /* M_TREE_TTEE */
+  '-', /* M_TREE_BTEE */
+  '?' /* M_TREE_MISSING */
+};
+
+static const char *TreeUTF8Chars[] = 
+{ 
+  "", /* not used */
+  "\342\224\224", /* WACS_LLCORNER */
+  "\342\224\214", /* WACS_ULCORNER */
+  "\342\224\234", /* WACS_LTEE */
+  "\342\224\200", /* WACS_HLINE */
+  "\342\224\202", /* WACS_VLINE */
+  " ",
+  ">",
+  "*",
+  "&",
+  "=",
+  "\342\224\254", /* WACS_TTEE */
+  "\342\224\264", /* WACS_BTEE */
+  "?"
+};
+
+void mutt_set_treechars ()
+{
+  int i;
+  for (i = 1; i < M_TREE_MAX; i++)
+    TreeWidth[i] = mutt_mbswidth (TreeChars[i], mutt_strlen(TreeChars[i]));
+}
+
+void mutt_init_treechars ()
+{
+  int i;
+  for (i = 1; i < M_TREE_MAX; i++)
+    TreeUTF8Width[i] = mutt_mbswidth ((char *)TreeUTF8Chars[i],
+				      mutt_strlen ((char *)TreeUTF8Chars[i]));
+  TreeChars[M_TREE_LLCORNER] = TreeLLCorner;
+  TreeChars[M_TREE_ULCORNER] = TreeULCorner;
+  TreeChars[M_TREE_LTEE] = TreeLTee;
+  TreeChars[M_TREE_HLINE] = TreeHLine;
+  TreeChars[M_TREE_VLINE] = TreeVLine;
+  TreeChars[M_TREE_SPACE] = TreeSpace;
+  TreeChars[M_TREE_RARROW] = TreeRArrow;
+  TreeChars[M_TREE_STAR] = TreeStar;
+  TreeChars[M_TREE_HIDDEN] = TreeHidden;
+  TreeChars[M_TREE_EQUALS] = TreeEquals;
+  TreeChars[M_TREE_TTEE] = TreeTTee;
+  TreeChars[M_TREE_BTEE] = TreeBTee;
+  TreeChars[M_TREE_MISSING] = TreeMissing;
+}
+
 static void print_enriched_string (int attr, unsigned char *s, int do_color)
 {
   wchar_t wc;
@@ -44,83 +108,52 @@
     {
       if (do_color)
 	SETCOLOR (MT_COLOR_TREE);
+      if (option (OPTTREECHARS))
       while (*s && *s < M_TREE_MAX)
       {
-	switch (*s)
+	  addstr (TreeChars[(int)*s]);
+	  s++, n--;
+	}
+      else if (option (OPTASCIICHARS))
+	while (*s && *s < M_TREE_MAX)
 	{
-	  case M_TREE_LLCORNER:
-	    if (option (OPTASCIICHARS))
-	      addch ('`');
+	  addch (TreeAsciiChars[(int)*s]);
+	  s++, n--;
+	}
 	    else if (Charset_is_utf8)
-	      addstr ("\342\224\224"); /* WACS_LLCORNER */
+	while (*s && *s < M_TREE_MAX)
+	{
+	  addstr ((char *)TreeUTF8Chars[(int)*s]);
+	  s++, n--;
+	}
 	    else
+	while (*s && *s < M_TREE_MAX)
+	{
+	  switch (*s)
+	  {
+	  case M_TREE_LLCORNER:
 	      addch (ACS_LLCORNER);
 	    break;
 	  case M_TREE_ULCORNER:
-	    if (option (OPTASCIICHARS))
-	      addch (',');
-	    else if (Charset_is_utf8)
-	      addstr ("\342\224\214"); /* WACS_ULCORNER */
-	    else
 	      addch (ACS_ULCORNER);
 	    break;
 	  case M_TREE_LTEE:
-	    if (option (OPTASCIICHARS))
-	      addch ('|');
-	    else if (Charset_is_utf8)
-	      addstr ("\342\224\234"); /* WACS_LTEE */
-	    else
 	      addch (ACS_LTEE);
 	    break;
 	  case M_TREE_HLINE:
-	    if (option (OPTASCIICHARS))
-	      addch ('-');
-	    else if (Charset_is_utf8)
-	      addstr ("\342\224\200"); /* WACS_HLINE */
-	    else
 	      addch (ACS_HLINE);
 	    break;
 	  case M_TREE_VLINE:
-	    if (option (OPTASCIICHARS))
-	      addch ('|');
-	    else if (Charset_is_utf8)
-	      addstr ("\342\224\202"); /* WACS_VLINE */
-	    else
 	      addch (ACS_VLINE);
 	    break;
 	  case M_TREE_TTEE:
-	    if (option (OPTASCIICHARS))
-	      addch ('-');
-	    else if (Charset_is_utf8)
-	      addstr ("\342\224\254"); /* WACS_TTEE */
-	    else
 	      addch (ACS_TTEE);
 	    break;
 	  case M_TREE_BTEE:
-	    if (option (OPTASCIICHARS))
-	      addch ('-');
-	    else if (Charset_is_utf8)
-	      addstr ("\342\224\264"); /* WACS_BTEE */
-	    else
 	      addch (ACS_BTEE);
 	    break;
-	  case M_TREE_SPACE:
-	    addch (' ');
-	    break;
-	  case M_TREE_RARROW:
-	    addch ('>');
-	    break;
-	  case M_TREE_STAR:
-	    addch ('*'); /* fake thread indicator */
-	    break;
-	  case M_TREE_HIDDEN:
-	    addch ('&');
-	    break;
-	  case M_TREE_EQUALS:
-	    addch ('=');
-	    break;
-	  case M_TREE_MISSING:
-	    addch ('?');
+	  default:
+	    addch (TreeAsciiChars[(int)*s]);
 	    break;
 	}
 	s++, n--;
@@ -130,7 +163,7 @@
     else if ((k = mbrtowc (&wc, (char *)s, n, &mbstate)) > 0)
     {
       addnstr ((char *)s, k);
-      s += k, n-= k;
+      s += k, n -= k;
     }
     else
       break;
diff -uNrb mutt-1.4.2.1.orig/mutt.h mutt-1.4.2.1/mutt.h
--- mutt-1.4.2.1.orig/mutt.h	Wed Jul 24 18:46:58 2002
+++ mutt-1.4.2.1/mutt.h	Thu Feb 12 21:04:58 2004
@@ -468,8 +468,18 @@
   OPTDONTHANDLEPGPKEYS,	/* (pseudo) used to extract PGP keys */
 #endif
 
-
-
+  OPTCREATERFC2047PARAMS, /* (pseudo) used to generate rfc2047 parameter */
+  OPTDELETEPREFIX,	/* (pseudo) used to delete prefix in Subject */
+  OPTMSGID,		/* (pseudo) used to print Message-ID field */
+  OPTMSGIDUSEFROM,	/* (pseudo) used to contain $from in Message-ID */
+  OPTPAGERHDRSONLY,	/* (pseudo) used to hide a body */
+  OPTPAGERSPOIL,	/* (pseudo) used to replace characters of a body */ 
+  OPTSANITIZEJACHARS,	/* (pseudo) used to sanitize ja characters */
+  OPTSTRICTMIME,	/* (pseudo) used to be strict in RFCs of MIME */ 
+  OPTTREECHARS,		/* (pseudo) used to use characters you like
+			 *          when displaying thread.
+			 */
+  OPTUSEJISX0208,       /* (pseudo) used to use jis x 0208 */
 
   OPTMAX
 };
@@ -580,6 +590,7 @@
 				 * If NULL, filename is used 
 				 * instead.
 				 */
+  char *file_charset;		/* charset of attached file */
   CONTENT *content;             /* structure used to store detailed info about
 				 * the content of the attachment.  this is used
 				 * to determine what content-transfer-encoding
@@ -825,7 +836,7 @@
 void state_attach_puts (const char *, STATE *);
 void state_prefix_putc (char, STATE *);
 int  state_printf(STATE *, const char *, ...);
-
+void state_puts_conv(BODY *, char *, STATE *);
 #include "ascii.h"
 #include "protos.h"
 #include "lib.h"
diff -uNrb mutt-1.4.2.1.orig/mutt_menu.h mutt-1.4.2.1/mutt_menu.h
--- mutt-1.4.2.1.orig/mutt_menu.h	Tue Sep 11 20:20:34 2001
+++ mutt-1.4.2.1/mutt_menu.h	Thu Feb 12 21:04:58 2004
@@ -107,3 +107,6 @@
 /* used in both the index and pager index to make an entry. */
 void index_make_entry (char *, size_t, struct menu_t *, int);
 int index_color (int);
+
+void mutt_set_treechars (void);
+void mutt_init_treechars (void);
diff -uNrb mutt-1.4.2.1.orig/mutt_regex.h mutt-1.4.2.1/mutt_regex.h
--- mutt-1.4.2.1.orig/mutt_regex.h	Fri Mar  3 19:10:10 2000
+++ mutt-1.4.2.1/mutt_regex.h	Thu Feb 12 21:04:58 2004
@@ -52,5 +52,6 @@
 WHERE REGEXP ReplyRegexp;
 WHERE REGEXP Smileys;
 WHERE REGEXP GecosMask;
+WHERE REGEXP DeleteRegexp;
 
 #endif /* MUTT_REGEX_H */
diff -uNrb mutt-1.4.2.1.orig/muttlib.c mutt-1.4.2.1/muttlib.c
--- mutt-1.4.2.1.orig/muttlib.c	Mon Mar 25 20:29:32 2002
+++ mutt-1.4.2.1/muttlib.c	Thu Feb 12 21:04:58 2004
@@ -23,6 +23,7 @@
 #include "mailbox.h"
 #include "mx.h"
 #include "url.h"
+#include "mbyte.h"
 
 #include "reldate.h"
 
@@ -896,6 +897,42 @@
       *p = '_';
 }
 
+/* return width of multibyte character string */
+size_t mutt_mbswidth (char *s, size_t n)
+{
+  wchar_t wc;
+  size_t j,k,l,m;
+  mbstate_t mbstate;
+
+  l = 0;
+  if (!s)
+    return 0;
+  memset (&mbstate, 0, sizeof (mbstate));
+  while (*s && n)
+  {
+    j = (int)*s;
+    if (j < M_TREE_MAX)
+    {
+      if (option (OPTTREECHARS))
+        l += TreeWidth[j];
+      else if (Charset_is_utf8)
+        l += TreeUTF8Width[j];
+      else
+        l++;
+      s++, n--;
+    }
+    else
+    {
+      k = mbrtowc (&wc, s, n, &mbstate);
+      if (k == (size_t)(-1) || k == (size_t)(-2))
+        break;
+      m = wcwidth (wc);
+      l += (m > 0) ? m : 0;
+      s += k, n -= k;
+    }
+  }
+  return l;
+}
 
 void mutt_FormatString (char *dest,		/* output buffer */
 			size_t destlen,		/* output buffer len */
@@ -1008,7 +1045,7 @@
 	    len = destlen - wlen;
 	  memcpy (wptr, buf, len);
 	  wptr += len;
-	  wlen += len;
+	  wlen += mutt_mbswidth (buf, len);
 	}
 	break; /* skip rest of input */
       }
@@ -1047,7 +1084,7 @@
 
 	memcpy (wptr, buf, len);
 	wptr += len;
-	wlen += len;
+	wlen += mutt_mbswidth (buf, len);
       }
     }
     else if (*src == '\\')
@@ -1279,6 +1316,23 @@
   *(buf->dptr) = '\0';
 }
 
+void state_puts_conv (BODY *b, char *f, STATE *s)
+{
+  char *charset;
+  char *t;
+
+  charset = mutt_get_parameter ("charset", b->parameter);
+  if (charset)
+  {
+    t = safe_strdup (f);
+    mutt_convert_string (&t, charset, Charset, M_ICONV_HOOK_FROM);
+    state_puts (t, s);
+    safe_free ((void **) &t);
+  }
+  else
+    state_puts (f, s);
+}
+
 /* Decrease a file's modification time by 1 second */
 
 time_t mutt_decrease_mtime (const char *f, struct stat *st)
diff -uNrb mutt-1.4.2.1.orig/mx.c mutt-1.4.2.1/mx.c
--- mutt-1.4.2.1.orig/mx.c	Wed Mar 20 18:53:42 2002
+++ mutt-1.4.2.1/mx.c	Thu Feb 12 21:04:58 2004
@@ -50,6 +50,7 @@
 #include <fcntl.h>
 #include <sys/file.h>
 #include <sys/stat.h>
+#include <sys/types.h>
 #include <errno.h>
 #include <unistd.h>
 #include <stdlib.h>
@@ -141,6 +142,39 @@
 
 #endif /* USE_DOTLOCK */
 
+/* check if non-dot-beginning subdirectories exist */
+static int have_subdir (const char *path){
+  int result = FALSE;
+  DIR * dirp;
+  struct dirent * de;
+  struct stat s;
+  char buffer[_POSIX_PATH_MAX + SHORT_STRING];
+
+  if ((dirp = opendir (path)) == NULL)
+  {
+    mutt_perror (path);
+    return (-1);
+  }
+
+  while ((de = readdir (dirp)) != NULL)
+  {
+    if ( de->d_name[0] != '.' )
+    {
+      snprintf (buffer, sizeof (buffer), "%s/%s", path, de->d_name);
+      if (lstat (buffer, &s) == -1)
+        continue;
+
+      if (S_ISDIR (s.st_mode))
+      {
+        result = TRUE;
+        break;
+      }
+    }
+  }
+  (void)closedir(dirp);
+  return result;
+}
+
 /* Args:
  *	excl		if excl != 0, request an exclusive lock
  *	dot		if dot != 0, try to dotlock the file
@@ -409,6 +443,12 @@
     if (access (tmp, F_OK) == 0)
       return (M_MH);
 
+    /* check if the directory-path is under $MhPath */
+    if (mutt_strlen(MhPath) > 0 &&
+        ! mutt_strncmp (MhPath, path, mutt_strlen(MhPath)) &&
+        ! have_subdir (path))
+      return (M_MH);
+
   }
   else if (st.st_size == 0)
   {
diff -uNrb mutt-1.4.2.1.orig/pager.c mutt-1.4.2.1/pager.c
--- mutt-1.4.2.1.orig/pager.c	Sun Jan 13 17:52:15 2002
+++ mutt-1.4.2.1/pager.c	Thu Feb 12 21:04:58 2004
@@ -86,6 +86,21 @@
 			break; \
 		     }
 
+#define REDRAW_WHOLE if(hdronly) \
+		     {\
+			whole = 1; \
+			hdronly = 0; \
+			redraw = REDRAW_FULL; \
+			break; \
+		     }
+
+#define DRAW_WHOLE if(hdronly) \
+		     {\
+			whole = 1; \
+			hdronly = 0; \
+			redraw = REDRAW_FULL; \
+		     }
+
 struct q_class_t
 {
   int length;
@@ -141,6 +156,10 @@
 
 #define NumSigLines 4
 
+static int hdronly = 0;
+static int inbody = 0;
+static int whole = 0;
+
 static int check_sig (const char *s, struct line_t *info, int n)
 {
   int count = 0;
@@ -1127,8 +1146,16 @@
       if (col + t > wrap_cols)
 	break;
       col += t;
-      if (pa)
+      if (pa) {
+	if (!inbody)
 	mutt_addwch (wc);
+	else if (t == 1)
+	  addch (Spoiler[0]);
+	else {
+	  addch (Spoiler[0]);
+	  addch (Spoiler[0]);
+	}
+      }
     }
     else if (wc == '\n')
       break;
@@ -1415,6 +1442,9 @@
   if (!(flags & M_SHOW))
     flags = 0;
 
+  if (hdronly && buf[0] == '\n')
+    inbody = 1;
+
   return (flags);
 }
 
@@ -1489,6 +1519,10 @@
   if (!(flags & M_SHOWCOLOR))
     flags |= M_SHOWFLAT;
 
+  hdronly = option (OPTPAGERHDRSONLY) && IsHeader (extra) ? 1 : 0;
+  if (IsHeader (extra))
+    whole = 0;
+
   if ((fp = fopen (fname, "r")) == NULL)
   {
     mutt_perror (fname);
@@ -1660,6 +1694,12 @@
 	lines = 0;
 	force_redraw = 0;
 
+	if (!hdronly && IsHeader (extra))
+	  mutt_set_flag (Context, extra->hdr, M_READ, 1);
+	else if (IsHeader (extra) && Context->msgnotreadyet == extra->hdr->msgno)
+	  mutt_set_flag (Context, extra->hdr, M_READ, 0);
+	inbody = 0;
+
 	while (lines < bodylen && lineInfo[curline].offset <= sb.st_size - 1)
 	{
 	  if (display_line (fp, &last_pos, &lineInfo, curline, &lastLine, 
@@ -1668,6 +1708,10 @@
 			    &QuoteList, &q_level, &force_redraw, &SearchRE) > 0)
 	    lines++;
 	  curline++;
+
+	  if (!option (OPTPAGERSPOIL) && hdronly && inbody)
+	    lines = bodylen;
+
 	}
 	last_offset = lineInfo[curline].offset;
       } while (force_redraw);
@@ -1696,15 +1740,13 @@
       CLEARLINE (statusoffset);
       if (IsHeader (extra))
       {
-	_mutt_make_string (buffer,
-			   COLS-9 < sizeof (buffer) ? COLS-9 : sizeof (buffer),
-			   NONULL (PagerFmt), Context, extra->hdr, M_FORMAT_MAKEPRINT);
+	_mutt_make_string (buffer, sizeof (buffer), NONULL (PagerFmt), 
+			   Context, extra->hdr, M_FORMAT_MAKEPRINT);
       }
       else if (IsMsgAttach (extra))
       {
-	_mutt_make_string (buffer,
-			   COLS - 9 < sizeof (buffer) ? COLS - 9: sizeof (buffer),
-			   NONULL (PagerFmt), Context, extra->bdy->hdr, M_FORMAT_MAKEPRINT);
+	_mutt_make_string (buffer, sizeof (buffer), NONULL (PagerFmt), 
+			   Context, extra->bdy->hdr, M_FORMAT_MAKEPRINT);
       }
       mutt_paddstr (COLS-10, IsHeader (extra) || IsMsgAttach (extra) ?
 		    buffer : banner);
@@ -1812,6 +1854,7 @@
 	break;
 
       case OP_NEXT_PAGE:
+	REDRAW_WHOLE;
 	if (lineInfo[curline].offset < sb.st_size-1)
 	{
 	  topline = upNLines (PagerContext, lineInfo, curline, hideQuoted);
@@ -1839,6 +1882,7 @@
 	break;
 
       case OP_NEXT_LINE:
+	REDRAW_WHOLE;
 	if (lineInfo[curline].offset < sb.st_size-1)
 	{
 	  topline++;
@@ -1894,6 +1938,7 @@
 
       case OP_SEARCH_NEXT:
       case OP_SEARCH_OPPOSITE:
+	DRAW_WHOLE;
 	if (SearchCompiled)
 	{
 	  if ((!SearchBack && ch==OP_SEARCH_NEXT) ||
@@ -1938,6 +1983,7 @@
 
       case OP_SEARCH:
       case OP_SEARCH_REVERSE:
+	DRAW_WHOLE;
 	/* leave SearchBack alone if ch == OP_SEARCH_NEXT */
 	if (ch == OP_SEARCH)
 	  SearchBack = 0;
@@ -2038,6 +2084,9 @@
 	  mutt_help (MENU_PAGER);
 	  redraw = REDRAW_FULL;
 	  InHelp = 0;
+
+	  if (!whole && option (OPTPAGERHDRSONLY))
+	    hdronly = 1;
 	}
 	else
 	  mutt_error _("Help is currently being shown.");
diff -uNrb mutt-1.4.2.1.orig/parse.c mutt-1.4.2.1/parse.c
--- mutt-1.4.2.1.orig/parse.c	Tue Jan 29 19:05:44 2002
+++ mutt-1.4.2.1/parse.c	Thu Feb 12 21:04:58 2004
@@ -214,9 +214,21 @@
 
       if (*s == '"')
       {
+	int state_ascii = 1;
 	s++;
-	for (i=0; *s && *s != '"' && i < sizeof (buffer) - 1; i++, s++)
+	for (i=0; *s && i < sizeof (buffer) - 1; i++, s++)
 	{
+	  if (*s == 0x1b)
+	  {
+	    if (s[1] == '(' && (s[2] == 'B' || s[2] == 'J'))
+	      state_ascii = 1;
+	    else
+	      state_ascii = 0;
+	  }
+	  if (state_ascii)
+	  {
+	    if (*s == '"')
+	      break;
 	  if (*s == '\\')
 	  {
 	    /* Quote the next character */
@@ -227,6 +239,9 @@
 	  else
 	    buffer[i] = *s;
 	}
+	  else
+	    buffer[i] = *s;
+	}
 	buffer[i] = 0;
 	if (*s)
 	  s++; /* skip over the " */
@@ -385,7 +400,9 @@
   if (ct->type == TYPETEXT)
   {
     if (!(pc = mutt_get_parameter ("charset", ct->parameter)))
-      mutt_set_parameter ("charset", "us-ascii", &ct->parameter);
+      mutt_set_parameter ("charset", option (OPTSTRICTMIME) ? "us-ascii" : 
+			  (const char *) mutt_get_first_charset (AssumedCharset),
+			  &ct->parameter);
   }
 
 }
@@ -1344,6 +1361,25 @@
 
       if (regexec (ReplyRegexp.rx, e->subject, 1, pmatch, 0) == 0)
 	e->real_subj = e->subject + pmatch[0].rm_eo;
+      else if (option (OPTDELETEPREFIX))
+      {
+        /* if this option is set, mutt will delete the string as [prefix], 
+         * [prefix:number] and [prefix number] in Subject line.
+         */
+	regmatch_t match[1];
+
+	if (regexec ((regex_t *) DeleteRegexp.rx, e->subject, 1, match, 0))
+	  e->real_subj = e->subject;
+	else
+	{
+	  char *p = e->subject + match[0].rm_eo;
+
+	  if (regexec (ReplyRegexp.rx, p, 1, match, 0) == 0)
+	    e->real_subj = p + match[0].rm_eo;
+	  else
+	    e->real_subj = p;
+	}
+      }
       else
 	e->real_subj = e->subject;
     }
diff -uNrb mutt-1.4.2.1.orig/pgp.c mutt-1.4.2.1/pgp.c
--- mutt-1.4.2.1.orig/pgp.c	Thu Jan 10 00:39:28 2002
+++ mutt-1.4.2.1/pgp.c	Thu Feb 12 21:04:58 2004
@@ -190,7 +190,7 @@
  * dash-escaping.
  */
 
-static long pgp_copy_clearsigned (STATE *s, long bytes)
+static long pgp_copy_clearsigned (BODY *m, STATE *s, long bytes)
 {
   long last_pos, offset;
   char buf[HUGE_STRING];
@@ -209,7 +209,7 @@
     if (!complete)
     {
       if (!armor_header)
-	state_puts (buf, s);
+	state_puts_conv (m, buf, s);
       continue;
     }
 
@@ -230,9 +230,9 @@
       state_puts (s->prefix, s);
     
     if (buf[0] == '-' && buf[1] == ' ')
-      state_puts (buf + 2, s);
+      state_puts_conv (m, buf + 2, s);
     else
-      state_puts (buf, s);
+      state_puts_conv (m, buf, s);
   }
   
   if (!have_sig)
@@ -306,7 +306,7 @@
       {
 	if (s->prefix)
 	  state_puts (s->prefix, s);
-	state_puts (buf, s);
+	state_puts_conv (m, buf, s);
 	continue;
       }
 
@@ -424,7 +424,7 @@
 	{
 	  if (s->prefix)
 	    state_puts (s->prefix, s);
-	  state_puts (buf, s);
+	  state_puts_conv (m, buf, s);
 	}
       }
 
@@ -445,7 +445,7 @@
       {
 	fseek (s->fpin, start_pos, SEEK_SET);
 	bytes   += (last_pos - start_pos);
-	bytes    = pgp_copy_clearsigned (s, bytes);
+	bytes    = pgp_copy_clearsigned (m, s, bytes);
 	last_pos = ftell (s->fpin);
       }
 
@@ -464,7 +464,7 @@
     {
       if (s->prefix)
 	state_puts (s->prefix, s);
-      state_puts (buf, s);
+      state_puts_conv (m, buf, s);
     }
   }
 
@@ -1550,9 +1550,9 @@
   char pgpoutfile[_POSIX_PATH_MAX];
   char pgperrfile[_POSIX_PATH_MAX];
   char pgpinfile[_POSIX_PATH_MAX];
+  char send_charset[SHORT_STRING];
   
   FILE *pgpout = NULL, *pgperr = NULL, *pgpin = NULL;
-  FILE *fp;
 
   int empty;
   int err;
@@ -1561,22 +1561,14 @@
 
   pid_t thepid;
   
-  if ((fp = fopen (a->filename, "r")) == NULL)
-  {
-    mutt_perror (a->filename);
-    return NULL;
-  }
-  
   mutt_mktemp (pgpinfile);
   if ((pgpin = safe_fopen (pgpinfile, "w")) == NULL)
   {
     mutt_perror (pgpinfile);
-    fclose (fp);
     return NULL;
   }
 
-  mutt_copy_stream (fp, pgpin);
-  fclose (fp);
+  mutt_write_mime_body (a, pgpin);
   fclose (pgpin);
 
   mutt_mktemp (pgpoutfile);
@@ -1651,6 +1643,8 @@
   b->type = TYPEAPPLICATION;
   b->subtype = safe_strdup ("pgp");
 
+  mutt_get_body_charset (send_charset, sizeof (send_charset), a);
+  mutt_set_parameter ("charset", send_charset, &b->parameter);
   mutt_set_parameter ("format", "text", &b->parameter);
   mutt_set_parameter ("x-action", flags & PGPENCRYPT ? "encrypt" : "sign",
 		      &b->parameter);
diff -uNrb mutt-1.4.2.1.orig/protos.h mutt-1.4.2.1/protos.h
--- mutt-1.4.2.1.orig/protos.h	Tue Apr 30 02:12:18 2002
+++ mutt-1.4.2.1/protos.h	Thu Feb 12 21:04:58 2004
@@ -340,6 +340,7 @@
 
 /* utf8.c */
 int mutt_wctoutf8 (char *s, unsigned int c);
+size_t mutt_mbswidth (char *s, size_t n);
 
 #ifdef LOCALES_HACK
 #define IsPrint(c) (isprint((unsigned char)(c)) || \
diff -uNrb mutt-1.4.2.1.orig/rfc2047.c mutt-1.4.2.1/rfc2047.c
--- mutt-1.4.2.1.orig/rfc2047.c	Sat Apr 20 16:26:10 2002
+++ mutt-1.4.2.1/rfc2047.c	Thu Feb 12 21:04:58 2004
@@ -58,6 +58,9 @@
   size_t obl, n;
   int e;
 
+  if (option (OPTSANITIZEJACHARS) && !ascii_strncasecmp (from, "iso-2022-jp", 11))
+    mutt_sanitize_ja_chars ((char *) f, flen, 0);
+
   cd = mutt_iconv_open (to, from, 0);
   if (cd == (iconv_t)(-1))
     return (size_t)(-1);
@@ -720,13 +723,54 @@
   return 0;
 }
 
+/* return length of linear white space */
+static size_t lwslen (const char *s, size_t n)
+{
+  const char *p = s;
+  size_t len = n;
+
+  if (n <= 0)
+    return 0;
+
+  for (; p < s + n; p++)
+    if (!strchr (" \t\r\n", *p))
+    {
+      len = (size_t)(p - s);
+      break;
+    }
+  if (strchr ("\r\n", *(p-1))) /* LWS doesn't end with CRLF */
+    len = (size_t)0;
+  return len;
+}
+
+/* return length of linear white space : reverse */
+static size_t lwsrlen (const char *s, size_t n)
+{
+  const char *p = s + n - 1;
+  size_t len = n;
+
+  if (n <= 0)
+    return 0;
+
+  if (strchr ("\r\n", *p)) /* LWS doesn't end with CRLF */
+    return (size_t)0;
+
+  for (; p >= s; p--)
+    if (!strchr (" \t\r\n", *p))
+    {
+      len = (size_t)(s + n - 1 - p);
+      break;
+    }
+  return len;
+}
+
 /* try to decode anything that looks like a valid RFC2047 encoded
  * header field, ignoring RFC822 parsing rules
  */
 void rfc2047_decode (char **pd)
 {
   const char *p, *q;
-  size_t n;
+  size_t m, n;
   int found_encoded = 0;
   char *d0, *d;
   const char *s = *pd;
@@ -743,6 +787,37 @@
     if (!(p = find_encoded_word (s, &q)))
     {
       /* no encoded words */
+      if (!option (OPTSTRICTMIME))
+      {
+	n = mutt_strlen (s);
+	if (found_encoded && (m = lwslen (s, n)) != 0)
+	{
+	  if (m != n)
+	    *d = ' ', d++, dlen--;
+	  n -= m, s += m;
+	}
+	if (ascii_strcasecmp (AssumedCharset, "us-ascii"))
+	{
+	  char *t;
+	  size_t tlen;
+
+	  t = safe_malloc (n + 1);
+	  strfcpy (t, s, n + 1);
+	  if (mutt_convert_nomime_string (&t) == 0)
+	  {
+	    tlen = mutt_strlen (t);
+	    strncpy (d, t, tlen); 
+	    d += tlen;
+	  }
+	  else
+	  {
+	    strncpy (d, s, n); 
+	    d += n;
+	  }
+	  safe_free((void **) &t);
+	  break;
+	}
+      }
       strncpy (d, s, dlen);
       d += dlen;
       break;
@@ -752,7 +827,27 @@
     {
       n = (size_t) (p - s);
       /* ignore spaces between encoded words */
-      if (!found_encoded || strspn (s, " \t\r\n") != n)
+      if (!option (OPTSTRICTMIME))
+      {
+	if (found_encoded && (m = lwslen (s, n)) != 0)
+	{
+	  if (m != n)
+	    *d = ' ', d++, dlen--;
+	  n -= m, s += m;
+	}
+
+	if ((m = n - lwsrlen (s, n)) != 0)
+	{
+	  if (m > dlen)
+	    m = dlen;
+	  memcpy (d, s, m);
+	  d += m;
+	  dlen -= m;
+	  if (m != n)
+	    *d = ' ', d++, dlen--;
+	}
+      }
+      else if (!found_encoded || strspn (s, " \t\r\n") != n)
       {
 	if (n > dlen)
 	  n = dlen;
@@ -780,7 +875,7 @@
 {
   while (a)
   {
-    if (a->personal && strstr (a->personal, "=?") != NULL)
+    if (a->personal)
       rfc2047_decode (&a->personal);
 #ifdef EXACT_ADDRESS
     if (a->val && strstr (a->val, "=?") != NULL)
diff -uNrb mutt-1.4.2.1.orig/rfc2231.c mutt-1.4.2.1/rfc2231.c
--- mutt-1.4.2.1.orig/rfc2231.c	Wed Feb 14 07:06:14 2001
+++ mutt-1.4.2.1/rfc2231.c	Thu Feb 12 21:04:58 2004
@@ -113,6 +113,11 @@
 
       if (option (OPTRFC2047PARAMS) && p->value && strstr (p->value, "=?"))
 	rfc2047_decode (&p->value);
+      else if (!option (OPTSTRICTMIME))
+      {
+	if (ascii_strcasecmp (AssumedCharset, "us-ascii"))
+	  mutt_convert_nomime_string (&p->value);
+      }
 
       *last = p;
       last = &p->next;
diff -uNrb mutt-1.4.2.1.orig/send.c mutt-1.4.2.1/send.c
--- mutt-1.4.2.1.orig/send.c	Thu Jan 31 07:50:59 2002
+++ mutt-1.4.2.1/send.c	Thu Feb 12 21:04:58 2004
@@ -988,7 +988,7 @@
   {
     if (t->description)
     {
-      rfc2047_encode_string (&t->description);
+      _rfc2047_encode_string (&t->description, 0, 13);
     }
     if (recurse && t->parts)
       encode_descriptions (t->parts, recurse);
diff -uNrb mutt-1.4.2.1.orig/sendlib.c mutt-1.4.2.1/sendlib.c
--- mutt-1.4.2.1.orig/sendlib.c	Sat Jun  1 01:59:39 2002
+++ mutt-1.4.2.1/sendlib.c	Thu Feb 12 21:05:37 2004
@@ -401,6 +401,33 @@
     }
   }
 
+  if (a->use_disp && !option (OPTSTRICTMIME) && option (OPTCREATERFC2047PARAMS))
+  {
+    if(!(fn = a->d_filename))
+      fn = a->filename;
+    
+    if (fn)
+    {
+      char *tmp;
+
+      /* Strip off the leading path... */
+      if ((t = strrchr (fn, '/')))
+	t++;
+      else
+	t = fn;
+
+      /* length of content-type */ 
+      len = 21 + mutt_strlen (TYPE (a)) + mutt_strlen (a->subtype);
+
+      buffer[0] = 0;
+      tmp = safe_strdup (t);
+      _rfc2047_encode_string (&tmp, 0, len);
+      rfc822_cat (buffer, sizeof (buffer), tmp, MimeSpecials);
+      safe_free ((void **)&tmp);
+      fprintf (f, "; name=%s", buffer);
+    }
+  }
+
   fputc ('\n', f);
 
   if (a->description)
@@ -494,7 +521,7 @@
   }
 
   if (a->type == TYPETEXT && (!a->noconv))
-    fc = fgetconv_open (fpin, Charset, 
+    fc = fgetconv_open (fpin, a->file_charset, 
 			mutt_get_body_charset (send_charset, sizeof (send_charset), a), 
 			0);
   else
@@ -892,6 +919,7 @@
   CONTENT *info;
   CONTENT_STATE state;
   FILE *fp = NULL;
+  char *fromcode;
   char *tocode;
   char buffer[100];
   char chsbuf[STRING];
@@ -926,15 +954,18 @@
   if (b != NULL && b->type == TYPETEXT && (!b->noconv && !b->force_charset))
   {
     char *chs = mutt_get_parameter ("charset", b->parameter);
+    char *fchs = b->use_disp ? ((FileCharset && *FileCharset) ?
+	                         FileCharset : Charset) : Charset;
     if (Charset && (chs || SendCharset) &&
-	convert_file_from_to (fp, Charset, chs ? chs : SendCharset,
-			      0, &tocode, info) != (size_t)(-1))
+      convert_file_from_to (fp, fchs, chs ? chs : SendCharset,
+                            &fromcode, &tocode, info) != (size_t)(-1))
     {
       if (!chs)
       {
 	mutt_canonical_charset (chsbuf, sizeof (chsbuf), tocode);
 	mutt_set_parameter ("charset", chsbuf, &b->parameter);
       }
+      b->file_charset = fromcode;
       safe_free ((void **) &tocode);
       safe_fclose (&fp);
       return info;
@@ -1311,6 +1342,7 @@
   body->unlink = 1;
   body->use_disp = 0;
   body->disposition = DISPINLINE;
+  body->noconv = 1;
 
   mutt_parse_mime_message (ctx, hdr);
 
@@ -1625,7 +1657,7 @@
     fputs ("Subject: \n", fp);
 
   /* save message id if the user has set it */
-  if (env->message_id && !privacy)
+  if (option (OPTMSGID) && env->message_id && !privacy)
     fprintf (fp, "Message-ID: %s\n", env->message_id);
 
   if (env->reply_to)
@@ -1703,7 +1735,7 @@
     if (!tmp)
       continue;
     
-    rfc2047_encode_string (&tmp);
+    _rfc2047_encode_string (&tmp, 0, 0);
     safe_realloc ((void **) &h->data, 
 		  mutt_strlen (h->data) + 2 + mutt_strlen (tmp) + 1);
 
@@ -1744,15 +1776,25 @@
   time_t now;
   struct tm *tm;
   const char *fqdn;
+  char symbol;
 
   now = time (NULL);
   tm = gmtime (&now);
+  if( option (OPTMSGIDUSEFROM) && From)
+  {
+    fqdn = NONULL(From->mailbox);
+    symbol = '%';
+  }
+  else
+  {
   if(!(fqdn = mutt_fqdn(0)))
     fqdn = NONULL(Hostname);
+    symbol = '@';
+  }
 
-  snprintf (buf, sizeof (buf), "<%d%02d%02d%02d%02d%02d.G%c%d@%s>",
+  snprintf (buf, sizeof (buf), "<%d%02d%02d%02d%02d%02d.G%c%d%c%s>",
 	    tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour,
-	    tm->tm_min, tm->tm_sec, MsgIdPfx, getpid (), fqdn);
+	    tm->tm_min, tm->tm_sec, MsgIdPfx, getpid (), symbol, fqdn);
   MsgIdPfx = (MsgIdPfx == 'Z') ? 'A' : MsgIdPfx + 1;
   return (safe_strdup (buf));
 }
@@ -2149,7 +2191,7 @@
 
   if (env->subject)
   {
-    rfc2047_encode_string (&env->subject);
+    _rfc2047_encode_string (&env->subject, 0, 9);
   }
   encode_headers (env->userhdrs);
 }
diff -uNrb mutt-1.4.2.1.orig/stamp-h.in mutt-1.4.2.1/stamp-h.in
--- mutt-1.4.2.1.orig/stamp-h.in	Thu Feb 12 17:52:25 2004
+++ mutt-1.4.2.1/stamp-h.in	Thu Feb 12 21:04:58 2004
@@ -1 +1,2 @@
 timestamp
+dummy line
diff -uNrb mutt-1.4.2.1.orig/PATCHES mutt-1.4.2.1/PATCHES
--- mutt-1.4.2.1.orig/PATCHES	Tue Nov 27 04:16:52 2001
+++ mutt-1.4.2.1/PATCHES	Fri Feb 13 00:42:23 2004
@@ -0,0 +1 @@
+patch-1.4.2.1.tt.ja.1
