Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 12 May 2013 20:11:20 +0900 (JST)
From:      SHIOZAKI Takehiko <st@be.to>
To:        bug-followup@FreeBSD.org
Subject:   ports/178530: japanese/mutt-devel update to 1.5.21-ja.2
Message-ID:  <20130512111120.56021110666@localhost.takehiko.cjb.net>
Resent-Message-ID: <201305121150.r4CBo1sP081736@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         178530
>Category:       ports
>Synopsis:       japanese/mutt-devel update to 1.5.21-ja.2
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          maintainer-update
>Submitter-Id:   current-users
>Arrival-Date:   Sun May 12 11:50:00 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator:     SHIOZAKI Takehiko
>Release:        FreeBSD 8.2-STABLE i386
>Organization:
>Environment:
System:	FreeBSD localhost.my.domain 8.2-STABLE FreeBSD 8.2-STABLE #1426: Sat Aug 20 00:04:05 JST 2011     root@localhost.my.domain:/usr/obj/usr/src/sys/GENERIC  i386
	
>Description:

	- Updated to 1.5.21-ja.2
>How-To-Repeat:

	
>Fix:

diff -urN mutt-devel/Makefile mutt-devel-1.5.21-ja.2/Makefile
--- mutt-devel/Makefile	2013-04-27 20:59:28.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/Makefile	2013-04-08 00:23:33.000000000 +0900
@@ -1,162 +1,663 @@
-# Created by: IWASHITA Yoji <shuna@pop16.odn.ne.jp>
-# $FreeBSD: japanese/mutt-devel/Makefile 316662 2013-04-27 11:59:28Z mva $
+#
+# Added Japanese patch of japanese/mutt-devel (mutt-1.15.1-ja.1)
+# by Kenji Rikitake to the files/ directory
+# Note:
+# * USE the "UTF-9" modified locale for UTF-8 display
+#   available in the Japanese distribution.
+# * DO NOT ENABLE SLANG; use ncurses.
+# * The rest of the file is the same as the mail/mutt Port Makefile
+#
 
-# WITH_MUTT_CYRUS_SASL2:	if defined, 'Cyrus sasl' support.
+#
+# ex:ts=8
+# Ports collection makefile for:  mutt development
+# Date created:			  6 Jun 2001
+# Whom:				  Udo Schweigert
+#
+# $FreeBSD: ports/mail/mutt/Makefile,v 1.198 2012/11/17 05:59:06 svnexp Exp $
+#
+# There are several knobs which are used to define additions to the core
+# mutt functionality.
+#
+# As all of the knobs have a unique name which should not interfere with
+# other ports you can add them to /etc/make.conf, e.g. a line like
+# "WITH_MUTT_NNTP=yes" will enable mutt's nntp facilities.
+#
+# In addition to the knobs listed below you can enable other configuration
+# options of mutt by adding them to the MUTT_CONFIGURE_ARGS variable. For
+# example you could say "MUTT_CONFIGURE_ARGS=--with-homespool=MyMail" to
+# configure a different file for mutt's homespool.
+#
+# The two most important knobs are:
+#
+# In general you can choose between using ncurses (WITH_MUTT_NCURSES)
+# and SLANG (WITH_MUTT_SLANG). Note that you may have to set the variables
+# COLORTERM=yes and COLORFGBG="color1;color2" in your environment to get slang
+# function properly.
+# The default version for ncurses is that which comes with the operating
+# system. If you want to use the ncurses supplied by the ports-system define
+# WITH_MUTT_NCURSES_PORT.
+#
+# If you want to install the mutt documentation in html and ps format define:
+#  WITH_MUTT_HTML
+#  This is a default knob and can be disabled by WITHOUT_MUTT_HTML
+#
+# If you do not want that the documentation is rebuilt using the xml tools
+# define:
+#  WITHOUT_MUTT_XML
+#    (this can only be stated if WITHOUT_MUTT_HTML is defined)
+#
+# If you want to access compressed email folders define:
+#  WITH_MUTT_COMPRESSED_FOLDERS
+#  This is a default knob and can be disabled by WITHOUT_MUTT_COMPRESSED_FOLDERS
+#
+# If you do not want mutt to use the iconv library define:
+#  WITHOUT_MUTT_ICONV
+#
+# If you want mutt to use the idn library define:
+#  WITH_MUTT_IDN
+#
+# If you want to make use of the gpgme interface define:
+#  WITH_MUTT_GPGME
+#
+# If you want to enable extended quoting functions define:
+#  WITH_MUTT_QUOTE_PATCH
+#  This is a default knob and can be disabled by WITHOUT_MUTT_QUOTE_PATCH
+#
+# If you want to have the IMAP header cache define:
+#  WITH_MUTT_IMAP_HEADER_CACHE
+#
+# If you want to have the Maildir and the IMAP header cache define:
+#  WITH_MUTT_MAILDIR_HEADER_CACHE
+#
+# If you want to make SMIME outlook compatible define:
+#  WITH_MUTT_SMIME_OUTLOOK_COMPAT
+#  This is a default knob and can be disabled by
+#    WITHOUT_MUTT_SMIME_OUTLOOK_COMPAT
+#
+# If you want to read and post news with mutt define:
+#  WITH_MUTT_NNTP
+#
+# If you want to use the SASL2 authentication features with your email server
+# define
+#  WITH_MUTT_CYRUS_SASL2
+#
+# If you want mutt to use the GNU aspell spelling checker define:
+#  WITH_MUTT_ASPELL
+#
+# If you want mutt to use the ispell spelling checker define:
+#  WITH_MUTT_ISPELL
+#
+# If you want to use the signature menu define:
+#  WITH_MUTT_SIGNATURE_MENU
+#
+# If you want to use the printf-like enhancement to the mbox-hook command
+# define:
+#  WITH_MUTT_MBOX_HOOK_PATCH
+#
+# If you want to use the ifdef feature define:
+#  WITH_MUTT_IFDEF_PATCH
+#
+# If you want to have the Maildir mtime patch define:
+#  WITH_MUTT_MAILDIR_MTIME_PATCH
+#
+# If you want to have the Mailbox Sidebar patch define:
+#  WITH_MUTT_SIDEBAR_PATCH
+#
+# If you do not want mutt to use the flock() function define:
+#  WITHOUT_MUTT_FLOCK
+#
+# If you want to enable the reverse_reply option define:
+#  WITH_MUTT_REVERSE_REPLY_PATCH
+#
+# If you want to enable the `greeting' option define:
+#  WITH_MUTT_GREETING_PATCH
+#
+# If you want to enable the parent/child match support define:
+#  WITH_MUTT_PARENT_CHILD_MATCH_PATCH
+#
+# If you want to be able to use a trash folder for deleted emails (especially useful
+# for example for googlemail) define:
+#  WITH_MUTT_TRASH_PATCH
+#
+# If you want to enable the internal SMTP relay support define:
+#  WITH_MUTT_SMTP
+#
+# If you want to enable debugging capabilities define:
+#  WITH_MUTT_DEBUG
+#
+# If you do not want to install the manpages mbox.5 and mmdf.5 (because that
+# conflicts with other ports which installed these:
+#  WITHOUT_MUTT_MAILBOX_MANPAGES
+#
+# Use CFLAGS_ADD and LDFLAGS_ADD to append additional CLFAGS and LDFLAGS.
 #
 
 PORTNAME=	mutt
 PORTVERSION=	${VERSION}.j${JP_VERSION}
-PORTREVISION=	3
-CATEGORIES=	japanese mail
-MASTER_SITES=	ftp://ftp.mutt.org/mutt/devel/:body \
-		ftp://ftp.fu-berlin.de/pub/unix/mail/mutt/devel/:body \
-		ftp://ftp.demon.co.uk/pub/mirrors/mutt/devel/:body \
-		http://www.emaillab.org/mutt/${MANUALVERSION}/:ja_man1 \
-		http://mutt-j.sourceforge.jp/:ja_man2 \
-		http://www.emaillab.org/mutt/1.5/doc/:ja_doc
+CATEGORIES+=	japanese mail ipv6
+.if defined(WITH_MUTT_NNTP)
+CATEGORIES+=	news
+.endif
+MASTER_SITES=	ftp://ftp.mutt.org/mutt/devel/ \
+		ftp://ftp.fu-berlin.de/pub/unix/mail/mutt/devel/ \
+		ftp://ftp.demon.co.uk/pub/mirrors/mutt/devel/ \
+		http://www.mutt.org.ua/download/mutt-${VVV_PATCH_VERSION}/:vvv \
+		http://www2.mutt.org.ua/download/mutt-${VVV_PATCH_VERSION}/:vvv \
+		http://www3.mutt.org.ua/download/mutt-${VVV_PATCH_VERSION}/:vvv \
+		ftp://ftp.mutt.org.ua/pub/mutt/mutt-${VVV_PATCH_VERSION}/:vvv \
+		ftp://ftp3.mutt.org.ua/pub/mutt/mutt-${VVV_PATCH_VERSION}/:vvv \
+		http://www.spinnaker.de/mutt/compressed/:rr \
+		http://lunar-linux.org/~tchan/mutt/:tchan
 PKGNAMESUFFIX=	-devel
 DISTNAME=	mutt-${VERSION}
-DISTFILES=	${DISTNAME}${EXTRACT_SUFX}:body \
-		manual_ja-${MANUALVERSION}i-1${EXTRACT_SUFX}:ja_man1 \
-		manual.ja-${MANJADATE}${EXTRACT_SUFX}:ja_man2 \
-		README.JA-PATCH.ja.html:ja_doc \
-		README.JA-PATCH.ja:ja_doc \
-		INSTALL.JA-PATCH.ja.html:ja_doc \
-		INSTALL.JA-PATCH.ja:ja_doc \
-		manual-ja-patch.ja.html:ja_doc \
-		manual-ja-patch.ja.txt:ja_doc \
-		usage-japanese.ja.html:ja_doc \
-		usage-japanese.ja.txt:ja_doc
-DIST_SUBDIR=	mutt
-EXTRACT_ONLY=	${DISTNAME}${EXTRACT_SUFX} \
-		manual_ja-${MANUALVERSION}i-1${EXTRACT_SUFX} \
-		manual.ja-${MANJADATE}${EXTRACT_SUFX}
+DISTFILES=	${DISTNAME}${EXTRACT_SUFX}
+EXTRACT_ONLY=	${DISTNAME}${EXTRACT_SUFX}
 
-PATCH_SITES=	http://www.emaillab.org/mutt/${VERSION}/:ja_patch
-PATCHFILES=	patch-${VERSION}.tt.wcwidth.${JP_VERSION}.gz:ja_patch \
-		patch-${VERSION}.tt.create_rfc2047_params.${JP_VERSION}.gz:ja_patch \
-		patch-${VERSION}.tt+yy.delete_prefix.${JP_VERSION}.gz:ja_patch \
-		patch-${VERSION}.tt.sanitize_ja_char.${JP_VERSION}.gz:ja_patch
-PATCH_DIST_STRIP=	-p1
+PATCH_SITES+=	http://www.mutt.org.ua/download/mutt-${VVV_PATCH_VERSION}/:vvv \
+		http://www2.mutt.org.ua/download/mutt-${VVV_PATCH_VERSION}/:vvv \
+		http://www3.mutt.org.ua/download/mutt-${VVV_PATCH_VERSION}/:vvv \
+		ftp://ftp.mutt.org.ua/pub/mutt/mutt-${VVV_PATCH_VERSION}/:vvv \
+		ftp://ftp3.mutt.org.ua/pub/mutt/mutt-${VVV_PATCH_VERSION}/:vvv \
+		http://home.woolridge.ca/mutt/patches/:dw \
+		http://www.spinnaker.de/mutt/compressed/:rr
 
 MAINTAINER=	st@be.to
 COMMENT=	Text-based mail client (Japanised development version)
 
-LIB_DEPENDS=	slang.2:${PORTSDIR}/japanese/libslang
-RUN_DEPENDS=	urlview:${PORTSDIR}/textproc/urlview \
-		${LOCALBASE}/etc/mime.types:${PORTSDIR}/misc/mime-support
+MASTER_SITES+=	http://dl.sourceforge.jp/mutt-j/57658/:ja_patch \
+		http://www.emaillab.org/mutt/${MANUALVERSION}/:ja_man1 \
+		http://mutt-j.sourceforge.jp/:ja_man2
+DISTFILES+=	${DISTNAME}-ja.${JP_VERSION}${EXTRACT_SUFX}:ja_patch \
+		manual_ja-${MANUALVERSION}i-1${EXTRACT_SUFX}:ja_man1 \
+		manual.ja-${MANJADATE}${EXTRACT_SUFX}:ja_man2
+EXTRACT_ONLY+=	${DISTNAME}-ja.${JP_VERSION}${EXTRACT_SUFX} \
+		manual_ja-${MANUALVERSION}i-1${EXTRACT_SUFX} \
+		manual.ja-${MANJADATE}${EXTRACT_SUFX}
 
-CONFLICTS=	ja-mutt-[0-9]* mutt-[0-9]* mutt-devel-[0-9]* mutt-devel-lite-[0-9]* mutt-lite-[0-9]* zh-mutt-devel-[0-9]*
+CONFLICTS?=	ja-mutt-[0-9]* mutt-[0-9]* mutt-devel-lite-[0-9]* mutt-lite-[0-9]* zh-mutt-devel-[0-9]*
 
 VERSION=	1.5.21
-JP_VERSION=	1
+JP_VERSION=	2
 MANUALVERSION=	1.4
 MANJADATE=	20050813
 
-FETCH_BEFORE_ARGS=	-A	# ha4.seikyou.ne.jp is running broken httpd
-
-NO_LATEST_LINK=	yes
-USE_GMAKE=	yes
-USES=		iconv
-USE_AUTOTOOLS=	automake autoconf
-USE_OPENSSL=	yes
-WRKSRC=		${WRKDIR}/mutt-${VERSION}
-LDFLAGS+=	-L${LOCALBASE}/lib
-CONFIGURE_ENV=	CC="${CC} -D_DONT_USE_CTYPE_INLINE_ ${DB_CFLAGS} -I${LOCALBASE}/include -I${LOCALBASE}/include/slang"
-CONFIGURE_ARGS=	--with-slang --enable-locales-fix \
-		--with-libiconv-prefix=${LOCALBASE} \
-		--without-wc-funcs \
-		--enable-flock --disable-fcntl \
-		--with-ssl \
-		--sysconfdir=${PREFIX}/etc \
-		--with-docdir=${DOCSDIR} \
-		--enable-pop --enable-imap \
-		--enable-smtp
+DIST_SUBDIR=	mutt
+DOCSDIR?=	${PREFIX}/share/doc/mutt
+EXAMPLESDIR?=	${PREFIX}/share/examples/mutt
+DATADIR?=	${PREFIX}/share/mutt
+CONFIGURE_ENV=	CC="${CC} -I${LOCALBASE}/include"
+CONFIGURE_ARGS=	--disable-fcntl --with-ssl=${OPENSSLBASE} \
+		--with-docdir=${DOCSDIR} --sysconfdir=${PREFIX}/etc \
+		--enable-external-dotlock --enable-pop --enable-imap \
+		--disable-warnings
 .if defined(MUTT_CONFIGURE_ARGS)
 CONFIGURE_ARGS+=	${MUTT_CONFIGURE_ARGS}
 .endif
 
-OPTIONS_DEFINE=	CYRUS_SASL2 IMAP_HEADER_CACHE IDN MAILDIR_HEADER_CACHE NLS
-CYRUS_SASL2_DESC=	SASL2 authentication
-IMAP_HEADER_CACHE_DESC=	imap header cache
-MAILDIR_HEADER_CACHE_DESC=	maildir header cache
-
-.include <bsd.port.options.mk>
+USE_AUTOTOOLS=	automake autoconf
+USE_OPENSSL=	yes
+USE_NCURSES=	yes
+USE_NCURSES_RPATH=	yes
 
-.if ! ${PORT_OPTIONS:MNLS}
-USES+=	gettext
+.if !defined (MUTT_LITE)
+OPTIONS=	MUTT_ASPELL			"Enable aspell support"		off \
+		MUTT_COMPRESSED_FOLDERS		"Enable compressed folders"	on \
+		MUTT_CYRUS_SASL2		"Enable SASL2 authentication"	off \
+		MUTT_DEBUG			"Enable debugging capabilities"	off \
+		MUTT_FLOCK			"Enable flock() usage"		off \
+		MUTT_GPGME			"Enable gpgme interface"	off \
+		MUTT_GREETING_PATCH		"Enable greeting"		off \
+		MUTT_HTML			"Enable HTML documentation"	on \
+		MUTT_ICONV			"Enable iconv support"		on  \
+		MUTT_IDN			"Enable idn support"		off \
+		MUTT_IFDEF_PATCH		"Enable ifdef feature"		off \
+		MUTT_IMAP_HEADER_CACHE		"Enable imap header cache"	off \
+		MUTT_ISPELL			"Enable ispell support"		off \
+		MUTT_LOCALES_FIX		"Enable locales fix"		off \
+		MUTT_MAILBOX_MANPAGES		"Install mbox.5/mmdf.5 manpages"	on  \
+		MUTT_MAILDIR_HEADER_CACHE	"Enable maildir header cache"	off \
+		MUTT_MAILDIR_MTIME_PATCH	"Enable Maildir mtime patch"	off \
+		MUTT_MBOX_HOOK_PATCH		"Enable enhanced mbox-hook"	off \
+		MUTT_NCURSES			"Enable ncurses support"	on \
+		MUTT_NCURSES_PORT		"Use ncurses from port"		off \
+		MUTT_NNTP			"Enable news reader"		off \
+		MUTT_PARENT_CHILD_MATCH_PATCH	"Enable parent/child match"	off \
+		MUTT_QUOTE_PATCH		"Enable extended quoting"	on  \
+		MUTT_REVERSE_REPLY_PATCH	"Enable reverse_reply"		off \
+		MUTT_SGMLFORMAT			"Enable sgml support"		on  \
+		MUTT_SIDEBAR_PATCH		"Enable sidebar"		off \
+		MUTT_SIGNATURE_MENU		"Enable signature menu"		off \
+		MUTT_SLANG			"Enable slang support"		off \
+		MUTT_SMIME_OUTLOOK_COMPAT	"SMIME outlook compatible"	on \
+		MUTT_SMTP			"Enable SMTP relay support"	off \
+		MUTT_TRASH_PATCH		"Enable trash folder support"	off \
+		MUTT_XML			"Use XML tools for docu"	on
+.endif
+
+PLIST=		${WRKDIR}/PLIST
+PKGMESSAGE=	${WRKDIR}/pkg-message
+SCRIPTS_ENV=	WRKDIR="${WRKDIR}"
+
+.include <bsd.port.pre.mk>
+
+DW_PATCH_VERSION=	1.5.6
+AC_PATCH_VERSION=	1.5.9
+DW_MBOX_PATCH_VERSION=	1.5.18
+.if !defined(VVV_PATCH_VERSION)
+VVV_PATCH_VERSION=	${VERSION}
+.endif
+.if !defined(RR_PATCH_VERSION)
+RR_PATCH_VERSION=	${VERSION}
+.endif
+.if !defined(DW_PATCH_VERSION)
+DW_PATCH_VERSION=	${VERSION}
+.endif
+.if !defined(DW_MBOX_PATCH_VERSION)
+DW_MBOX_PATCH_VERSION=	${DW_PATCH_VERSION}
+.endif
+.if !defined(AC_PATCH_VERSION)
+AC_PATCH_VERSION=	${VERSION}
+.endif
+.if defined(WITH_MUTT_MAILDIR_HEADER_CACHE)
+WITH_MUTT_IMAP_HEADER_CACHE=	yes
+.endif
+
+.if defined (MUTT_LITE)
+WITHOUT_MUTT_XML=			yes
+WITHOUT_MUTT_COMPRESSED_FOLDERS=	yes
+WITHOUT_MUTT_QUOTE_PATCH=		yes
+WITHOUT_MUTT_HTML=			yes
+WITH_MUTT_NCURSES=			yes
+PKGNAMESUFFIX=	-lite
+.endif
+
+# XXX
+# this should be done automagically by aclocal but ....
+# for now, this will have to do
+pre-build:
+	@${REINPLACE_CMD} -E -e "s|^(ACLOCAL = ).+|\1${ACLOCAL}|" \
+			-e "s|^(AUTOCONF = ).+|\1${AUTOCONF}|" \
+			-e "s|^(AUTOMAKE = ).+|\1${AUTOMAKE}|" \
+			-e "s|^(AUTOHEADER = ).+|\1${AUTOHEADER}|" \
+		${BUILD_WRKSRC}/Makefile
+
+RUN_DEPENDS+=	${LOCALBASE}/etc/mime.types:${PORTSDIR}/misc/mime-support
+.if !defined (MUTT_LITE)
+.if exists(${LOCALBASE}/bin/aspell) && !defined(WITH_MUTT_ISPELL)
+WITH_MUTT_ASPELL=	yes
+.elif exists(${LOCALBASE}/bin/ispell) && !defined(WITH_MUTT_ASPELL)
+WITH_MUTT_ISPELL=	yes
+.endif
+.if defined(PACKAGE_BUILDING) && !defined(WITH_MUTT_ASPELL) && \
+	!defined(WITH_MUTT_ISPELL)
+WITH_MUTT_ASPELL=	yes
+.endif
+.if defined(WITH_MUTT_ASPELL)
+BUILD_DEPENDS+=	aspell:${PORTSDIR}/textproc/aspell
+RUN_DEPENDS+=	aspell:${PORTSDIR}/textproc/aspell
+.elif defined(WITH_MUTT_ISPELL)
+BUILD_DEPENDS+=	ispell:${PORTSDIR}/textproc/ispell
+RUN_DEPENDS+=	ispell:${PORTSDIR}/textproc/ispell
+.endif
+.if defined(PACKAGE_BUILDING)
+RUN_DEPENDS+=	urlview:${PORTSDIR}/textproc/urlview
+.endif
+.endif
+
+.if defined(WITH_MUTT_NCURSES_PORT)
+WITH_MUTT_NCURSES=	yes
+.endif
+.if defined(WITH_MUTT_SLANG) || defined(WITH_SLANG)
+MUTT_USES_SLANG=	yes
+.endif
+.if defined(WITH_MUTT_NCURSES) && !defined(MUTT_USES_SLANG)
+MUTT_USES_NCURSES=	yes
+.endif
+.if !defined(MUTT_USES_SLANG) && !defined(WITHOUT_MUTT_SLANG)
+MUTT_USES_NCURSES=	yes
+.endif
+.if defined(WITHOUT_MUTT_SGMLFORMAT)
+XML_USED=	no
+.endif
+.if defined(WITHOUT_MUTT_XML)
+XML_USED=	no
+.endif
+.if !defined(XML_USED)
+XML_USED=	no
+.endif
+.if !defined(WITHOUT_NLS)
+USE_GETTEXT=	yes
+.endif
+.if !defined(WITHOUT_MUTT_ICONV)
+USE_ICONV=	yes
+.endif
+.if defined(NOPORTDOCS)
+XML_USED=	no
+.endif
+.if defined(WITH_MUTT_NCURSES_PORT)
+.if !defined(MUTT_USES_SLANG)
+MUTT_USES_NCURSES_PORT=	yes
+.endif
+.endif
+.if defined(MUTT_USES_NCURSES_PORT)
+WITH_NCURSES_PORT=	yes
+CFLAGS+=	-I${NCURSESINC}
+.elif defined(MUTT_USES_SLANG)
+LIB_DEPENDS+=	slang.2:${PORTSDIR}/devel/libslang2
 .endif
-.if ${PORT_OPTIONS:MCYRUS_SASL2}
-LIB_DEPENDS+=	sasl2:${PORTSDIR}/security/cyrus-sasl2
+.if defined(WITH_MUTT_CYRUS_SASL2)
+LIB_DEPENDS+=	sasl2.2:${PORTSDIR}/security/cyrus-sasl2
 .endif
-.if ${PORT_OPTIONS:MMAILDIR_HEADER_CACHE}
-PORT_OPTIONS+=	MAILDIR_HEADER_CACHE
+.if exists(${LOCALBASE}/lib/libidn.so) && !defined(WITHOUT_MUTT_IDN)
+WITH_MUTT_IDN=	yes
 .endif
-.if ${PORT_OPTIONS:MIMAP_HEADER_CACHE}
-USE_BDB=	42+
-.endif
-.if ${PORT_OPTIONS:MIDN}
+.if defined(WITH_MUTT_IDN)
 LIB_DEPENDS+=	idn:${PORTSDIR}/dns/libidn
 .endif
+.if defined(WITH_MUTT_GPGME)
+LIB_DEPENDS+=	gpgme:${PORTSDIR}/security/gpgme
+.endif
+.if ! defined(WITHOUT_MUTT_SMIME_OUTLOOK_COMPAT)
+post-patch::
+	@${PATCH} ${PATCH_ARGS} < ${PATCHDIR}/extra-patch-smime-outlook
+.endif
+.if defined(WITH_MUTT_SIGNATURE_MENU)
+IGNORE=	the WITH_MUTT_SIGNATURE_MENU does not work at the moment
+XML_NEEDED=	yes
+post-patch::
+	@${PATCH} ${PATCH_ARGS} -p1 < ${PATCHDIR}/extra-patch-signature-menu
+.endif
+.if defined(WITH_MUTT_MAILDIR_MTIME_PATCH)
+post-patch::
+.if defined(WITH_MUTT_NNTP)
+	@${PATCH} ${PATCH_ARGS} < ${PATCHDIR}/extra-patch-maildir-mtime-nntp
+.else
+	@${PATCH} ${PATCH_ARGS} < ${PATCHDIR}/extra-patch-maildir-mtime
+.endif
+.endif
+
+.if defined(WITH_MUTT_ASPELL)
+post-patch::
+	@${PATCH} ${PATCH_ARGS} < ${PATCHDIR}/extra-patch-aspell
+.endif
+
+.if defined(WITH_MUTT_REVERSE_REPLY_PATCH)
+post-patch::
+	@${PATCH} ${PATCH_ARGS} < ${PATCHDIR}/extra-patch-reverse_reply
+.endif
+
+.if defined(WITH_MUTT_PARENT_CHILD_MATCH_PATCH)
+post-patch::
+	@${PATCH} ${PATCH_ARGS} -p1 < ${PATCHDIR}/extra-patch-parent-child-match
+.endif
 
-.if ${PORT_OPTIONS:MCYRUS_SASL2}
+.if defined(WITHOUT_MUTT_FLOCK)
+CONFIGURE_ARGS+=	--disable-flock
+.else
+CONFIGURE_ARGS+=	--enable-flock
+.endif
+.if defined(WITH_MUTT_LOCALES_FIX)
+CONFIGURE_ARGS+=	--enable-locales-fix
+.endif
+.if defined(MUTT_USES_NCURSES_PORT)
+CONFIGURE_ARGS+=	--with-curses=${NCURSESBASE}
+.elif defined(MUTT_USES_SLANG)
+CONFIGURE_ARGS+=	--with-slang=${LOCALBASE}
+.else
+CONFIGURE_ARGS+=	--with-curses=${NCURSESBASE}
+.endif
+.if defined(WITH_MUTT_CYRUS_SASL2)
 CONFIGURE_ARGS+=	--with-sasl=${LOCALBASE}
 .endif
-.if ! ${PORT_OPTIONS:MNLS}
+.if defined(WITHOUT_NLS)
 CONFIGURE_ARGS+=	--disable-nls
-PLIST_SUB+=	NLS="@comment "
+.endif
+.if defined(WITHOUT_MUTT_ICONV)
+CONFIGURE_ARGS+=	--disable-iconv
 .else
-PLIST_SUB+=	NLS=""
+CONFIGURE_ARGS+=	--with-libiconv-prefix=${LOCALBASE}
 .endif
-.if ${PORT_OPTIONS:MIDN}
+.if defined(WITH_MUTT_IDN)
 CONFIGURE_ARGS+=	--with-idn
 .else
 CONFIGURE_ARGS+=	--without-idn
 .endif
-.if ${PORT_OPTIONS:MIMAP_HEADER_CACHE}
+.if defined(WITH_MUTT_GPGME)
+CONFIGURE_ARGS+=	--enable-gpgme
+.else
+CONFIGURE_ARGS+=	--disable-gpgme
+.endif
+LDFLAGS=
+.if !defined(WITHOUT_GSSAPI)
+.if exists(${LOCALBASE}/bin/krb5-config)
+LIB_DEPENDS+=		gssapi_krb5:${PORTSDIR}/security/krb5
+CONFIGURE_ARGS+=	--with-gss=${LOCALBASE}
+.elif exists(${KRB5_HOME}/bin/krb5-config)
+LIB_DEPENDS+=		gssapi_krb5:${PORTSDIR}/security/krb5
+CONFIGURE_ARGS+=	--with-gss=${KRB5_HOME}
+LDFLAGS+=		-L${KRB5_HOME}/lib -rpath=${KRB5_HOME}/lib
+.elif exists(${HEIMDAL_HOME}/bin/krb5-config)
+LIB_DEPENDS+=		gssapi_krb5:${PORTSDIR}/security/krb5
+CONFIGURE_ARGS+=	--with-gss=${HEIMDAL_HOME}
+LDFLAGS+=		-L${HEIMDAL_HOME}/lib -rpath=${HEIMDAL_HOME}/lib
+.elif (defined(MAKE_KERBEROS5)) || exists(/usr/lib/libkrb5.a)
+CONFIGURE_ARGS+=	--with-gss
+USE_KRB5_SYS=YES
+.endif
+.endif
+LDFLAGS+=		-L${LOCALBASE}/lib -rpath=${LOCALBASE}/lib:/usr/lib
+CFLAGS+=		${CFLAGS_ADD}
+LDFLAGS+=		${LDFLAGS_ADD}
+.if defined(WITH_MUTT_SMTP)
+CONFIGURE_ARGS+=	--enable-smtp
+.else
+CONFIGURE_ARGS+=	--disable-smtp
+.endif
+.if defined(WITH_MUTT_DEBUG)
+CONFIGURE_ARGS+=	--enable-debug
+.endif
+
+PATCH_DIST_STRIP=	-p1
+
+pre-patch::
+	@${CP} -f ${WRKDIR}/patches/* ${FILESDIR}
+
+.if ! defined (WITHOUT_MUTT_COMPRESSED_FOLDERS)
+DISTFILES+=	patch-${RR_PATCH_VERSION}.rr.compressed.gz:vvv
+CONFIGURE_ARGS+=	--enable-compressed
+XML_NEEDED=	yes
+pre-patch::
+	@${GUNZIP_CMD} -c ${DISTDIR}/${DIST_SUBDIR}/patch-${RR_PATCH_VERSION}.rr.compressed.gz > ${WRKDIR}/patch-compressed
+	@${REINPLACE_CMD} -E '/^diff.*\/doc\/manual.txt$$/,/^diff/d' \
+		 ${WRKDIR}/patch-compressed
+	@${PATCH} ${PATCH_ARGS} -p1 < ${WRKDIR}/patch-compressed
+.endif
+.if defined(WITH_MUTT_NNTP)
+DISTFILES+=	patch-${VVV_PATCH_VERSION}.vvv.nntp.gz:vvv
+CONFIGURE_ARGS+=	--enable-nntp
+XML_NEEDED=	yes
+pre-patch::
+	@${GUNZIP_CMD} -c ${DISTDIR}/${DIST_SUBDIR}/patch-${VVV_PATCH_VERSION}.vvv.nntp.gz > ${WRKDIR}/patch-nntp
+	@${REINPLACE_CMD} -E '/^diff.*\/doc\/manual.txt$$/,/^diff/d' \
+		${WRKDIR}/patch-nntp
+	@${PATCH} ${PATCH_ARGS} -p1 < ${WRKDIR}/patch-nntp
+.endif
+.if ! defined(WITHOUT_MUTT_QUOTE_PATCH)
+PATCHFILES+=	patch-${VVV_PATCH_VERSION}.vvv.initials.gz:vvv \
+		patch-${VVV_PATCH_VERSION}.vvv.quote.gz:vvv
+XML_NEEDED=	yes
+.endif
+.if defined(WITH_MUTT_IFDEF_PATCH)
+post-patch::
+	@${PATCH} ${PATCH_ARGS} -p1 < ${PATCHDIR}/extra-patch-ifdef
+.endif
+.if defined(WITH_MUTT_MBOX_HOOK_PATCH)
+IGNORE=	the WITH_MUTT_MBOX_HOOK_PATCH does not work at the moment
+#PATCHFILES+=	p0-patch-${DW_MBOX_PATCH_VERSION}.dw.mbox-hook.1:dw
+.endif
+.if defined(WITH_MUTT_SIDEBAR_PATCH)
+XML_NEEDED=	yes
+.if defined(WITH_MUTT_NNTP)
+post-patch::
+	@${PATCH} ${PATCH_ARGS} -p1 < ${PATCHDIR}/extra-patch-sidebar-nntp
+.else
+post-patch::
+	@${PATCH} ${PATCH_ARGS} -p1 < ${PATCHDIR}/extra-patch-sidebar
+.endif
+.endif
+.if defined(WITH_MUTT_GREETING_PATCH)
+post-patch::
+	@${PATCH} ${PATCH_ARGS} -p1 < ${PATCHDIR}/extra-patch-greeting
+.endif
+.if defined(WITH_MUTT_TRASH_PATCH)
+post-patch::
+	@${PATCH} ${PATCH_ARGS} -p1 < ${PATCHDIR}/extra-patch-trash-purge
+.endif
+
+WRKSRC=		${WRKDIR}/${DISTNAME:S/i$//}
+MAN1=		mutt.1 mutt_dotlock.1 flea.1 muttbug.1 smime_keys.1
+MAN5=		muttrc.5
+.if !defined(WITHOUT_MUTT_MAILBOX_MANPAGES)
+MAN5+=		mbox.5 mmdf.5
+.endif
+
+post-patch::
+	@${REINPLACE_CMD} -e 's,/usr/bin/gpg,${LOCALBASE}/bin/gpg,g' \
+		${WRKSRC}/contrib/gpg.rc
+	@${REINPLACE_CMD} -e 's,pgp6,pgp,g' \
+		${WRKSRC}/contrib/pgp6.rc
+	@${REINPLACE_CMD} -E -e 's|@samplesdir@|${EXAMPLESDIR}|g' \
+		${WRKSRC}/contrib/Makefile.am
+.if defined(WITHOUT_MUTT_MAILBOX_MANPAGES)
+	@${PATCH} ${PATCH_ARGS} < ${PATCHDIR}/extra-patch-no-mbox-manpage
+.endif
+
+pre-configure::
+	@(cd ${WRKSRC}; ${SETENV} ${AUTOMAKE_ENV} ${ACLOCAL} -I m4)
+.if defined(USE_KRB5_SYS)
+	@${ECHO_CMD} "#define HAVE_HEIMDAL" >> ${WRKSRC}/config.h.in
+	@${REINPLACE_CMD} -e 's|<gssapi/gssapi\.h>|<gssapi.h>|' \
+		${WRKSRC}/imap/auth_gss.c
+.endif
+
+.if defined(MUTT_SLAVE_HTML_PAGES)
+SCRIPTS_ENV+=	MUTT_SLAVE_HTML_PAGES="${MUTT_SLAVE_HTML_PAGES}"
+.endif
+.if defined(WITH_MUTT_NNTP)
+SCRIPTS_ENV+=	MUTT_NNTP="yes"
+.endif
+.if ! defined (WITHOUT_MUTT_COMPRESSED_FOLDERS)
+SCRIPTS_ENV+=	MUTT_COMPRESSED_FOLDERS="yes"
+.endif
+.if ! defined(WITHOUT_MUTT_QUOTE_PATCH)
+SCRIPTS_ENV+=	MUTT_QUOTE_PATCH="yes"
+.endif
+.if defined(WITH_MUTT_IMAP_HEADER_CACHE)
+.if defined(WITH_TOKYOCABINET)
+CONFIGURE_ARGS+=	--enable-hcache --without-gdbm --without-bdb --with-tokyocabinet
+LIB_DEPENDS+=		tokyocabinet.9:${PORTSDIR}/databases/tokyocabinet
+.else
+USE_BDB=		42+
 CONFIGURE_ARGS+=	--enable-hcache --without-gdbm --with-bdb
+.endif
 .else
 CONFIGURE_ARGS+=	--disable-hcache
 .endif
-.if ${PORT_OPTIONS:MMAILDIR_HEADER_CACHE}
+.if defined(WITH_MUTT_MAILDIR_HEADER_CACHE)
 CONFIGURE_ARGS+=	--without-qdbm
 .endif
+.if defined(WITH_MUTT_SIDEBAR_PATCH)
+SCRIPTS_ENV+=	MUTT_SIDEBAR_PATCH="yes"
+.endif
+.if defined(WITH_MUTT_SIGNATURE_MENU)
+SCRIPTS_ENV+=	MUTT_SIGNATURE_MENU="yes"
+.endif
+.if defined(WITH_MUTT_IFDEF_PATCH)
+SCRIPTS_ENV+=	MUTT_IFDEF_PATCH="yes"
+.endif
+.if ! defined(WITHOUT_MUTT_HTML)
+SCRIPTS_ENV+=	MUTT_HTML="yes"
+.endif
+.if !defined(WITHOUT_NLS)
+SCRIPTS_ENV+=	MUTT_NLS="yes"
+.endif
+.if defined(WITH_MUTT_REVERSE_REPLY_PATCH)
+SCRIPTS_ENV+=	MUTT_REVERSE_REPLY_PATCH="yes"
+.endif
+
+.if !defined(NOPORTDOCS)
+SCRIPTS_ENV+=	MUTT_PORTDOCS="yes"
+post-build::
+	@${PATCH} ${PATCH_ARGS} < ${PATCHDIR}/extra-patch-doc-ref
+	@${REINPLACE_CMD} -E -e 's|\$$\{PREFIX\}|${PREFIX}|g' \
+		-e 's|\$$\{DOCSDIR\}|${DOCSDIR}|g' \
+		-e 's|\$$\{EXAMPLESDIR\}|${EXAMPLESDIR}|g' \
+		${WRKSRC}/doc/mutt.man
+	@${REINPLACE_CMD} -E -e 's|\$$\{PREFIX\}|${PREFIX}|g' \
+		-e 's|\$$\{DOCSDIR\}|${DOCSDIR}|g' \
+		-e 's|\$$\{EXAMPLESDIR\}|${EXAMPLESDIR}|g' \
+		${WRKSRC}/doc/muttrc.man
+.if ! defined(WITHOUT_MUTT_HTML)
+XML_USED=	yes
+.endif
+.if defined(XML_NEEDED) && !defined(WITHOUT_MUTT_XML)
+XML_USED=	yes
+.endif
+.else 	# ! NOPORTDOCS
+post-patch::
+	@${PATCH} ${PATCH_ARGS} < ${PATCHDIR}/extra-patch-nodoc-contrib
+.endif # ! NOPORTDOCS
+
+.if ${XML_USED} == yes
+BUILD_DEPENDS+=	xsltproc:${PORTSDIR}/textproc/libxslt \
+		${LOCALBASE}/share/xsl/docbook/html/docbook.xsl:${PORTSDIR}/textproc/docbook-xsl \
+		lynx:${PORTSDIR}/www/lynx
+BUILD_DEPENDS+=	w3m:${PORTSDIR}/www/w3m
+post-patch::
+	@${PATCH} ${PATCH_ARGS} < ${PATCHDIR}/extra-patch-doc-xml
 
-NOMANCOMPRESS=	yes
-MAN1=		flea.1 mutt.1 muttbug.1 mutt_dotlock.1 smime_keys.1
-MAN5=		muttrc.5 mbox.5 mmdf.5
-
-pre-configure:
-.if ! ${PORT_OPTIONS:MDOCS}
-	${PATCH} ${PATCH_ARGS} < ${PATCHDIR}/extra-patch-nodoc-contrib
-.endif
-	(cd ${WRKSRC}; ${ACLOCAL} -I m4; ${AUTOHEADER})
-
-post-configure:
-	@${REINPLACE_CMD} -E "\
-		s|^(s%\@ACLOCAL\@%).+(%g)|\1${ACLOCAL}\2|; \
-		s|^(s%\@AUTOCONF\@%).+(%g)|\1${AUTOCONF}\2|; \
-		s|^(s%\@AUTOMAKE\@%).+(%g)|\1${AUTOMAKE}\2|; \
-		s|^(s%\@AUTOHEADER\@%).+(%g)|\1${AUTOHEADER}\2|" \
-		${BUILD_WRKSRC}/config.status
+post-build::
+	@cd ${WRKDIR}/docbook; ${GMAKE}
+.endif
+
+pre-install:
+	@${SETENV} ${SCRIPTS_ENV} ${SH} ${SCRIPTDIR}/generate-plist > ${PLIST}
 
-.if ${PORT_OPTIONS:MDOCS}
 post-install:
-	${INSTALL_DATA} ${_DISTDIR}/INSTALL.JA-PATCH.ja ${DOCSDIR}
-	${INSTALL_DATA} ${_DISTDIR}/README.JA-PATCH.ja ${DOCSDIR}
-	${INSTALL_DATA} ${_DISTDIR}/manual-ja-patch.ja.txt ${DOCSDIR}
-	${INSTALL_DATA} ${_DISTDIR}/usage-japanese.ja.txt ${DOCSDIR}
-	${INSTALL_DATA} ${_DISTDIR}/INSTALL.JA-PATCH.ja.html ${DOCSDIR}
-	${INSTALL_DATA} ${_DISTDIR}/README.JA-PATCH.ja.html ${DOCSDIR}
-	${INSTALL_DATA} ${_DISTDIR}/manual-ja-patch.ja.html ${DOCSDIR}
-	${INSTALL_DATA} ${_DISTDIR}/usage-japanese.ja.html ${DOCSDIR}
-	${INSTALL_DATA} ${WRKDIR}/manual_ja.txt ${DOCSDIR}
-	${INSTALL_DATA} ${WRKDIR}/manual_ja.tex ${DOCSDIR}
-	${INSTALL_DATA} ${WRKDIR}/manual_ja.html ${DOCSDIR}
-	${INSTALL_DATA} ${WRKDIR}/manual_ja.sgml ${DOCSDIR}
-	${INSTALL_DATA} ${WRKDIR}/manual.ja.txt ${DOCSDIR}
-	${INSTALL_DATA} ${WRKDIR}/manual.ja.html ${DOCSDIR}
-	${INSTALL_DATA} ${WRKDIR}/manual.ja.sgml ${DOCSDIR}
+	@${ECHO} > ${PKGMESSAGE}
+	${INSTALL_DATA} ${WRKSRC}/doc/Muttrc ${PREFIX}/etc/Muttrc.dist
+	@for f in ${WRKDIR}/samples/*; do \
+		${INSTALL_DATA} $${f} ${EXAMPLESDIR}; \
+		done
+.if !defined(NOPORTDOCS)
+	@${ECHO} "===>   Installing Mutt documentation"
+	@${MKDIR} ${DOCSDIR} && ${CHMOD} a+rx ${DOCSDIR}
+	@cd ${WRKSRC}/doc ; ${INSTALL_MAN} manual.txt PGP-Notes.txt \
+		../ABOUT-NLS ../contrib/language*  ${DOCSDIR}
+	@cd ${WRKDIR}/docbook ; ${INSTALL_MAN} *.ja *.ja.txt ${DOCSDIR}
+	@cd ${WRKDIR} ; ${INSTALL_MAN} manual*.txt manual*.sgml manual*.tex \
+		${DOCSDIR}
+.if defined(WITH_MUTT_NNTP)
+	@cd ${WRKSRC} ; ${INSTALL_MAN} ChangeLog.nntp ${DOCSDIR}
+.endif
+.if ! defined(WITHOUT_MUTT_HTML)
+	@${MKDIR} ${DOCSDIR}/html && ${CHMOD} a+rx ${DOCSDIR}/html
+	${INSTALL_MAN} ${WRKSRC}/doc/*.html ${DOCSDIR}/html
+	${INSTALL_MAN} ${WRKDIR}/docbook/*.ja.html ${DOCSDIR}/html
+	${INSTALL_MAN} ${WRKDIR}/manual*.html ${DOCSDIR}/html
+.endif
+.endif
+.if defined(MUTT_USES_SLANG)
+	@${ECHO} "=====================================================" >> ${PKGMESSAGE}
+	@${ECHO} "You have installed ${PORTNAME} with SLANG support." >> ${PKGMESSAGE}
+	@${ECHO} "This may work for a color terminal only when defining" >> ${PKGMESSAGE}
+	@${ECHO} "COLORTERM=yes and COLORFGBG=\"color1;color2\" in your" >> ${PKGMESSAGE}
+	@${ECHO} "environment." >> ${PKGMESSAGE}
+	@${ECHO} "=====================================================" >> ${PKGMESSAGE}
+.endif
+.if !defined(BATCH)
+	@${CAT} ${PKGMESSAGE}
+	@${ECHO}
 .endif
-
-.include <bsd.port.mk>
+.include <bsd.port.post.mk>
diff -urN mutt-devel/distinfo mutt-devel-1.5.21-ja.2/distinfo
--- mutt-devel/distinfo	2012-07-14 22:54:48.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/distinfo	2013-04-07 23:02:19.000000000 +0900
@@ -1,30 +1,14 @@
 SHA256 (mutt/mutt-1.5.21.tar.gz) = 2141f36e8d0f4f71c9ca6780001e7cc679fe313e643953fc07f001223e67c4a0
 SIZE (mutt/mutt-1.5.21.tar.gz) = 3716886
+SHA256 (mutt/mutt-1.5.21-ja.2.tar.gz) = 0843a5316f0cbd8fb972bc8f4adcfbb5f377777ba78de423ef0a20f8a27d53f7
+SIZE (mutt/mutt-1.5.21-ja.2.tar.gz) = 559120
 SHA256 (mutt/manual_ja-1.4i-1.tar.gz) = a0c02908bb5d47c30cf7a8c5e05bfe875439448ec050382671c1368b7d3c4d61
 SIZE (mutt/manual_ja-1.4i-1.tar.gz) = 300461
 SHA256 (mutt/manual.ja-20050813.tar.gz) = bee26bc377bc51e68611cbfaf2d352ad4bf00648ad86ba96b572a21cd27774cd
 SIZE (mutt/manual.ja-20050813.tar.gz) = 281491
-SHA256 (mutt/README.JA-PATCH.ja.html) = 6f23bde1416919205cf6a9393abf295b533ca2f82cd59bfabb6f1a6970ae0196
-SIZE (mutt/README.JA-PATCH.ja.html) = 15346
-SHA256 (mutt/README.JA-PATCH.ja) = 4b017013108ac0bf45e6e5117351f8d6f61bedabf46f1c719985f82d1c12993f
-SIZE (mutt/README.JA-PATCH.ja) = 8978
-SHA256 (mutt/INSTALL.JA-PATCH.ja.html) = ad2ad98c745544d4558f82c33873380066c526d7775a0685be54758682907646
-SIZE (mutt/INSTALL.JA-PATCH.ja.html) = 11821
-SHA256 (mutt/INSTALL.JA-PATCH.ja) = 2e1e3bc60937f2b116be58bf16987339efaef6c5130e253038b91f364f8ac929
-SIZE (mutt/INSTALL.JA-PATCH.ja) = 7651
-SHA256 (mutt/manual-ja-patch.ja.html) = 8607c4d692956c9b1ce8ad58c88761c7ddfe5089b7b6a343c1fae43b0f72893a
-SIZE (mutt/manual-ja-patch.ja.html) = 15415
-SHA256 (mutt/manual-ja-patch.ja.txt) = a68952bfb8b250566cd41e00f99e6b959639df0aa286e7f6b98598f357c8c094
-SIZE (mutt/manual-ja-patch.ja.txt) = 7691
-SHA256 (mutt/usage-japanese.ja.html) = 2d1a9eb0a84d6134da2d94c8456f70f86d6e5be9ec1798ebf81040d06bc27049
-SIZE (mutt/usage-japanese.ja.html) = 14177
-SHA256 (mutt/usage-japanese.ja.txt) = 0ea8d1afeb361a8a4e99563c7173cd7e30b4f4f00ff7b71381ce649d53e7c3cd
-SIZE (mutt/usage-japanese.ja.txt) = 9969
-SHA256 (mutt/patch-1.5.21.tt.wcwidth.1.gz) = f08f60d94be290b9d0eff3399ae97f620afba497960e4c3d112dc2f306047f59
-SIZE (mutt/patch-1.5.21.tt.wcwidth.1.gz) = 8145
-SHA256 (mutt/patch-1.5.21.tt.create_rfc2047_params.1.gz) = 71251917b4a9ec791dbe728df26f4f31bc86db8a920c6b70f282796cf8aa4d8d
-SIZE (mutt/patch-1.5.21.tt.create_rfc2047_params.1.gz) = 1115
-SHA256 (mutt/patch-1.5.21.tt+yy.delete_prefix.1.gz) = 0b673b504c22e942f92a7df95c9a1bc00551ffc50ac6c3a445713ac18807f460
-SIZE (mutt/patch-1.5.21.tt+yy.delete_prefix.1.gz) = 1568
-SHA256 (mutt/patch-1.5.21.tt.sanitize_ja_char.1.gz) = dea6d350838422f50c9fde9e8238156a55aa1a404e968e86d260fa8e5fa9e954
-SIZE (mutt/patch-1.5.21.tt.sanitize_ja_char.1.gz) = 2924
+SHA256 (mutt/patch-1.5.21.rr.compressed.gz) = 5056b181222c4322667fd99a6314e80a4a8b4613357364d9deddef626136b4d9
+SIZE (mutt/patch-1.5.21.rr.compressed.gz) = 10133
+SHA256 (mutt/patch-1.5.21.vvv.initials.gz) = ecce3643b04d1aced7085bca506896298bd56d991a5d1af057922c8358abf141
+SIZE (mutt/patch-1.5.21.vvv.initials.gz) = 691
+SHA256 (mutt/patch-1.5.21.vvv.quote.gz) = b0613d305932b31eaf005ee0740558d46561a6d7a333c97a00d34a1d0c1ef843
+SIZE (mutt/patch-1.5.21.vvv.quote.gz) = 1280
diff -urN mutt-devel/files/extra-patch-aspell mutt-devel-1.5.21-ja.2/files/extra-patch-aspell
--- mutt-devel/files/extra-patch-aspell	1970-01-01 09:00:00.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/extra-patch-aspell	2012-07-22 18:15:04.000000000 +0900
@@ -0,0 +1,11 @@
+--- doc/Muttrc.head.orig	Thu Jan 24 13:10:47 2002
++++ doc/Muttrc.head	Tue Nov  9 08:53:14 2004
+@@ -19,6 +19,8 @@
+ macro index   <f1> "!less @docdir@/manual.txt\n" "Show Mutt documentation"
+ macro pager   <f1> "!less @docdir@/manual.txt\n" "Show Mutt documentation"
+ 
++set ispell="/usr/local/bin/aspell --mode=email check"
++
+ # If Mutt is unable to determine your site's domain name correctly, you can
+ # set the default here.
+ #
diff -urN mutt-devel/files/extra-patch-doc-ref mutt-devel-1.5.21-ja.2/files/extra-patch-doc-ref
--- mutt-devel/files/extra-patch-doc-ref	1970-01-01 09:00:00.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/extra-patch-doc-ref	2013-01-02 23:57:25.000000000 +0900
@@ -0,0 +1,12 @@
+--- doc/mutt.man.orig	2009-02-06 13:52:38.000000000 +0100
++++ doc/mutt.man	2009-02-06 13:55:05.000000000 +0100
+@@ -69,7 +69,8 @@
+ .PP
+ Mutt is a small but very powerful text based program for reading and sending electronic
+ mail under unix operating systems, including support for color terminals, MIME,
+-OpenPGP, and a threaded sorting mode.
++OpenPGP, and a threaded sorting mode. Details of how to use all of this is
++available in \fI${DOCSDIR}\fP.
+ .PP
+ .I Note:
+ .IR
diff -urN mutt-devel/files/extra-patch-doc-xml mutt-devel-1.5.21-ja.2/files/extra-patch-doc-xml
--- mutt-devel/files/extra-patch-doc-xml	1970-01-01 09:00:00.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/extra-patch-doc-xml	2012-07-22 18:15:04.000000000 +0900
@@ -0,0 +1,11 @@
+--- doc/Makefile.am.orig	2010-09-17 16:23:30.000000000 +0200
++++ doc/Makefile.am	2010-09-17 16:25:01.000000000 +0200
+@@ -47,7 +47,7 @@
+ 
+ all: makedoc-all
+ 
+-makedoc-all: mutt.1 smime_keys.1 muttrc.man
++makedoc-all: mutt.1 smime_keys.1 muttrc.man manual.html stamp-doc-chunked manual.txt
+ 
+ install-data-local: makedoc-all instdoc
+ 	$(top_srcdir)/mkinstalldirs $(DESTDIR)$(mandir)/man1
diff -urN mutt-devel/files/extra-patch-greeting mutt-devel-1.5.21-ja.2/files/extra-patch-greeting
--- mutt-devel/files/extra-patch-greeting	1970-01-01 09:00:00.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/extra-patch-greeting	2012-07-22 18:15:04.000000000 +0900
@@ -0,0 +1,160 @@
+diff -urN mutt-1.5.19/globals.h mutt-1.5.19-vc/globals.h
+--- mutt-1.5.19/globals.h	2009-01-04 01:27:10.000000000 +0200
++++ mutt-1.5.19-vc/globals.h	2009-02-09 19:30:31.000000000 +0200
+@@ -52,6 +52,7 @@
+ WHERE char *FolderFormat;
+ WHERE char *ForwFmt;
+ WHERE char *Fqdn;
++WHERE char *Greeting;
+ WHERE char *HdrFmt;
+ WHERE char *HistFile;
+ WHERE char *Homedir;
+diff -urN mutt-1.5.19/hdrline.c mutt-1.5.19-vc/hdrline.c
+--- mutt-1.5.19/hdrline.c	2009-01-05 21:20:53.000000000 +0200
++++ mutt-1.5.19-vc/hdrline.c	2009-02-09 19:30:31.000000000 +0200
+@@ -741,3 +741,62 @@
+ {
+   mutt_FormatString (dst, dstlen, 0, s, hdr_format_str, (unsigned long) hfi, flags);
+ }
++
++/* %n = recipient name
++ * %u = user (login) name of recipient
++ * %v = first name of recipient	*/
++const char *
++greeting_string (char *dest,
++		size_t destlen,
++		size_t col,
++		char op,
++		const char *src,
++		const char *prefix,
++		const char *ifstring,
++		const char *elsestring,
++		unsigned long data,
++		format_flag flags)
++{
++  HEADER *hdr = (HEADER *)data;
++  char *p, buf2[SHORT_STRING];
++
++  dest[0] = '\0';
++  switch (op)
++  {
++    case 'n':
++      mutt_format_s (dest, destlen, prefix, mutt_get_name (hdr->env->to));
++      break;
++
++    case 'u':
++      if (hdr->env->to)
++      {
++	strfcpy (buf2, mutt_addr_for_display (hdr->env->to), sizeof (buf2));
++	if ((p = strpbrk (buf2, "%@")))
++	  *p = '\0';
++      }
++      else
++	buf2[0] = '\0';
++      mutt_format_s (dest, destlen, prefix, buf2);
++      break;
++
++    case 'v':
++      if (hdr->env->to)
++	mutt_format_s (buf2, sizeof (buf2), prefix, mutt_get_name (hdr->env->to));
++      else if (hdr->env->cc)
++	mutt_format_s (buf2, sizeof (buf2), prefix, mutt_get_name (hdr->env->cc));
++      else
++	*buf2 = '\0';
++      if ((p = strpbrk (buf2, " %@")))
++	*p = '\0';
++      mutt_format_s (dest, destlen, prefix, buf2);
++      break;
++
++    default:
++      snprintf (dest, destlen, "%%%s%c", prefix, op);
++      break;
++  }
++  if (flags & M_FORMAT_OPTIONAL)
++    mutt_FormatString (dest, destlen, col, elsestring, greeting_string, data, flags);
++
++  return(src);
++}
+diff -urN mutt-1.5.19/init.h mutt-1.5.19-vc/init.h
+--- mutt-1.5.19/init.h	2009-01-05 21:20:53.000000000 +0200
++++ mutt-1.5.19-vc/init.h	2009-02-09 19:30:31.000000000 +0200
+@@ -745,6 +745,22 @@
+   ** .pp
+   ** This setting defaults to the contents of the environment variable \fC$$$EMAIL\fP.
+   */
++  { "greeting",		DT_STR,	 R_NONE, UL &Greeting, UL "" },
++  /*
++  ** .pp
++  ** When set, this is the string that will precede every message as a
++  ** greeting phrase to the recipients.
++  ** .pp
++  ** ``Format strings'' are similar to the strings used in the ``C''
++  ** function printf to format output (see the man page for more detail).
++  ** The following sequences are defined in Mutt:
++  ** .pp
++  ** .dl
++  ** .dt %n .dd recipient name
++  ** .dt %u .dd user (login) name of recipient
++  ** .dt %v .dd first name of recipient
++  ** .de
++  */
+   { "gecos_mask",	DT_RX,	 R_NONE, UL &GecosMask, UL "^[^,]*" },
+   /*
+   ** .pp
+diff -urN mutt-1.5.19/PATCHES mutt-1.5.19-vc/PATCHES
+--- mutt-1.5.19/PATCHES	2008-03-19 22:07:06.000000000 +0200
++++ mutt-1.5.19-vc/PATCHES	2009-02-09 19:30:31.000000000 +0200
+@@ -0,0 +1 @@
++vc.greeting
+diff -urN mutt-1.5.19/protos.h mutt-1.5.19-vc/protos.h
+--- mutt-1.5.19/protos.h	2009-01-05 21:20:53.000000000 +0200
++++ mutt-1.5.19-vc/protos.h	2009-02-09 19:32:15.000000000 +0200
+@@ -526,6 +526,9 @@
+ void ci_bounce_message (HEADER *, int *);
+ int ci_send_message (int, HEADER *, char *, CONTEXT *, HEADER *);
+ 
++const char *greeting_string (char *, size_t, size_t, char, const char *, const char *,
++		const char *, const char *, unsigned long, format_flag);
++
+ /* prototypes for compatibility functions */
+ 
+ #ifndef HAVE_SETENV
+diff -urN mutt-1.5.19/send.c mutt-1.5.19-vc/send.c
+--- mutt-1.5.19/send.c.orig	2010-09-17 16:49:09.000000000 +0200
++++ mutt-1.5.19-vc/send.c	2010-09-17 16:53:15.000000000 +0200
+@@ -469,6 +469,18 @@
+   }
+ }
+ 
++void mutt_make_greeting (HEADER *hdr, FILE *out, int flags)
++{
++  char buffer[STRING];
++  if (Greeting)
++  {
++    mutt_FormatString(buffer, sizeof(buffer), 0, Greeting, greeting_string,
++		      (unsigned long) hdr, flags);
++    fputs(buffer, out);
++    fputc ('\n', out);
++  }
++}
++
+ void mutt_make_post_indent (CONTEXT *ctx, HEADER *cur, FILE *out)
+ {
+   char buffer[STRING];
+@@ -1003,7 +1015,6 @@
+   }
+ }
+ 
+-
+ /* look through the recipients of the message we are replying to, and if
+    we find an address that matches $alternates, we use that as the default
+    from field */
+@@ -1439,6 +1450,8 @@
+     if (option (OPTHDRS))
+       process_user_header (msg->env);
+ 
++    mutt_make_greeting(msg, tempfp, flags);
++
+     if (flags & SENDBATCH)
+        mutt_copy_stream (stdin, tempfp);
+ 
diff -urN mutt-devel/files/extra-patch-ifdef mutt-devel-1.5.21-ja.2/files/extra-patch-ifdef
--- mutt-devel/files/extra-patch-ifdef	1970-01-01 09:00:00.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/extra-patch-ifdef	2012-07-22 18:15:04.000000000 +0900
@@ -0,0 +1,79 @@
+--- mutt-1.5.4.orig/init.c	2003-03-04 08:49:48.000000000 +0100
++++ mutt-1.5.4/init.c	2003-07-22 20:14:47.000000000 +0200
+@@ -349,6 +349,52 @@ static void remove_from_list (LIST **l, 
+   }
+ }
+ 
++static int parse_ifdef (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err)
++{
++  int i, j, res = 0;
++  BUFFER token;
++
++  memset (&token, 0, sizeof (token));
++  mutt_extract_token (tmp, s, 0);
++
++  /* is the item defined as a variable or a function? */
++  if (!(res = (mutt_option_index (tmp->data) != -1)))
++    for (i = 0; !res && i < MENU_MAX; i++)
++    {
++      struct binding_t *b = km_get_table (Menus[i].value);
++
++      if (!b)
++	continue;
++
++      for (j = 0; b[j].name; j++)
++	if (!ascii_strncasecmp (tmp->data, b[j].name, mutt_strlen (tmp->data))
++	      && (mutt_strlen (b[j].name) == mutt_strlen (tmp->data)))
++	{
++	  res = 1;
++	  break;
++	}
++    }
++
++  if (!MoreArgs (s))
++  {
++    snprintf (err->data, err->dsize, _("ifdef: too few arguments"));
++    return (-1);
++  }
++  mutt_extract_token (tmp, s, M_TOKEN_SPACE);
++
++  if (res)
++  {
++    if (mutt_parse_rc_line (tmp->data, &token, err) == -1)
++    {
++      mutt_error ("Erreur: %s", err->data);
++      FREE (&token.data);
++      return (-1);
++    }
++    FREE (&token.data);
++  }
++  return 0;
++}
++
+ static int parse_unignore (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
+ {
+   do
+diff -pruN mutt-1.5.4.orig/init.h mutt-1.5.4/init.h
+--- mutt-1.5.4.orig/init.h.orig	2009-06-22 15:48:16.000000000 +0200
++++ mutt-1.5.4/init.h	2009-06-22 15:49:28.000000000 +0200
+@@ -3658,6 +3658,7 @@
+ static int parse_unlists (BUFFER *, BUFFER *, unsigned long, BUFFER *);
+ static int parse_alias (BUFFER *, BUFFER *, unsigned long, BUFFER *);
+ static int parse_unalias (BUFFER *, BUFFER *, unsigned long, BUFFER *);
++static int parse_ifdef (BUFFER *, BUFFER *, unsigned long, BUFFER *);
+ static int parse_ignore (BUFFER *, BUFFER *, unsigned long, BUFFER *);
+ static int parse_unignore (BUFFER *, BUFFER *, unsigned long, BUFFER *);
+ static int parse_source (BUFFER *, BUFFER *, unsigned long, BUFFER *);
+@@ -3715,6 +3716,7 @@
+   { "hdr_order",	parse_list,		UL &HeaderOrderList },
+ #ifdef HAVE_ICONV
+   { "iconv-hook",	mutt_parse_hook,	M_ICONVHOOK },
++  { "ifdef",		parse_ifdef,		0 },
+ #endif
+   { "ignore",		parse_ignore,		0 },
+   { "lists",		parse_lists,		0 },
+diff -pruN mutt-1.5.4.orig/PATCHES mutt-1.5.4/PATCHES
+--- mutt-1.5.4.orig/PATCHES	2003-03-19 22:33:37.000000000 +0100
++++ mutt-1.5.4/PATCHES	2003-07-22 20:14:47.000000000 +0200
+@@ -0,0 +1 @@
++patch-1.5.4.cd.ifdef.1
diff -urN mutt-devel/files/extra-patch-maildir-mtime mutt-devel-1.5.21-ja.2/files/extra-patch-maildir-mtime
--- mutt-devel/files/extra-patch-maildir-mtime	1970-01-01 09:00:00.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/extra-patch-maildir-mtime	2012-07-22 18:15:04.000000000 +0900
@@ -0,0 +1,52 @@
+--- PATCHES Dec 2002 17:44:54 -0000	3.6
++++ PATCHES Feb 2004 13:19:42 -0000
+@@ -0,0 +1 @@
++patch-1.5.7.ust.maildir-mtime.2
+--- browser.c.orig	Wed Jan 26 13:41:04 2005
++++ browser.c	Wed Feb  9 09:20:14 2005
+@@ -27,6 +27,7 @@
+ #ifdef USE_IMAP
+ #include "imap.h"
+ #endif
++#include "mx.h"
+ 
+ #include <stdlib.h>
+ #include <dirent.h>
+@@ -346,6 +347,21 @@
+     menu->data = state->entry;
+ }
+ 
++static void check_maildir_times (BUFFY *buf, struct stat *st)
++{
++  char buffer[_POSIX_PATH_MAX + SHORT_STRING];
++  struct stat s;
++
++  if(!buf || buf->magic != M_MAILDIR)
++    return;
++
++  snprintf (buffer, sizeof (buffer), "%s/tmp", buf->path);
++  if (lstat (buffer, &s) != 0)
++    return;
++
++  st->st_mtime = s.st_mtime;
++}
++
+ static int examine_directory (MUTTMENU *menu, struct browser_state *state,
+ 			      char *d, const char *prefix)
+ {
+@@ -409,6 +425,7 @@
+     tmp = Incoming;
+     while (tmp && mutt_strcmp (buffer, tmp->path))
+       tmp = tmp->next;
++    check_maildir_times (tmp, &s);
+     add_folder (menu, state, de->d_name, &s, (tmp) ? tmp->new : 0);
+   }
+   closedir (dp);  
+@@ -454,6 +471,7 @@
+     strfcpy (buffer, NONULL(tmp->path), sizeof (buffer));
+     mutt_pretty_mailbox (buffer);
+ 
++    check_maildir_times (tmp, &s);
+     add_folder (menu, state, buffer, &s, tmp->new);
+   }
+   while ((tmp = tmp->next));
diff -urN mutt-devel/files/extra-patch-maildir-mtime-nntp mutt-devel-1.5.21-ja.2/files/extra-patch-maildir-mtime-nntp
--- mutt-devel/files/extra-patch-maildir-mtime-nntp	1970-01-01 09:00:00.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/extra-patch-maildir-mtime-nntp	2012-07-22 18:15:04.000000000 +0900
@@ -0,0 +1,44 @@
+--- PATCHES Dec 2002 17:44:54 -0000	3.6
++++ PATCHES Feb 2004 13:19:42 -0000
+@@ -0,0 +1 @@
++patch-1.5.7.ust.maildir-mtime.2
+--- browser.c.orig	Tue Feb  8 10:29:57 2005
++++ browser.c	Tue Feb  8 10:29:58 2005
+@@ -31,4 +31,5 @@
+ #include "nntp.h"
+ #endif
++#include "mx.h"
+ 
+ #include <stdlib.h>
+@@ -473,4 +474,19 @@
+ }
+ 
++static void check_maildir_times (BUFFY *buf, struct stat *st)
++{
++  char buffer[_POSIX_PATH_MAX + SHORT_STRING];
++  struct stat s;
++
++  if(!buf || buf->magic != M_MAILDIR)
++    return;
++
++  snprintf (buffer, sizeof (buffer), "%s/tmp", buf->path);
++  if (lstat (buffer, &s) != 0)
++    return;
++
++  st->st_mtime = s.st_mtime;
++}
++
+ /* get list of all files/newsgroups with mask */
+ static int examine_directory (MUTTMENU *menu, struct browser_state *state,
+@@ -562,4 +578,5 @@
+     while (tmp && mutt_strcmp (buffer, tmp->path))
+       tmp = tmp->next;
++    check_maildir_times (tmp, &s);
+     add_folder (menu, state, de->d_name, &s, NULL, (tmp) ? tmp->new : 0);
+   }
+@@ -637,4 +654,5 @@
+     mutt_pretty_mailbox (buffer);
+ 
++    check_maildir_times (tmp, &s);
+     add_folder (menu, state, buffer, &s, NULL, tmp->new);
+   }
diff -urN mutt-devel/files/extra-patch-no-mbox-manpage mutt-devel-1.5.21-ja.2/files/extra-patch-no-mbox-manpage
--- mutt-devel/files/extra-patch-no-mbox-manpage	1970-01-01 09:00:00.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/extra-patch-no-mbox-manpage	2012-07-22 18:15:04.000000000 +0900
@@ -0,0 +1,29 @@
+--- doc/Makefile.am.orig	2008-05-30 08:00:04.000000000 +0100
++++ doc/Makefile.am	2008-09-19 18:55:55.000000000 +0100
+@@ -18,8 +18,6 @@
+ 	gen-map-doc			\
+ 	muttrc.man.head			\
+ 	muttrc.man.tail			\
+-	mbox.man			\
+-	mmdf.man			\
+ 	manual.xml.head			\
+ 	manual.xml.tail			\
+ 	instdoc.sh.in			\
+@@ -57,8 +55,6 @@
+ 	test x@DOTLOCK_TARGET@ = x || ./instdoc $(srcdir)/dotlock.man \
+ 		$(DESTDIR)$(mandir)/man1/mutt_dotlock.1
+ 	./instdoc muttrc.man $(DESTDIR)$(mandir)/man5/muttrc.5
+-	./instdoc $(srcdir)/mbox.man $(DESTDIR)$(mandir)/man5/mbox.5
+-	./instdoc $(srcdir)/mmdf.man $(DESTDIR)$(mandir)/man5/mmdf.5
+ 	$(top_srcdir)/mkinstalldirs $(DESTDIR)$(docdir)
+ 	for f in $(topsrcdir_DOCFILES) ; do \
+ 		$(INSTALL) -m 644 $(top_srcdir)/$$f $(DESTDIR)$(docdir) ; \
+@@ -83,7 +79,7 @@
+ 	for f in mutt.1 mutt_dotlock.1 flea.1 muttbug.1 ; do \
+ 		rm -f $(DESTDIR)$(mandir)/man1/$$f ; \
+ 	done
+-	for f in muttrc.5 mbox.5 mmdf.5 ; do \
++	for f in muttrc.5 ; do \
+ 		rm -f $(DESTDIR)$(mandir)/man5/$$f ; \
+ 	done
+ 	for f in $(srcdir_DOCFILES) $(topsrcdir_DOCFILES) $(HTML_DOCFILES) ; \
diff -urN mutt-devel/files/extra-patch-nodoc-contrib mutt-devel-1.5.21-ja.2/files/extra-patch-nodoc-contrib
--- mutt-devel/files/extra-patch-nodoc-contrib	2012-07-14 22:54:48.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/extra-patch-nodoc-contrib	2012-07-22 18:15:04.000000000 +0900
@@ -9,9 +9,9 @@
  
  bin_SCRIPTS = muttbug flea @SMIMEAUX_TARGET@
  
---- doc/Makefile.am.orig	2009-06-25 14:00:16.000000000 +0900
-+++ doc/Makefile.am	2009-06-25 14:04:02.000000000 +0900
-@@ -59,17 +59,6 @@
+--- doc/Makefile.am.orig	2008-05-19 19:43:38.000000000 +0200
++++ doc/Makefile.am	2008-05-19 19:45:35.000000000 +0200
+@@ -60,14 +60,6 @@
  	./instdoc muttrc.man $(DESTDIR)$(mandir)/man5/muttrc.5
  	./instdoc $(srcdir)/mbox.man $(DESTDIR)$(mandir)/man5/mbox.5
  	./instdoc $(srcdir)/mmdf.man $(DESTDIR)$(mandir)/man5/mmdf.5
@@ -23,9 +23,6 @@
 -		$(INSTALL) -m 644 $(srcdir)/$$f $(DESTDIR)$(docdir) ; \
 -	done
 -	-$(INSTALL) -m 644 manual.txt $(DESTDIR)$(docdir)
--	-for f in $(HTML_DOCFILES) ; do \
--		$(INSTALL) -m 644 $$f $(DESTDIR)$(docdir) ; \
--	done
  	$(INSTALL) -m 644 Muttrc $(DESTDIR)$(sysconfdir)/Muttrc.dist
  	-if [ -f $(DESTDIR)$(pkgdatadir)/Muttrc ] ; then \
  		mv $(DESTDIR)$(pkgdatadir)/Muttrc* $(DESTDIR)$(sysconfdir) ; \
diff -urN mutt-devel/files/extra-patch-parent-child-match mutt-devel-1.5.21-ja.2/files/extra-patch-parent-child-match
--- mutt-devel/files/extra-patch-parent-child-match	1970-01-01 09:00:00.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/extra-patch-parent-child-match	2012-07-22 18:15:04.000000000 +0900
@@ -0,0 +1,169 @@
+--- mutt-1.5.20/doc/manual.xml.head	2009-05-30 19:20:08.000000000 +0200
++++ mutt-1.5.20-parentchildmatch/doc/manual.xml.head	2009-07-18 01:09:23.000000000 +0200
+@@ -3947,6 +3947,22 @@ With the <command>reset</command> comman
+ which allows you to reset all variables to their system defaults.
+ </para>
+ 
++<para>
++<emphasis role="bold">Parent and child match</emphasis>.
++You can tell mutt that the following pattern has to be matched against
++the parent message with &lt; or one of its childs with &gt;.
++This example matches all mails which have at least an unread duplicate
++message:
++</para>
++
++<para>
++
++<screen>
++>(~= ~N)
++</screen>
++
++</para>
++
+ </sect2>
+ 
+ <sect2 id="set-myvar">
+diff -urNp mutt-1.5.20/mutt.h mutt-1.5.20-parentchildmatch/mutt.h
+--- mutt-1.5.20/mutt.h	2009-06-13 00:15:42.000000000 +0200
++++ mutt-1.5.20-parentchildmatch/mutt.h	2009-07-18 01:14:21.000000000 +0200
+@@ -819,6 +819,8 @@ typedef struct pattern_t
+   unsigned int alladdr : 1;
+   unsigned int stringmatch : 1;
+   unsigned int groupmatch : 1;
++  unsigned int parentmatch : 1;
++  unsigned int childsmatch : 1;
+   unsigned int ign_case : 1;		/* ignore case for local stringmatch searches */
+   int min;
+   int max;
+diff -urNp mutt-1.5.20/pattern.c mutt-1.5.20-parentchildmatch/pattern.c
+--- mutt-1.5.20/pattern.c	2009-06-03 22:48:31.000000000 +0200
++++ mutt-1.5.20-parentchildmatch/pattern.c	2009-07-18 01:09:23.000000000 +0200
+@@ -45,6 +45,7 @@ static int eat_regexp (pattern_t *pat, B
+ static int eat_date (pattern_t *pat, BUFFER *, BUFFER *);
+ static int eat_range (pattern_t *pat, BUFFER *, BUFFER *);
+ static int patmatch (const pattern_t *pat, const char *buf);
++static int pattern_exec (struct pattern_t *pat, pattern_exec_flag flags, CONTEXT *ctx, HEADER *h);
+ 
+ static struct pattern_flags
+ {
+@@ -769,6 +770,8 @@ pattern_t *mutt_pattern_comp (/* const *
+   pattern_t *last = NULL;
+   int not = 0;
+   int alladdr = 0;
++  int parentmatch = 0;
++  int childsmatch = 0;
+   int or = 0;
+   int implicit = 1;	/* used to detect logical AND operator */
+   struct pattern_flags *entry;
+@@ -793,6 +796,24 @@ pattern_t *mutt_pattern_comp (/* const *
+ 	ps.dptr++;
+ 	not = !not;
+ 	break;
++      case '<':
++	ps.dptr++;
++	if (childsmatch) {
++	  snprintf (err->data, err->dsize, _("cannot use both < and > as a pattern modifier"));
++	  mutt_pattern_free (&curlist);
++	  return NULL;
++	}
++	parentmatch = 1;
++	break;
++      case '>':
++	ps.dptr++;
++	if (parentmatch) {
++	  snprintf (err->data, err->dsize, _("cannot use both < and > as a pattern modifier"));
++	  mutt_pattern_free (&curlist);
++	  return NULL;
++	}
++	childsmatch = 1;
++	break;
+       case '|':
+ 	if (!or)
+ 	{
+@@ -818,6 +839,8 @@ pattern_t *mutt_pattern_comp (/* const *
+ 	implicit = 0;
+ 	not = 0;
+ 	alladdr = 0;
++	parentmatch = 0;
++	childsmatch = 0;
+ 	break;
+       case '%':
+       case '=':
+@@ -841,8 +864,12 @@ pattern_t *mutt_pattern_comp (/* const *
+ 	  last = tmp;
+ 	  tmp->not ^= not;
+ 	  tmp->alladdr |= alladdr;
++	  tmp->parentmatch |= parentmatch;
++	  tmp->childsmatch |= childsmatch;
+ 	  not = 0;
+ 	  alladdr = 0;
++	  parentmatch = 0;
++	  childsmatch = 0;
+ 	  /* compile the sub-expression */
+ 	  buf = mutt_substrdup (ps.dptr + 1, p);
+ 	  if ((tmp2 = mutt_pattern_comp (buf, flags, err)) == NULL)
+@@ -870,10 +897,14 @@ pattern_t *mutt_pattern_comp (/* const *
+ 	tmp = new_pattern ();
+ 	tmp->not = not;
+ 	tmp->alladdr = alladdr;
++	tmp->parentmatch = parentmatch;
++	tmp->childsmatch = childsmatch;
+         tmp->stringmatch = (*ps.dptr == '=') ? 1 : 0;
+         tmp->groupmatch  = (*ps.dptr == '%') ? 1 : 0;
+ 	not = 0;
+ 	alladdr = 0;
++	parentmatch = 0;
++	childsmatch = 0;
+ 
+ 	if (last)
+ 	  last->next = tmp;
+@@ -939,8 +970,12 @@ pattern_t *mutt_pattern_comp (/* const *
+ 	last = tmp;
+ 	tmp->not ^= not;
+ 	tmp->alladdr |= alladdr;
++	tmp->parentmatch |= parentmatch;
++	tmp->childsmatch |= childsmatch;
+ 	not = 0;
+ 	alladdr = 0;
++	parentmatch = 0;
++	childsmatch = 0;
+ 	ps.dptr = p + 1; /* restore location */
+ 	break;
+       default:
+@@ -1081,6 +1116,36 @@ static int match_threadcomplete(struct p
+ int
+ mutt_pattern_exec (struct pattern_t *pat, pattern_exec_flag flags, CONTEXT *ctx, HEADER *h)
+ {
++  THREAD *t;
++
++  if (pat->parentmatch) {
++    if (h->thread && h->thread->parent && h->thread->parent->message)
++      return pattern_exec (pat, flags, ctx, h->thread->parent->message);
++    else
++      return pat->not;
++  }
++  if (pat->childsmatch) {
++    if (!h->thread)
++      return pat->not;
++    if (!h->thread->child)
++      return pat->not;
++    t = h->thread->child;
++    while (t->prev)
++      t = t->prev;
++    for (; t; t = t->next) {
++      if (!t->message)
++	continue;
++      if (pattern_exec (pat, flags, ctx, t->message))
++	return !pat->not;
++    }
++    return pat->not;
++  }
++  return pattern_exec (pat, flags, ctx, h);
++}
++
++static int
++pattern_exec (struct pattern_t *pat, pattern_exec_flag flags, CONTEXT *ctx, HEADER *h)
++{
+   switch (pat->op)
+   {
+     case M_AND:
diff -urN mutt-devel/files/extra-patch-pgp-dw mutt-devel-1.5.21-ja.2/files/extra-patch-pgp-dw
--- mutt-devel/files/extra-patch-pgp-dw	1970-01-01 09:00:00.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/extra-patch-pgp-dw	2012-07-22 18:15:04.000000000 +0900
@@ -0,0 +1,1039 @@
+--- PATCHES Dec 2002 17:44:54 -0000	3.6
++++ PATCHES Feb 2004 06:07:13 -0000
+@@ -0,0 +1,4 @@
++patch-1.5.6.dw.multiple-crypt-hook.2
++patch-1.5.6.dw.confirm-crypt-hook.1
++patch-1.5.6.dw.crypt-autoselectkey.1
++patch-1.5.6.dw.pgp-menu-traditional.2
+--- compose.c Oct 2003 20:34:59 -0000	3.14
++++ compose.c Feb 2004 06:07:13 -0000
+@@ -133,2 +133,9 @@ static void redraw_crypt_lines (HEADER *
+     addstr (_("Clear"));
++
++  if ((WithCrypto & APPLICATION_PGP))
++    if ((msg->security & (ENCRYPT | SIGN)))
++      if ((msg->security & INLINE))
++	addstr (_(" (inline)"));
++      else
++	addstr (_(" (PGP/MIME)"));
+   clrtoeol ();
+@@ -158,2 +165,3 @@ static int pgp_send_menu (HEADER *msg, i
+ {
++  int use_autoinline = 0;
+   pgp_key_t p;
+@@ -164,7 +172,10 @@ static int pgp_send_menu (HEADER *msg, i
+ 
+-  switch (mutt_multi_choice (_("PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, or (f)orget it? "),
+-			     N_("esabf")))
++  if (!(msg->security & (SIGN | ENCRYPT)))
++    use_autoinline = 1;
++
++  switch (mutt_multi_choice (_("PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, (i)nline, or (f)orget it? "),
++			     N_("esabif")))
+   {
+   case 1: /* (e)ncrypt */
+-    msg->security |= ENCRYPT;
++    msg->security ^= ENCRYPT;
+     break;
+@@ -172,3 +183,3 @@ static int pgp_send_menu (HEADER *msg, i
+   case 2: /* (s)ign */
+-    msg->security |= SIGN;
++    msg->security ^= SIGN;
+     break;
+@@ -199,6 +210,16 @@ static int pgp_send_menu (HEADER *msg, i
+   case 4: /* (b)oth */
+-    msg->security = ENCRYPT | SIGN;
++    if ((msg->security & (ENCRYPT | SIGN)) == (ENCRYPT | SIGN))
++      msg->security = 0;
++    else
++      msg->security |= (ENCRYPT | SIGN);
+     break;
+ 
+-  case 5: /* (f)orget it */
++  case 5: /* (i)nline */
++    if ((msg->security & (ENCRYPT | SIGN)))
++      msg->security ^= INLINE;
++    else
++      msg->security &= ~INLINE;
++    break;
++
++  case 6: /* (f)orget it */
+     msg->security = 0;
+@@ -207,6 +228,16 @@ static int pgp_send_menu (HEADER *msg, i
+ 
+-  if (msg->security && msg->security != APPLICATION_PGP)
+-    msg->security |= APPLICATION_PGP;
+-  else
+-    msg->security = 0;
++  if (msg->security)
++  {
++    if (!(msg->security & (ENCRYPT | SIGN)))
++    {
++      msg->security = 0;
++    }
++    else
++    {
++      msg->security |= APPLICATION_PGP;
++
++      if (use_autoinline && option (OPTPGPAUTOINLINE))
++	msg->security |= INLINE;
++    }
++  }
+ 
+--- crypt.c Jan 2004 19:59:38 -0000	3.22
++++ crypt.c Feb 2004 06:07:13 -0000
+@@ -161,3 +161,3 @@ int crypt_valid_passphrase(int flags)
+ 
+-int mutt_protect (HEADER *msg, HEADER *cur, char *keylist)
++int mutt_protect (HEADER *msg, char *keylist)
+ {
+@@ -166,3 +166,2 @@ int mutt_protect (HEADER *msg, HEADER *c
+   BODY *tmp_pgp_pbody = NULL;
+-  int traditional = 0;
+   int flags = (WithCrypto & APPLICATION_PGP)? msg->security: 0;
+@@ -176,29 +175,9 @@ int mutt_protect (HEADER *msg, HEADER *c
+ 
+-  if ((WithCrypto & APPLICATION_PGP) && (msg->security & APPLICATION_PGP))
++  if ((WithCrypto & APPLICATION_PGP) && ((msg->security & PGPINLINE) == PGPINLINE))
+   {
+-    if ((msg->content->type == TYPETEXT) &&
+-	!ascii_strcasecmp (msg->content->subtype, "plain"))
+-    {
+-      if (cur && cur->security && option (OPTPGPAUTOTRAD)
+-	  && (option (OPTCRYPTREPLYENCRYPT)
+-	      || option (OPTCRYPTREPLYSIGN)
+-	      || option (OPTCRYPTREPLYSIGNENCRYPTED)))
+-	{
+-	  if(mutt_is_application_pgp(cur->content))
+-	    traditional = 1;
+-	}
+-      else
+-	{
+-	  if ((i = query_quadoption (OPT_PGPTRADITIONAL, _("Create a traditional (inline) PGP message?"))) == -1)
+-	    return -1;
+-	  else if (i == M_YES)
+-	    traditional = 1;
+-	}
+-    }
+-    if (traditional)
++    /* they really want to send it inline... go for it */
++    if (!isendwin ()) mutt_endwin _("Invoking PGP...");
++    pbody = crypt_pgp_traditional_encryptsign (msg->content, flags, keylist);
++    if (pbody)
+     {
+-      if (!isendwin ()) mutt_endwin _("Invoking PGP...");
+-      if (!(pbody = crypt_pgp_traditional_encryptsign (msg->content, flags, keylist)))
+-	return -1;
+-
+       msg->content = pbody;
+@@ -206,2 +185,8 @@ int mutt_protect (HEADER *msg, HEADER *c
+     }
++
++    /* otherwise inline won't work...ask for revert */
++    if ((i = query_quadoption (OPT_PGPMIMEASK, _("Message can't be sent inline.  Revert to using PGP/MIME?"))) != M_YES)
++      return -1;
++
++    /* go ahead with PGP/MIME */
+   }
+@@ -393,2 +378,5 @@ int mutt_is_application_pgp (BODY *m)
+   }
++  if (t)
++    t |= PGPINLINE;
++
+   return t;
+--- hook.c Jan 2004 09:52:55 -0000	3.8
++++ hook.c Feb 2004 06:07:13 -0000
+@@ -119,3 +119,7 @@ int mutt_parse_hook (BUFFER *buf, BUFFER
+     {
++#ifdef M_CRYPTHOOK
++      if (data & (M_FOLDERHOOK | M_SENDHOOK | M_MESSAGEHOOK | M_ACCOUNTHOOK | M_REPLYHOOK | M_CRYPTHOOK))
++#else
+       if (data & (M_FOLDERHOOK | M_SENDHOOK | M_MESSAGEHOOK | M_ACCOUNTHOOK | M_REPLYHOOK))
++#endif
+       {
+@@ -445,5 +449,21 @@ char *mutt_iconv_hook (const char *chs)
+ 
+-char *mutt_crypt_hook (ADDRESS *adr)
++LIST *mutt_crypt_hook (ADDRESS *adr)
+ {
+-  return _mutt_string_hook (adr->mailbox, M_CRYPTHOOK);
++  HOOK *hook;
++  LIST *key_list = NULL;
++
++  if (!adr && !adr->mailbox)
++    return (NULL);
++
++  for (hook = Hooks; hook; hook = hook->next)
++  {
++    if (!hook->command)
++      continue;
++    if (!(hook->type & M_CRYPTHOOK))
++      continue;
++
++    if ((regexec (hook->rx.rx, adr->mailbox, 0, NULL, 0) == 0) ^ hook->rx.not)
++      key_list = mutt_add_list (key_list, hook->command);
++  }
++  return (key_list);
+ }
+--- init.h Feb 2004 17:10:43 -0000	3.43
++++ init.h Feb 2004 06:07:14 -0000
+@@ -1205,2 +1205,12 @@ struct option_t MuttVars[] = {
+   */
++  
++
++  { "pgp_autoselectkey",	DT_SYN,  R_NONE, UL "crypt_autoselectkey", 0 },
++  { "crypt_autoselectkey",	DT_BOOL, R_NONE, OPTCRYPTAUTOSELECT, 0 },
++  /*
++  ** .pp
++  ** If set, then a list of keys is not presented for selection when only
++  ** one matching key is available.  This may be useful in conjunction with
++  ** the \fIcrypt-hook\fP command.
++  */
+   { "pgp_autosign", 	DT_SYN,  R_NONE, UL "crypt_autosign", 0 },
+@@ -1230,2 +1240,11 @@ struct option_t MuttVars[] = {
+   */
++  { "pgp_confirmhook",		DT_SYN, R_NONE, UL "crypt_confirmhook", 1 },
++  { "crypt_confirmhook",	DT_BOOL, R_NONE, OPTCRYPTCONFIRMHOOK, 1 },
++  /*
++  ** .pp
++  ** If set, then you will be prompted for confirmation of keys when using
++  ** the \fIcrypt-hook\fP command.  If unset, no such confirmation prompt will
++  ** be presented.  This is generally considered unsafe, especially where
++  ** typos are concerned.
++  */
+   { "pgp_ignore_subkeys", DT_BOOL, R_NONE, OPTPGPIGNORESUB, 1},
+@@ -1374,2 +1393,44 @@ struct option_t MuttVars[] = {
+   */
++  { "pgp_create_traditional",	DT_SYN, R_NONE, UL "pgp_autoinline", 0 },
++  { "pgp_autoinline",		DT_BOOL, R_NONE, OPTPGPAUTOINLINE, 0 },
++  /*
++  ** .pp
++  ** This option controls whether Mutt generates old-style inline
++  ** (traditional) PGP encrypted or signed messages under certain
++  ** circumstances.  This can be overridden by use of the \fIpgp-menu\fP,
++  ** when inline is not required.
++  ** .pp
++  ** Note that Mutt might automatically use PGP/MIME for messages
++  ** which consist of more than a single MIME part.  Mutt can be
++  ** configured to ask before sending PGP/MIME messages when inline
++  ** (traditional) would not work.
++  ** See also: ``$$pgp_mime_ask''.
++  ** .pp
++  ** Also note that using the old-style PGP message format is \fBstrongly\fP
++  ** \fBdeprecated\fP.
++  ** (PGP only)
++  */
++  { "pgp_auto_traditional",	DT_SYN, R_NONE, UL "pgp_replyinline", 0 },
++  { "pgp_replyinline",		DT_BOOL, R_NONE, OPTPGPREPLYINLINE, 0 },
++  /*
++  ** .pp
++  ** Setting this variable will cause Mutt to always attempt to
++  ** create an inline (traditional) message when replying to a
++  ** message which is PGP encrypted/signed inline.  This can be
++  ** overridden by use of the \fIpgp-menu\fP, when inline is not
++  ** required.  This option does not automatically detect if the
++  ** (replied-to) message is inline; instead it relies on Mutt
++  ** internals for previously checked/flagged messages.
++  ** .pp
++  ** Note that Mutt might automatically use PGP/MIME for messages
++  ** which consist of more than a single MIME part.  Mutt can be
++  ** configured to ask before sending PGP/MIME messages when inline
++  ** (traditional) would not work.
++  ** See also: ``$$pgp_mime_ask''.
++  ** .pp
++  ** Also note that using the old-style PGP message format is \fBstrongly\fP
++  ** \fBdeprecated\fP.
++  ** (PGP only)
++  ** 
++  */
+   { "pgp_show_unusable", DT_BOOL, R_NONE, OPTPGPSHOWUNUSABLE, 1 },
+@@ -1423,11 +1484,8 @@ struct option_t MuttVars[] = {
+   */
+-  { "pgp_create_traditional", DT_QUAD, R_NONE, OPT_PGPTRADITIONAL, M_NO },
++  { "pgp_mime_ask", DT_QUAD, R_NONE, OPT_PGPMIMEASK, M_NO },
+   /*
+   ** .pp
+-  ** This option controls whether Mutt generates old-style inline PGP
+-  ** encrypted or signed messages.
+-  ** .pp
+-  ** Note that PGP/MIME will be used automatically for messages which have
+-  ** a character set different from us-ascii, or which consist of more than
+-  ** a single MIME part.
++  ** This option controls whether Mutt will prompt you for
++  ** automatically sending a (signed/encrypted) message using
++  ** PGP/MIME when inline (traditional) fails (for any reason).
+   ** .pp
+@@ -1435,19 +1493,2 @@ struct option_t MuttVars[] = {
+   ** \fBdeprecated\fP.
+-  ** (PGP only)
+-  */
+-  { "pgp_auto_traditional", DT_BOOL, R_NONE, OPTPGPAUTOTRAD, 0 },
+-  /*
+-  ** .pp
+-  ** This option causes Mutt to generate an old-style inline PGP
+-  ** encrypted or signed message when replying to an old-style
+-  ** message, and a PGP/MIME message when replying to a PGP/MIME
+-  ** message.  Note that this option is only meaningful when using
+-  ** ``$$crypt_replyencrypt'', ``$$crypt_replysign'', or
+-  ** ``$$crypt_replysignencrypted''.
+-  ** .pp
+-  ** Also note that PGP/MIME will be used automatically for messages
+-  ** which have a character set different from us-ascii, or which
+-  ** consist of more than a single MIME part.
+-  ** .pp
+-  ** This option overrides ``$$pgp_create_traditional''
+   ** (PGP only)
+--- mutt.h Feb 2004 17:10:43 -0000	3.23
++++ mutt.h Feb 2004 06:07:14 -0000
+@@ -278,3 +278,2 @@ enum
+   OPT_MOVE,
+-  OPT_PGPTRADITIONAL, /* create old-style PGP messages */
+ #ifdef USE_POP
+@@ -284,2 +283,3 @@ enum
+   OPT_POSTPONE,
++  OPT_PGPMIMEASK,     /* ask to revert to PGP/MIME when inline fails */
+   OPT_PRINT,
+@@ -431,2 +431,3 @@ enum
+   
++  OPTCRYPTAUTOSELECT,
+   OPTCRYPTAUTOSIGN,
+@@ -442,2 +443,3 @@ enum
+   OPTSDEFAULTDECRYPTKEY,
++  OPTCRYPTCONFIRMHOOK,
+   OPTPGPIGNORESUB,
+@@ -445,3 +447,2 @@ enum
+   OPTPGPLONGIDS,
+-  OPTPGPAUTOTRAD,
+ #if 0
+@@ -453,2 +454,4 @@ enum
+   OPTPGPSHOWUNUSABLE,
++  OPTPGPAUTOINLINE,
++  OPTPGPREPLYINLINE,
+ 
+@@ -642,4 +645,4 @@ typedef struct header
+ {
+-  unsigned int security : 9;  /* bit 0-6: flags, bit 7,8: application.
+-				 see: crypt.h pgplib.h, smime.h */
++  unsigned int security : 10;  /* bit 0-7: flags, bit 8,9: application.
++				 see: mutt_crypt.h */
+ 
+--- mutt_crypt.h Dec 2003 13:04:20 -0000	3.5
++++ mutt_crypt.h Feb 2004 06:07:14 -0000
+@@ -38,6 +38,7 @@
+ #define SIGNOPAQUE (1 << 5)
+-/* (1 << 6) is used by PGPKEY below. */
++#define KEYBLOCK   (1 << 6) /* KEY too generic? */
++#define INLINE     (1 << 7)
+ 
+-#define APPLICATION_PGP    (1 << 7) 
+-#define APPLICATION_SMIME  (1 << 8)
++#define APPLICATION_PGP    (1 << 8) 
++#define APPLICATION_SMIME  (1 << 9)
+ 
+@@ -46,3 +47,4 @@
+ #define PGPGOODSIGN (APPLICATION_PGP | GOODSIGN)
+-#define PGPKEY      (APPLICATION_PGP | (1 << 6)) 
++#define PGPKEY      (APPLICATION_PGP | KEYBLOCK) 
++#define PGPINLINE   (APPLICATION_PGP | INLINE)
+ 
+@@ -105,3 +107,3 @@ typedef struct pgp_keyinfo *pgp_key_t;
+ 
+-int mutt_protect (HEADER *, HEADER *, char *);
++int mutt_protect (HEADER *, char *);
+ 
+--- pgp.c Sep 2003 13:03:26 -0000	3.26
++++ pgp.c Feb 2004 06:07:14 -0000
+@@ -1018,2 +1018,4 @@ char *pgp_findKeys (ADDRESS *to, ADDRESS
+   size_t keylist_used = 0;
++  LIST *hook_list = NULL;
++  LIST *hook = NULL;
+   ADDRESS *tmp = NULL, *addr = NULL;
+@@ -1051,66 +1053,93 @@ char *pgp_findKeys (ADDRESS *to, ADDRESS
+     q = p;
+-    k_info = NULL;
+ 
+-    if ((keyID = mutt_crypt_hook (p)) != NULL)
++    /*
++     * grab the list of matching hooks (matching on recipient address)
++     * process each entry singly so that auto key selection still works
++     */
++    hook_list = mutt_crypt_hook (p);
++    hook = hook_list;
++    while (1)
+     {
+       int r;
+-      snprintf (buf, sizeof (buf), _("Use keyID = \"%s\" for %s?"), keyID, p->mailbox);
+-      if ((r = mutt_yesorno (buf, M_YES)) == M_YES)
++
++      k_info = NULL;
++      key = NULL;
++
++      if (hook)
+       {
+-	if (is_numerical_keyid (keyID))
++	keyID = (char *)hook->data;
++	snprintf (buf, sizeof (buf), _("Use keyID = \"%s\" for %s?"), keyID, p->mailbox);
++	if (!option(OPTCRYPTCONFIRMHOOK) || (r = mutt_yesorno (buf, M_YES)) == M_YES)
+ 	{
+-	  if (strncmp (keyID, "0x", 2) == 0)
+-	    keyID += 2;
+-	  goto bypass_selection;		/* you don't see this. */
++	  if (is_numerical_keyid (keyID))
++	  {
++	    if (strncmp (keyID, "0x", 2) == 0)
++	      keyID += 2;
++	    goto bypass_selection;		/* you don't see this. */
++	  }
++
++	  /* check for e-mail address */
++	  if ((t = strchr (keyID, '@')) && 
++	      (addr = rfc822_parse_adrlist (NULL, keyID)))
++	  {
++	    if (fqdn) rfc822_qualify (addr, fqdn);
++	    q = addr;
++	  }
++	  else
++	    k_info = pgp_getkeybystr (keyID, KEYFLAG_CANENCRYPT, PGP_PUBRING);
+ 	}
+-	
+-	/* check for e-mail address */
+-	if ((t = strchr (keyID, '@')) && 
+-	    (addr = rfc822_parse_adrlist (NULL, keyID)))
++	else if (r == -1)
+ 	{
+-	  if (fqdn) rfc822_qualify (addr, fqdn);
+-	  q = addr;
++	  /*
++	   * yes, this implies that if one key fails they all do
++	   */
++	  FREE (&keylist);
++	  rfc822_free_address (&tmp);
++	  rfc822_free_address (&addr);
++	  mutt_free_list (&hook_list);
++	  return NULL;
+ 	}
+-	else
+-	  k_info = pgp_getkeybystr (keyID, KEYFLAG_CANENCRYPT, PGP_PUBRING);
+       }
+-      else if (r == -1)
+-      {
+-	FREE (&keylist);
+-	rfc822_free_address (&tmp);
+-	rfc822_free_address (&addr);
+-	return NULL;
+-      }
+-    }
+ 
+-    if (k_info == NULL)
+-      pgp_invoke_getkeys (q);
+-
+-    if (k_info == NULL && (k_info = pgp_getkeybyaddr (q, KEYFLAG_CANENCRYPT, PGP_PUBRING)) == NULL)
+-    {
+-      snprintf (buf, sizeof (buf), _("Enter keyID for %s: "), q->mailbox);
++      if (k_info == NULL)
++	pgp_invoke_getkeys (q);
+ 
+-      if ((key = pgp_ask_for_key (buf, q->mailbox,
+-				  KEYFLAG_CANENCRYPT, PGP_PUBRING)) == NULL)
++      if (k_info == NULL && (k_info = pgp_getkeybyaddr (q, KEYFLAG_CANENCRYPT, PGP_PUBRING)) == NULL)
+       {
+-	FREE (&keylist);
+-	rfc822_free_address (&tmp);
+-	rfc822_free_address (&addr);
+-	return NULL;
++	snprintf (buf, sizeof (buf), _("Enter keyID for %s: "), q->mailbox);
++
++	if ((key = pgp_ask_for_key (buf, q->mailbox,
++				    KEYFLAG_CANENCRYPT, PGP_PUBRING)) == NULL)
++	{
++	  FREE (&keylist);
++	  rfc822_free_address (&tmp);
++	  rfc822_free_address (&addr);
++	  mutt_free_list (&hook_list);
++	  return NULL;
++	}
+       }
+-    }
+-    else
+-      key = k_info;
++      else
++	key = k_info;
+ 
+-    keyID = pgp_keyid (key);
++      keyID = pgp_keyid (key);
+     
+   bypass_selection:
+-    keylist_size += mutt_strlen (keyID) + 4;
+-    safe_realloc (&keylist, keylist_size);
+-    sprintf (keylist + keylist_used, "%s0x%s", keylist_used ? " " : "",	/* __SPRINTF_CHECKED__ */
+-	     keyID);
+-    keylist_used = mutt_strlen (keylist);
++      keylist_size += mutt_strlen (keyID) + 4;
++      safe_realloc (&keylist, keylist_size);
++      sprintf (keylist + keylist_used, "%s0x%s", keylist_used ? " " : "",	/* __SPRINTF_CHECKED__ */
++	       keyID);
++      keylist_used = mutt_strlen (keylist);
+ 
+-    pgp_free_key (&key);
+-    rfc822_free_address (&addr);
++      pgp_free_key (&key);
++      rfc822_free_address (&addr);
++
++      if (!hook_list)
++	break;
++
++      hook = hook->next;
++      if (!hook)
++	break;
++
++    }
++    mutt_free_list (&hook_list);
+ 
+--- pgpkey.c Oct 2003 19:55:39 -0000	3.8
++++ pgpkey.c Feb 2004 06:07:14 -0000
+@@ -437,4 +437,9 @@ static int pgp_id_matches_addr (ADDRESS 
+ 
++
++#define pgp_trusted_id(uid) (!option(OPTPGPCHECKTRUST) \
++			     || (pgp_id_is_valid((uid)) \
++				 && pgp_id_is_strong((uid))))
++
+ static pgp_key_t pgp_select_key (pgp_key_t keys,
+-                                 ADDRESS * p, const char *s)
++				  ADDRESS * p, const char *s)
+ {
+@@ -452,2 +457,3 @@ static pgp_key_t pgp_select_key (pgp_key
+ 
++  int keymatch = 0;		/* count matching keys */
+   int unusable = 0;
+@@ -481,2 +487,3 @@ static pgp_key_t pgp_select_key (pgp_key
+     }
++    keymatch++;
+   }
+@@ -489,2 +496,17 @@ static pgp_key_t pgp_select_key (pgp_key
+   }
++  else if (keymatch == 1 && option(OPTCRYPTAUTOSELECT))
++  {
++    /*
++     * Only one matching key...see if there's an id with enough trust to auto-select
++     */
++    kp = KeyTable[0]->parent;
++    for (a = kp->address; a; a = a->next)
++    {
++      if (pgp_trusted_id(a))
++      {
++	safe_free ((void **) &KeyTable);
++	return (kp);
++      }
++    }
++  }
+ 
+@@ -599,5 +621,3 @@ static pgp_key_t pgp_select_key (pgp_key
+       
+-      if (option (OPTPGPCHECKTRUST) &&
+-	  (!pgp_id_is_valid (KeyTable[menu->current])
+-	   || !pgp_id_is_strong (KeyTable[menu->current])))
++      if (!pgp_trusted_id(KeyTable[menu->current]))
+       {
+--- postpone.c Sep 2003 17:22:09 -0000	3.9
++++ postpone.c Feb 2004 06:07:14 -0000
+@@ -486,2 +486,7 @@ int mutt_parse_crypt_hdr (char *p, int s
+ 
++      case 'i':
++      case 'I':
++	pgp |= INLINE;
++	break;
++
+       default:
+--- protos.h Feb 2004 17:10:43 -0000	3.19
++++ protos.h Feb 2004 06:07:14 -0000
+@@ -131,3 +131,3 @@ const char *mutt_get_name (ADDRESS *);
+ char *mutt_get_parameter (const char *, PARAMETER *);
+-char *mutt_crypt_hook (ADDRESS *);
++LIST *mutt_crypt_hook (ADDRESS *);
+ char *mutt_make_date (char *, size_t);
+--- send.c Jan 2004 10:03:46 -0000	3.29
++++ send.c Feb 2004 06:07:14 -0000
+@@ -1258,2 +1258,9 @@ ci_send_message (int flags,		/* send mod
+ 	msg->security |= SIGN;
++      if ((WithCrypto & APPLICATION_PGP) && (msg->security & (ENCRYPT | SIGN)))
++      {
++	if (option (OPTPGPAUTOINLINE))
++	  msg->security |= INLINE;
++	if (option (OPTPGPREPLYINLINE) && cur && (cur->security & INLINE))
++	  msg->security |= INLINE;
++      }
+     }      
+@@ -1496,3 +1503,3 @@ main_loop:
+       if ((crypt_get_keys (msg, &pgpkeylist) == -1) ||
+-          mutt_protect (msg, cur, pgpkeylist) == -1)
++          mutt_protect (msg, pgpkeylist) == -1)
+       {
+@@ -1576,3 +1583,3 @@ main_loop:
+ 
+-	  if (mutt_protect (msg, cur, pgpkeylist) == -1)
++	  if (mutt_protect (msg, pgpkeylist) == -1)
+ 	  {
+--- sendlib.c Sep 2003 13:03:26 -0000	3.24
++++ sendlib.c Feb 2004 06:07:14 -0000
+@@ -2407,2 +2407,4 @@ int mutt_write_fcc (const char *path, HE
+     }
++    if (hdr->security & INLINE)
++      fputc ('I', msg->fp);
+     fputc ('\n', msg->fp);
+--- doc/manual.sgml.head Feb 2004 17:45:33 -0000	3.26
++++ doc/manual.sgml.head Feb 2004 06:07:15 -0000
+@@ -1450,3 +1450,5 @@ normally use.  The crypt-hook command pr
+ specify the ID of the public key to be used when encrypting messages to
+-a certain recipient.
++a certain recipient.  You may use multiple pgp-hook's with the same
++pattern; multiple matching pgp-hook's result in the use of multiple
++keyids for recipient.
+ 
+--- doc/muttrc.man.head Feb 2004 17:10:43 -0000	3.10
++++ doc/muttrc.man.head Feb 2004 06:07:15 -0000
+@@ -297,3 +297,6 @@ to a certain recipient.  The meaning of 
+ broadly: This can be a different e-mail address, a numerical key ID,
+-or even just an arbitrary search string.
++or even just an arbitrary search string.  You may use multiple
++\fBpgp-hook\fPs with the same \fIpattern\fP; multiple matching
++\fBpgp-hook\fPs result in the use of multiple \fIkey-id\fPs for
++recipient.
+ .TP
+--- po/ca.po Feb 2004 18:26:11 -0000	3.13
++++ po/ca.po Feb 2004 06:07:15 -0000
+@@ -603,10 +603,10 @@ msgstr "Xifra amb: "
+ #: compose.c:165
+-msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, or (f)orget it? "
+-msgstr "PGP: (x)ifra, (s)igna, si(g)na com a, (a)mbdóó, o en (c)lar? "
++msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, (i)nline, or (f)orget it? "
++msgstr "PGP: (x)ifra, (s)igna, s(i)gna com a, (a)mbdóó, en (l)íîia, o en (c)lar? "
+ 
+ # ivb (2003/03/26)
+-# ivb  (x)ifra, (s)igna, si(g)na com a, (a)mbdóó, (c)lar
++# ivb  (x)ifra, (s)igna, s(i)gna com a, (a)mbdóó, en (l)íîia, o en (c)lar
+ #: compose.c:166
+-msgid "esabf"
+-msgstr "xsgac"
++msgid "esabif"
++msgstr "xsialc"
+ 
+--- po/cs.po Feb 2004 18:26:11 -0000	3.12
++++ po/cs.po Feb 2004 06:07:16 -0000
+@@ -683,4 +683,4 @@ msgstr "Za¹éfrovat pomocíº"
+ #: compose.c:165
+-msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, or (f)orget it? "
+-msgstr "PGP - (¹©ifrovat, (p)odepsat, podepsat (j)ako, (o)bojí¬ èé (n)ic?"
++msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, (i)nline, or (f)orget it? "
++msgstr "PGP - (¹©ifrovat, (p)odepsat, podepsat (j)ako, (o)bojí¬ pøí(m)ý¬ èé (n)ic?"
+ 
+@@ -688,4 +688,4 @@ msgstr "PGP - (¹©ifrovat, (p)odepsat, po
+ #: compose.c:166
+-msgid "esabf"
+-msgstr "¹ðjon"
++msgid "esabif"
++msgstr "¹ðjomn"
+ 
+--- po/da.po Feb 2004 18:26:11 -0000	3.11
++++ po/da.po Feb 2004 06:07:16 -0000
+@@ -578,8 +578,8 @@ msgstr "Kryptéò"
+ #, fuzzy
+-msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, or (f)orget it? "
+-msgstr "(k)ryptéò, (u)nderskriv, underskriv (s)om, (b)egge, (i)ngen PGP"
++msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, (i)nline, or (f)orget it? "
++msgstr "(k)ryptéò, (u)nderskriv, underskriv (s)om, (b)egge, i(n)tegreret, (i)ngen PGP"
+ 
+ #: compose.c:166
+-msgid "esabf"
+-msgstr "kusbi"
++msgid "esabif"
++msgstr "kusbni"
+ 
+--- po/de.po Feb 2004 18:26:11 -0000	3.15
++++ po/de.po Feb 2004 06:07:16 -0000
+@@ -569,8 +569,8 @@ msgstr "Verschlüóseln mit: "
+ #: compose.c:165
+-msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, or (f)orget it? "
+-msgstr "PGP (v)erschl., (s)ign., sign. (a)ls, (b)eides, (k)ein PGP? "
++msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, (i)nline, or (f)orget it? "
++msgstr "PGP (v)erschl., (s)ign., sign. (a)ls, (b)eides, (i)nline, (k)ein PGP? "
+ 
+ #: compose.c:166
+-msgid "esabf"
+-msgstr "vsabk"
++msgid "esabif"
++msgstr "vsabik"
+ 
+--- po/el.po Feb 2004 18:26:11 -0000	3.12
++++ po/el.po Feb 2004 06:07:17 -0000
+@@ -700,4 +700,4 @@ msgstr "ÊñõðôïãñÜöçóç ìå: "
+ #: compose.c:165
+-msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, or (f)orget it? "
+-msgstr "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, Ýþ(f)orget it? "
++msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, (i)nline, or (f)orget it? "
++msgstr "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, (i)êåßìåíï¬ Ýþ(f)orget it? "
+ 
+@@ -706,4 +706,4 @@ msgstr "PGP (e)ncrypt, (s)ign, sign (a)s
+ #: compose.c:166
+-msgid "esabf"
+-msgstr "esabf"
++msgid "esabif"
++msgstr "esabif"
+ 
+--- po/eo.po Feb 2004 18:26:11 -0000	3.13
++++ po/eo.po Feb 2004 06:07:17 -0000
+@@ -571,8 +571,8 @@ msgstr "Æéfri per: "
+ #: compose.c:165
+-msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, or (f)orget it? "
+-msgstr "PGP æ¨i)fri, (s)ubskribi, subskribi (k)iel, (a)mbaý¬ aý (f)orgesi? "
++msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, (i)nline, or (f)orget it? "
++msgstr "PGP æ¨i)fri, (s)ubskribi, subskribi (k)iel, (a)mbaý¬ \"i(n)line\", aý (f)orgesi? "
+ 
+ #: compose.c:166
+-msgid "esabf"
+-msgstr "iskaf"
++msgid "esabif"
++msgstr "iskanf"
+ 
+--- po/es.po Feb 2004 18:26:11 -0000	3.14
++++ po/es.po Feb 2004 06:07:17 -0000
+@@ -576,4 +576,4 @@ msgstr "Cifrar"
+ #, fuzzy
+-msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, or (f)orget it? "
+-msgstr "¿ão(d)ificar, f(i)rmar (c)omo, amb(o)s o ca(n)celar? "
++msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, (i)nline, or (f)orget it? "
++msgstr "¿ão(d)ificar, f(i)rmar (c)omo, amb(o)s, inc(l)uido, o ca(n)celar? "
+ 
+@@ -581,4 +581,4 @@ msgstr "¿ão(d)ificar, f(i)rmar (c)omo, a
+ #, fuzzy
+-msgid "esabf"
+-msgstr "dicon"
++msgid "esabif"
++msgstr "dicoln"
+ 
+--- po/et.po Feb 2004 18:26:11 -0000	3.13
++++ po/et.po Feb 2004 06:07:18 -0000
+@@ -571,8 +571,8 @@ msgstr "Krüðti kasutades: "
+ #: compose.c:165
+-msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, or (f)orget it? "
+-msgstr "PGP (k)rüðti, (a)llkiri, allk. ku(i), (m)õìemad võé (u)nusta? "
++msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, (i)nline, or (f)orget it? "
++msgstr "PGP (k)rüðti, (a)llkiri, allk. ku(i), (m)õìemad, k(e)hasse, võé (u)nusta? "
+ 
+ #: compose.c:166
+-msgid "esabf"
+-msgstr "kaimu"
++msgid "esabif"
++msgstr "kaimeu"
+ 
+--- po/fr.po Feb 2004 18:26:11 -0000	3.23
++++ po/fr.po Feb 2004 06:07:18 -0000
+@@ -596,8 +596,8 @@ msgstr "Chiffrer avec : "
+ #: compose.c:165
+-msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, or (f)orget it? "
+-msgstr "(c)hiffrer PGP, (s)igner, (e)n tant que, les (d)eux, ou (o)ublier ? "
++msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, (i)nline, or (f)orget it? "
++msgstr "(c)hiffrer PGP, (s)igner, (e)n tant que, les (d)eux, en (l)igne, ou (o)ublier ? "
+ 
+ #: compose.c:166
+-msgid "esabf"
+-msgstr "csedo"
++msgid "esabif"
++msgstr "csedlo"
+ 
+--- po/gl.po Feb 2004 18:26:11 -0000	3.11
++++ po/gl.po Feb 2004 06:07:18 -0000
+@@ -580,8 +580,8 @@ msgstr "Encriptar"
+ #, fuzzy
+-msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, or (f)orget it? "
+-msgstr "¿¨e)ncriptar, (f)irmar, firmar (c)omo, (a)mbas ou (o)lvidar? "
++msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, (i)nline, or (f)orget it? "
++msgstr "¿¨e)ncriptar, (f)irmar, firmar (c)omo, (a)mbas, (i)nterior, ou (o)lvidar? "
+ 
+ #: compose.c:166
+-msgid "esabf"
+-msgstr "efcao"
++msgid "esabif"
++msgstr "efcaio"
+ 
+--- po/hu.po Feb 2004 18:26:11 -0000	3.12
++++ po/hu.po Feb 2004 06:07:19 -0000
+@@ -571,8 +571,8 @@ msgstr "Titkosíôáó: "
+ #: compose.c:165
+-msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, or (f)orget it? "
+-msgstr "PGP (t)itkosíô, (a)láír, aláír (m)int, titkosíô é¨s) aláír, mé¨g)se? "
++msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, (i)nline, or (f)orget it? "
++msgstr "PGP (t)itkosíô, (a)láír, aláír (m)int, titkosíô é¨s) aláír, (b)eáçyazott, mé¨g)se? "
+ 
+ #: compose.c:166
+-msgid "esabf"
+-msgstr "tamsg"
++msgid "esabif"
++msgstr "tamsbg"
+ 
+--- po/id.po Feb 2004 18:26:12 -0000	3.14
++++ po/id.po Feb 2004 06:07:19 -0000
+@@ -572,8 +572,8 @@ msgstr "Enkrip dengan: "
+ #: compose.c:165
+-msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, or (f)orget it? "
+-msgstr "PGP (e)nkrip, (t)andatangan, tandatangan (s)bg, ke(d)uanya, (b)atal? "
++msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, (i)nline, or (f)orget it? "
++msgstr "PGP (e)nkrip, (t)andatangan, tandatangan (s)bg, ke(d)uanya, (i)nline, (b)atal? "
+ 
+ #: compose.c:166
+-msgid "esabf"
+-msgstr "etsdb"
++msgid "esabif"
++msgstr "etsdib"
+ 
+--- po/it.po Feb 2004 18:26:12 -0000	3.11
++++ po/it.po Feb 2004 06:07:19 -0000
+@@ -582,8 +582,8 @@ msgstr "Crittografa"
+ #, fuzzy
+-msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, or (f)orget it? "
+-msgstr "cifra(e), firma(s), firma come(a), entrambi(b), annulla(f) "
++msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, (i)nline, or (f)orget it? "
++msgstr "cifra(e), firma(s), firma come(a), entrambi(b), in l(i)nea , annulla(f) "
+ 
+ #: compose.c:166
+-msgid "esabf"
+-msgstr "esabf"
++msgid "esabif"
++msgstr "esabif"
+ 
+--- po/ja.po Feb 2004 18:26:12 -0000	3.21
++++ po/ja.po Feb 2004 06:07:20 -0000
+@@ -569,8 +569,8 @@ msgstr "  °Å¹æ²½Êý¼°: "
+ #: compose.c:165
+-msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, or (f)orget it? "
+-msgstr "PGP (e)°Å¹æ²½,(s)½ð̾,(a)..¤È¤·¤Æ½ð̾,(b)ξ¼Ô,(f)²ò½ü?"
++msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, (i)nline, or (f)orget it? "
++msgstr "PGP (e)°Å¹æ²½,(s)½ð̾,(a)..¤È¤·¤Æ½ð̾,(b)ξ¼Ô,(i)nline,(f)²ò½ü?"
+ 
+ #: compose.c:166
+-msgid "esabf"
+-msgstr "esabf"
++msgid "esabif"
++msgstr "esabif"
+ 
+--- po/ko.po Feb 2004 18:26:12 -0000	3.15
++++ po/ko.po Feb 2004 06:07:20 -0000
+@@ -570,8 +570,8 @@ msgstr "¾Ïȣȭ ¹æ½Ä: "
+ #: compose.c:165
+-msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, or (f)orget it? "
+-msgstr "PGP ¾Ïȣȭ(e), ¼­¸í(s), »ç¿ë ¼­¸í(a), µÑ ´Ù(b), Ãë¼Ò(f)? "
++msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, (i)nline, or (f)orget it? "
++msgstr "PGP ¾Ïȣȭ(e), ¼­¸í(s), »ç¿ë ¼­¸í(a), µÑ ´Ù(b), (i)nline, Ãë¼Ò(f)? "
+ 
+ #: compose.c:166
+-msgid "esabf"
+-msgstr "esabf"
++msgid "esabif"
++msgstr "esabif"
+ 
+--- po/lt.po Feb 2004 18:26:12 -0000	3.11
++++ po/lt.po Feb 2004 06:07:20 -0000
+@@ -578,5 +578,5 @@ msgstr "Uþðifruoti"
+ #, fuzzy
+-msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, or (f)orget it? "
++msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, (i)nline, or (f)orget it? "
+ msgstr ""
+-"(u)þðifruot, pa(s)iraðùt, pasiraðùt k(a)ip, a(b)u, rinktis (m)ic algoritmଠ"
++"(u)þðifruot, pa(s)iraðùt, pasiraðùt k(a)ip, a(b)u, (l)aiðëe, "
+ "ar (p)amirðôi?"
+@@ -585,4 +585,4 @@ msgstr ""
+ #, fuzzy
+-msgid "esabf"
+-msgstr "usabmp"
++msgid "esabif"
++msgstr "usablp"
+ 
+@@ -598,4 +598,3 @@ msgid ""
+ msgstr ""
+-"(u)þðifruot, pa(s)iraðùt, pasiraðùt k(a)ip, a(b)u, rinktis (m)ic algoritmଠ"
+-"ar (p)amirðôi?"
++"(u)þðifruot, pa(s)iraðùt, uþðifruo(t) su, pasiraðùt k(a)ip, a(b)u, ar (p)amirðôi?"
+ 
+@@ -604,3 +603,3 @@ msgstr ""
+ msgid "eswabf"
+-msgstr "usabmp"
++msgstr "ustabp"
+ 
+--- po/nl.po Feb 2004 18:26:12 -0000	3.16
++++ po/nl.po Feb 2004 06:07:21 -0000
+@@ -568,8 +568,8 @@ msgstr "Versleutelen met: "
+ #: compose.c:165
+-msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, or (f)orget it? "
+-msgstr "PGP (v)ersleutel, (o)ndertekenen, ondert. (a)ls, (b)eiden, (g)een? "
++msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, (i)nline, or (f)orget it? "
++msgstr "PGP (v)ersleutel, (o)ndertekenen, ondert. (a)ls, (b)eiden, ber(i)cht, (g)een? "
+ 
+ #: compose.c:166
+-msgid "esabf"
+-msgstr "voabg"
++msgid "esabif"
++msgstr "voabig"
+ 
+--- po/pl.po Feb 2004 18:26:12 -0000	3.17
++++ po/pl.po Feb 2004 06:07:21 -0000
+@@ -571,8 +571,8 @@ msgstr "Zaszyfruj u¿ùwaj±ã: "
+ #: compose.c:165
+-msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, or (f)orget it? "
+-msgstr "PGP: (z)aszyfruj, podpi(s)z, podpisz j(a)ko, o(b)a, b(e)z PGP? "
++msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, (i)nline, or (f)orget it? "
++msgstr "PGP: (z)aszyfruj, podpi(s)z, podpisz j(a)ko, o(b)a, (i)nline, b(e)z PGP? "
+ 
+ #: compose.c:166
+-msgid "esabf"
+-msgstr "zsabe"
++msgid "esabif"
++msgstr "zsabie"
+ 
+--- po/pt_BR.po Feb 2004 18:26:13 -0000	3.12
++++ po/pt_BR.po Feb 2004 06:07:21 -0000
+@@ -581,5 +581,5 @@ msgstr "Encriptar"
+ #, fuzzy
+-msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, or (f)orget it? "
++msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, (i)nline, or (f)orget it? "
+ msgstr ""
+-"(e)ncripa, a(s)sina, assina (c)omo, (a)mbos, escolhe (m)ic, ou es(q)uece? "
++"(e)ncripa, a(s)sina, assina (c)omo, (a)mbos, em l(i)nha, ou es(q)uece? "
+ 
+@@ -587,4 +587,4 @@ msgstr ""
+ #, fuzzy
+-msgid "esabf"
+-msgstr "escamq"
++msgid "esabif"
++msgstr "escaiq"
+ 
+@@ -600,3 +600,3 @@ msgid ""
+ msgstr ""
+-"(e)ncripa, a(s)sina, assina (c)omo, (a)mbos, escolhe (m)ic, ou es(q)uece? "
++"(e)ncripa, a(s)sina, e(n)cripa com, assina (c)omo, (a)mbos, ou es(q)uece? "
+ 
+@@ -605,3 +605,3 @@ msgstr ""
+ msgid "eswabf"
+-msgstr "escamq"
++msgstr "esncaq"
+ 
+--- po/ru.po Feb 2004 18:26:13 -0000	3.19
++++ po/ru.po Feb 2004 06:07:22 -0000
+@@ -577,8 +577,8 @@ msgstr "úÁÛÉÆÒÏ×ÁÔغ "
+ #: compose.c:165
+-msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, or (f)orget it? "
+-msgstr "PGP (e)ÛÉÆÒ, (s)ÐÏÄÐÉÓج (a)ÐÏÄÐÉÓ×þËÁˬ (b)ÏÂÁ¬ (f)ÏÔËÁÚÁÔØÓÑ? "
++msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, (i)nline, or (f)orget it? "
++msgstr "PGP (e)ÛÉÆÒ, (s)ÐÏÄÐÉÓج (a)ÐÏÄÐÉÓ×þËÁˬ (b)ÏÂÁ¬ (i)nline, (f)ÏÔËÁÚÁÔØÓÑ? "
+ 
+ #: compose.c:166
+-msgid "esabf"
+-msgstr "esabf"
++msgid "esabif"
++msgstr "esabif"
+ 
+--- po/sk.po Feb 2004 18:26:13 -0000	3.11
++++ po/sk.po Feb 2004 06:07:22 -0000
+@@ -586,5 +586,5 @@ msgstr "Za¹éfruj"
+ #, fuzzy
+-msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, or (f)orget it? "
++msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, (i)nline, or (f)orget it? "
+ msgstr ""
+-"(e)-¹éfr, (s)-podp, podp (a)ko, o(b)e, oznaçþalg. mi(c), alebo (f)-zabudnú» "
++"(e)-¹éfr, (s)-podp, podp (a)ko, o(b)e, (i)nline, alebo (f)-zabudnú» "
+ "na to? "
+@@ -593,4 +593,4 @@ msgstr ""
+ #, fuzzy
+-msgid "esabf"
+-msgstr "esabmf"
++msgid "esabif"
++msgstr "esabif"
+ 
+@@ -606,4 +606,3 @@ msgid ""
+ msgstr ""
+-"(e)-¹éfr, (s)-podp, podp (a)ko, o(b)e, oznaçþalg. mi(c), alebo (f)-zabudnú» "
+-"na to? "
++"(e)-¹éfr, (s)-podp, (w)-¹éfr s, podp (a)ko, o(b)e, alebo (f)-zabudnú» na to? "
+ 
+@@ -612,3 +611,3 @@ msgstr ""
+ msgid "eswabf"
+-msgstr "esabmf"
++msgstr "eswabf"
+ 
+--- po/sv.po Feb 2004 18:26:13 -0000	3.12
++++ po/sv.po Feb 2004 06:07:22 -0000
+@@ -568,8 +568,8 @@ msgstr "Kryptera med: "
+ #: compose.c:165
+-msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, or (f)orget it? "
+-msgstr "PGP: (k)ryptera, (s)ignera, signera s(o)m, (b)åäa, eller sk(i)ppa det?"
++msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, (i)nline, or (f)orget it? "
++msgstr "PGP: (k)ryptera, (s)ignera, signera s(o)m, (b)åäa, i(n)fogat, eller sk(i)ppa det?"
+ 
+ #: compose.c:166
+-msgid "esabf"
+-msgstr "ksobi"
++msgid "esabif"
++msgstr "ksobni"
+ 
+--- po/tr.po Feb 2004 18:26:13 -0000	3.11
++++ po/tr.po Feb 2004 06:07:22 -0000
+@@ -577,5 +577,5 @@ msgstr "Þéfrele"
+ #, fuzzy
+-msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, or (f)orget it? "
++msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, (i)nline, or (f)orget it? "
+ msgstr ""
+-"þ¨i)frele, i(m)zala, (f)arklý imzala, i(k)isi de, mi(c) algoritmini seç "
++"þ¨i)frele, i(m)zala, (f)arklý imzala, i(k)isi de, (i)nline, "
+ "yoksa i(p)talmý¿ "
+@@ -583,4 +583,4 @@ msgstr ""
+ #: compose.c:166
+-msgid "esabf"
+-msgstr "imfkcp"
++msgid "esabif"
++msgstr "imfkip"
+ 
+--- po/uk.po Feb 2004 18:26:13 -0000	3.12
++++ po/uk.po Feb 2004 06:07:23 -0000
+@@ -572,8 +572,8 @@ msgstr "ûÉÆÒÕ×ÁÎÎÑ"
+ #, fuzzy
+-msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, or (f)orget it? "
+-msgstr "ÛÉÆÒ.(e), ЦÄÐ.(s), ЦÄÐ. ÑË(a), ÕÓŨb) ÞÉ ×¦ÄͦÎÁ¨f)? "
++msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, (i)nline, or (f)orget it? "
++msgstr "ÛÉÆÒ.(e), ЦÄÐ.(s), ЦÄÐ. ÑË(a), ÕÓŨb), (i)nline ÞÉ ×¦ÄͦÎÁ¨f)? "
+ 
+ #: compose.c:166
+-msgid "esabf"
+-msgstr ""
++msgid "esabif"
++msgstr "esabif"
+ 
+--- po/zh_CN.po Feb 2004 18:26:13 -0000	3.11
++++ po/zh_CN.po Feb 2004 06:07:23 -0000
+@@ -585,5 +585,5 @@ msgstr "¼ÓÃÜ"
+ #, fuzzy
+-msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, or (f)orget it? "
++msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, (i)nline, or (f)orget it? "
+ msgstr ""
+-"(e)¼ÓÃÜ, (s)Ç©Ãû, (a)ÓñðµÄÉí·ÝÇ©, (b)Á½Õß½ÔÒª, Ñ¡Ôñ (m)ic ÑÝËã·¨ »ò (f)·Å"
++"(e)¼ÓÃÜ, (s)Ç©Ãû, (a)ÓñðµÄÉí·ÝÇ©, (b)Á½Õß½ÔÒª, (i)nline, »ò (f)·Å"
+ "Æú£¿"
+@@ -591,4 +591,4 @@ msgstr ""
+ #: compose.c:166
+-msgid "esabf"
+-msgstr ""
++msgid "esabif"
++msgstr "esabif"
+ 
+--- po/zh_TW.po Feb 2004 18:26:13 -0000	3.11
++++ po/zh_TW.po Feb 2004 06:07:24 -0000
+@@ -577,3 +577,3 @@ msgstr "加å¯"
+ #, fuzzy
+-msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, or (f)orget it? "
++msgid "PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, (i)nline, or (f)orget it? "
+ msgstr "(1)加å¯, (2)ç°½å
, (3)用å¥ç身份簽¬ (4)å…©è€çšè¦, åæ (5)åò¾æ£„ï¼"
+@@ -581,4 +581,4 @@ msgstr "(1)加å¯, (2)ç°½å
, (3)用å¥ç
+ #: compose.c:166
+-msgid "esabf"
+-msgstr "12345"
++msgid "esabif"
++msgstr "1234i5"
+ 
diff -urN mutt-devel/files/extra-patch-reverse_reply mutt-devel-1.5.21-ja.2/files/extra-patch-reverse_reply
--- mutt-devel/files/extra-patch-reverse_reply	1970-01-01 09:00:00.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/extra-patch-reverse_reply	2012-07-22 18:15:04.000000000 +0900
@@ -0,0 +1,92 @@
+diff -u PATCHES PATCHES
+--- PATCHES
++++ PATCHES
+@@ -0,0 +1 @@
++patch-1.5.6.cb.reverse_reply.2
+--- init.h.orig	2005-03-01 16:56:02.000000000 +0100
++++ init.h	2005-05-25 18:20:57.000000000 +0200
+@@ -2257,6 +2257,13 @@
+   ** possibly including eventual real names.  When it is unset, mutt will
+   ** override any such real names with the setting of the $realname variable.
+   */
++  { "reverse_reply",	DT_BOOL, R_NONE, OPTREVREPLY, 0 },
++  /*
++  ** .pp
++  ** When set, this variable uses the name from your aliases in the To and Cc
++  ** headers of reply mails you send, like $reverse_alias does in the index.
++  ** When unset, the headers taken from the original mail are left unchanged.
++  */
+   { "rfc2047_parameters", DT_BOOL, R_NONE, OPTRFC2047PARAMS, 0 },
+   /*
+   ** .pp
+--- mutt.h.orig	2005-02-28 16:13:57.000000000 +0100
++++ mutt.h	2005-05-25 18:20:57.000000000 +0200
+@@ -410,6 +410,7 @@
+   OPTREVALIAS,
+   OPTREVNAME,
+   OPTREVREAL,
++  OPTREVREPLY,
+   OPTRFC2047PARAMS,
+   OPTSAVEADDRESS,
+   OPTSAVEEMPTY,
+--- protos.h.orig	Wed Jul 12 01:32:28 2006
++++ protos.h	Mon Jul 17 16:14:16 2006
+@@ -92,6 +92,7 @@
+ ADDRESS *mutt_lookup_alias (const char *s);
+ ADDRESS *mutt_remove_duplicates (ADDRESS *);
+ ADDRESS *mutt_remove_xrefs (ADDRESS *, ADDRESS *);
++ADDRESS *mutt_reverse_address (ADDRESS *);
+ ADDRESS *mutt_expand_aliases (ADDRESS *);
+ ADDRESS *mutt_parse_adrlist (ADDRESS *, const char *);
+
+--- send.c.orig	2005-02-03 19:47:53.000000000 +0100
++++ send.c	2005-05-25 18:20:57.000000000 +0200
+@@ -588,6 +588,10 @@
+   /* the CC field can get cluttered, especially with lists */
+   env->to = mutt_remove_duplicates (env->to);
+   env->cc = mutt_remove_duplicates (env->cc);
++  if (option (OPTREVREPLY)){
++	env->to = mutt_reverse_address (env->to);
++	env->cc = mutt_reverse_address (env->cc);
++  }
+   env->cc = mutt_remove_xrefs (env->to, env->cc);
+ }
+ 
+--- sendlib.c.orig	2005-02-21 05:45:57.000000000 +0100
++++ sendlib.c	2005-05-25 18:20:57.000000000 +0200
+@@ -2341,6 +2341,35 @@
+   }
+ }
+ 
++/* given a list of addresses, return a list of reverse_alias'ed addresses */
++ADDRESS *mutt_reverse_address (ADDRESS *addr)
++{
++  ADDRESS *top,*tmp,*alias;
++
++  if (addr == NULL)
++    return NULL;
++
++  if ((alias = alias_reverse_lookup (addr)) && alias->personal) {
++    tmp = rfc822_cpy_adr_real(alias);
++    tmp->next = addr->next;
++    addr->next = NULL;
++    rfc822_free_address(&addr);
++    addr = tmp;
++  }
++
++  for (top = addr; top->next != NULL; top = tmp) {
++    tmp = top->next;
++    if ((alias = alias_reverse_lookup (tmp)) && alias->personal) {
++      top->next = rfc822_cpy_adr_real(alias);
++      top->next->next = tmp->next;
++      tmp->next = NULL;
++      rfc822_free_address(&tmp);
++      tmp = top->next;
++    }
++  }
++  return addr;
++}
++
+ int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int post, char *fcc)
+ {
+   CONTEXT f;
diff -urN mutt-devel/files/extra-patch-sidebar mutt-devel-1.5.21-ja.2/files/extra-patch-sidebar
--- mutt-devel/files/extra-patch-sidebar	1970-01-01 09:00:00.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/extra-patch-sidebar	2012-07-22 18:15:04.000000000 +0900
@@ -0,0 +1,1603 @@
+--- orig/buffy.c.orig	2010-09-18 14:12:40.000000000 +0200
++++ new/buffy.c	2010-09-18 14:17:36.000000000 +0200
+@@ -161,6 +161,49 @@
+   }
+ }
+ 
++static int buffy_compare_name(const void *a, const void *b) {
++  const BUFFY *b1 = * (BUFFY * const *) a;
++  const BUFFY *b2 = * (BUFFY * const *) b;
++
++  return mutt_strcoll(b1->path, b2->path);
++}
++
++static BUFFY *buffy_sort(BUFFY *b)
++{
++  BUFFY *tmp = b;
++  int buffycount = 0;
++  BUFFY **ary;
++  int i;
++
++  if (!option(OPTSIDEBARSORT))
++    return b;
++
++  for (; tmp != NULL; tmp = tmp->next)
++    buffycount++;
++
++  ary = (BUFFY **) safe_calloc(buffycount, sizeof (*ary));
++
++  tmp = b;
++  for (i = 0; tmp != NULL; tmp = tmp->next, i++) {
++    ary[i] = tmp;
++  }
++
++  qsort(ary, buffycount, sizeof(*ary), buffy_compare_name);
++
++  for (i = 0; i < buffycount - 1; i++) {
++    ary[i]->next = ary[i+1];
++  }
++  ary[buffycount - 1]->next = NULL;
++  for (i = 1; i < buffycount; i++) {
++    ary[i]->prev = ary[i-1];
++  }
++  ary[0]->prev = NULL;
++
++  tmp = ary[0];
++  free(ary);
++  return tmp;
++}
++
+ BUFFY *mutt_find_mailbox (const char *path)
+ {
+   BUFFY *tmp = NULL;
+@@ -282,6 +325,7 @@
+     else
+       (*tmp)->size = 0;
+   }
++  Incoming = buffy_sort(Incoming);
+   return 0;
+ }
+ 
+@@ -371,12 +415,17 @@
+   return rc;
+ }
+ 
++#define STAT_CHECK_SIZE (sb.st_size > tmp->size)
++#define STAT_CHECK_TIME (sb.st_mtime > sb.st_atime || (tmp->newly_created && sb.st_ctime == sb.st_mtime && sb.st_ctime == sb.st_atime))
++#define STAT_CHECK (option(OPTCHECKMBOXSIZE) ? STAT_CHECK_SIZE : STAT_CHECK_TIME)
++
+ int mutt_buffy_check (int force)
+ {
+   BUFFY *tmp;
+   struct stat sb;
+   struct stat contex_sb;
+   time_t t;
++  CONTEXT *ctx;
+ 
+   sb.st_size=0;
+   contex_sb.st_dev=0;
+@@ -416,6 +465,8 @@
+   
+   for (tmp = Incoming; tmp; tmp = tmp->next)
+   {
++    if ( tmp->new == 1 )
++       tmp->has_new = 1;
+     if (tmp->magic != M_IMAP)
+     {
+       tmp->new = 0;
+@@ -455,18 +506,122 @@
+       {
+       case M_MBOX:
+       case M_MMDF:
+-	if (buffy_mbox_hasnew (tmp, &sb) > 0)
+-	  BuffyCount++;
+-	break;
++        {
++          if (STAT_CHECK || tmp->msgcount == 0)
++          {
++            BUFFY b = *tmp;
++            int msgcount = 0;
++            int msg_unread = 0;
++            /* parse the mailbox, to see how much mail there is */
++            ctx = mx_open_mailbox( tmp->path, M_READONLY | M_QUIET | M_NOSORT | M_PEEK, NULL);
++            if(ctx)
++            {
++              msgcount = ctx->msgcount;
++              msg_unread = ctx->unread;
++              mx_close_mailbox(ctx, 0);
++            }
++            *tmp = b;
++            tmp->msgcount = msgcount;
++            tmp->msg_unread = msg_unread;
++            if(STAT_CHECK) {
++              tmp->has_new = tmp->new = 1;
++              BuffyCount++;
++            }
++          }
++          else if (option(OPTCHECKMBOXSIZE))
++          {
++            /* some other program has deleted mail from the folder */
++            tmp->size = (off_t) sb.st_size;
++          }
++          if (tmp->newly_created &&
++              (sb.st_ctime != sb.st_mtime || sb.st_ctime != sb.st_atime))
++            tmp->newly_created = 0;
++        }
++        break;
++
+ 
+       case M_MAILDIR:
+-	if (buffy_maildir_hasnew (tmp) > 0)
+-	  BuffyCount++;
++        { 
++        char path[_POSIX_PATH_MAX];
++        DIR *dirp;
++        struct dirent *de;
++        /* count new message */
++        snprintf (path, sizeof (path), "%s/new", tmp->path);
++        if ((dirp = opendir (path)) == NULL)
++        {
++          tmp->magic = 0;
++          break;
++        }
++        tmp->msgcount = 0;
++        tmp->msg_unread = 0;
++        tmp->msg_flagged = 0;
++        while ((de = readdir (dirp)) != NULL)
++        {
++          char *p;
++          if (*de->d_name != '.' &&
++              (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')))
++          {
++            tmp->has_new = tmp->new = 1;
++            tmp->msgcount++;
++            tmp->msg_unread++;
++          }
++        }
++        if(tmp->msg_unread)
++          BuffyCount++;
++
++        closedir (dirp);
++
++        /*
++         * count read messages (for folderlist (sidebar) we also need to count
++         * messages in cur so that we the total number of messages
++         */
++        snprintf (path, sizeof (path), "%s/cur", tmp->path);
++        if ((dirp = opendir (path)) == NULL)
++        {
++          tmp->magic = 0;
++          break;
++        }
++        while ((de = readdir (dirp)) != NULL)
++        {
++          char *p;
++          if (*de->d_name != '.') {
++                  if ((p = strstr (de->d_name, ":2,"))) {
++                          if (!strchr (p + 3, 'T')) {
++                                  tmp->msgcount++;
++                                  if ( !strchr (p + 3, 'S'))
++                                          tmp->msg_unread++;
++                                  if (strchr(p + 3, 'F'))
++                                          tmp->msg_flagged++;
++                          }
++                  } else
++                          tmp->msgcount++;
++          }
++        }
++        closedir (dirp);
++        } 
+ 	break;
+ 
+       case M_MH:
+-	if ((tmp->new = mh_buffy (tmp->path)) > 0)
+-	  BuffyCount++;
++        {
++        DIR *dp;
++        char path[_POSIX_PATH_MAX];
++        struct dirent *de;
++        if ((tmp->new = mh_buffy (tmp->path)) > 0)
++          BuffyCount++;
++
++        if ((dp = opendir (path)) == NULL)
++          break;
++        tmp->msgcount = 0;
++        while ((de = readdir (dp)))
++        {
++          if (mh_valid_message (de->d_name))
++          {
++            tmp->msgcount++;
++            tmp->has_new = tmp->new = 1;
++          }
++        }
++        closedir (dp);
++        }
+ 	break;
+       }
+     }
+*** mutt-1.5.20-orig/buffy.h	2009-04-30 00:36:16.000000000 -0500
+--- mutt-1.5.20-patched/buffy.h	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 25,31 ****
+--- 25,36 ----
+    char path[_POSIX_PATH_MAX];
+    off_t size;
+    struct buffy_t *next;
++   struct buffy_t *prev;
+    short new;			/* mailbox has new mail */
++   short has_new;		/* set it new if new and not read */
++   int msgcount;			/* total number of messages */
++   int msg_unread;		/* number of unread messages */
++   int msg_flagged;		/* number of flagged messages */
+    short notified;		/* user has been notified */
+    short magic;			/* mailbox type */
+    short newly_created;		/* mbox or mmdf just popped into existence */
+*** mutt-1.5.20-orig/color.c	2009-05-18 19:11:35.000000000 -0500
+--- mutt-1.5.20-patched/color.c	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 93,98 ****
+--- 93,100 ----
+    { "bold",		MT_COLOR_BOLD },
+    { "underline",	MT_COLOR_UNDERLINE },
+    { "index",		MT_COLOR_INDEX },
++   { "sidebar_new",	MT_COLOR_NEW },
++   { "sidebar_flagged",	MT_COLOR_FLAGGED },
+    { NULL,		0 }
+  };
+  
+*** mutt-1.5.20-orig/curs_main.c	2009-06-13 21:48:36.000000000 -0500
+--- mutt-1.5.20-patched/curs_main.c	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 26,32 ****
+--- 26,34 ----
+  #include "mailbox.h"
+  #include "mapping.h"
+  #include "sort.h"
++ #include "buffy.h"
+  #include "mx.h"
++ #include "sidebar.h"
+  
+  #ifdef USE_POP
+  #include "pop.h"
+***************
+*** 523,530 ****
+         menu->redraw |= REDRAW_STATUS;
+       if (do_buffy_notify)
+       {
+!        if (mutt_buffy_notify () && option (OPTBEEPNEW))
+!  	beep ();
+       }
+       else
+         do_buffy_notify = 1;
+--- 525,536 ----
+         menu->redraw |= REDRAW_STATUS;
+       if (do_buffy_notify)
+       {
+!        if (mutt_buffy_notify ())
+!        {
+!          menu->redraw |= REDRAW_FULL;
+!          if (option (OPTBEEPNEW))
+!            beep ();
+!        }
+       }
+       else
+         do_buffy_notify = 1;
+***************
+*** 536,541 ****
+--- 542,548 ----
+      if (menu->redraw & REDRAW_FULL)
+      {
+        menu_redraw_full (menu);
++       draw_sidebar(menu->menu);
+        mutt_show_error ();
+      }
+  
+***************
+*** 558,567 ****
+--- 565,577 ----
+  
+        if (menu->redraw & REDRAW_STATUS)
+        {
++         DrawFullLine = 1;
+  	menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
++         DrawFullLine = 0;
+  	CLEARLINE (option (OPTSTATUSONTOP) ? 0 : LINES-2);
+  	SETCOLOR (MT_COLOR_STATUS);
+          BKGDSET (MT_COLOR_STATUS);
++         set_buffystats(Context);
+  	mutt_paddstr (COLS, buf);
+  	SETCOLOR (MT_COLOR_NORMAL);
+          BKGDSET (MT_COLOR_NORMAL);
+***************
+*** 575,581 ****
+  	menu->oldcurrent = -1;
+  
+        if (option (OPTARROWCURSOR))
+! 	move (menu->current - menu->top + menu->offset, 2);
+        else if (option (OPTBRAILLEFRIENDLY))
+  	move (menu->current - menu->top + menu->offset, 0);
+        else
+--- 585,591 ----
+  	menu->oldcurrent = -1;
+  
+        if (option (OPTARROWCURSOR))
+! 	move (menu->current - menu->top + menu->offset, SidebarWidth + 2);
+        else if (option (OPTBRAILLEFRIENDLY))
+  	move (menu->current - menu->top + menu->offset, 0);
+        else
+***************
+*** 1055,1060 ****
+--- 1065,1071 ----
+  	  menu->redraw = REDRAW_FULL;
+  	break;
+  
++       case OP_SIDEBAR_OPEN:
+        case OP_MAIN_CHANGE_FOLDER:
+        case OP_MAIN_NEXT_UNREAD_MAILBOX:
+  
+***************
+*** 1086,1092 ****
+  	{
+  	  mutt_buffy (buf, sizeof (buf));
+  
+! 	  if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
+  	  {
+  	    if (menu->menu == MENU_PAGER)
+  	    {
+--- 1097,1107 ----
+  	{
+  	  mutt_buffy (buf, sizeof (buf));
+  
+!           if ( op == OP_SIDEBAR_OPEN ) {
+!               if(!CurBuffy)
+!                 break;
+!             strncpy( buf, CurBuffy->path, sizeof(buf) );  
+! 	    } else if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
+  	  {
+  	    if (menu->menu == MENU_PAGER)
+  	    {
+***************
+*** 1104,1109 ****
+--- 1119,1125 ----
+  	}
+  
+  	mutt_expand_path (buf, sizeof (buf));
++         set_curbuffy(buf);
+  	if (mx_get_magic (buf) <= 0)
+  	{
+  	  mutt_error (_("%s is not a mailbox."), buf);
+***************
+*** 2183,2188 ****
+--- 2199,2210 ----
+  	mutt_what_key();
+  	break;
+  
++       case OP_SIDEBAR_SCROLL_UP:
++       case OP_SIDEBAR_SCROLL_DOWN:
++       case OP_SIDEBAR_NEXT:
++       case OP_SIDEBAR_PREV:
++         scroll_sidebar(op, menu->menu);
++         break;
+        default:
+  	if (menu->menu == MENU_MAIN)
+  	  km_error_key (MENU_MAIN);
+*** mutt-1.5.20-orig/flags.c	2008-12-16 21:50:09.000000000 -0600
+--- mutt-1.5.20-patched/flags.c	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 22,29 ****
+--- 22,31 ----
+  
+  #include "mutt.h"
+  #include "mutt_curses.h"
++ #include "mutt_menu.h"
+  #include "sort.h"
+  #include "mx.h"
++ #include "sidebar.h"
+  
+  void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx)
+  {
+***************
+*** 263,268 ****
+--- 265,271 ----
+     */
+    if (h->searched && (changed != h->changed || deleted != ctx->deleted || tagged != ctx->tagged || flagged != ctx->flagged))
+      h->searched = 0;
++ 	draw_sidebar(0);
+  }
+  
+  void mutt_tag_set_flag (int flag, int bf)
+*** mutt-1.5.20-orig/functions.h	2009-04-30 00:36:17.000000000 -0500
+--- mutt-1.5.20-patched/functions.h	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 168,173 ****
+--- 168,178 ----
+    { "decrypt-save",		OP_DECRYPT_SAVE,		NULL },
+  
+  
++  { "sidebar-scroll-up",	OP_SIDEBAR_SCROLL_UP, NULL },
++  { "sidebar-scroll-down",	OP_SIDEBAR_SCROLL_DOWN, NULL },
++  { "sidebar-next",		OP_SIDEBAR_NEXT, NULL },
++  { "sidebar-prev",		OP_SIDEBAR_PREV, NULL },
++  { "sidebar-open",		OP_SIDEBAR_OPEN, NULL },
+    { NULL,			0,				NULL }
+  };
+  
+***************
+*** 268,273 ****
+--- 273,283 ----
+  
+    { "what-key",		OP_WHAT_KEY,		NULL },
+  
++   { "sidebar-scroll-up",	OP_SIDEBAR_SCROLL_UP, NULL },
++   { "sidebar-scroll-down",	OP_SIDEBAR_SCROLL_DOWN, NULL },
++   { "sidebar-next",	OP_SIDEBAR_NEXT, NULL },
++   { "sidebar-prev",	OP_SIDEBAR_PREV, NULL },
++   { "sidebar-open", OP_SIDEBAR_OPEN, NULL },
+    { NULL,		0,				NULL }
+  };
+  
+*** mutt-1.5.20-orig/globals.h	2009-06-03 15:48:31.000000000 -0500
+--- mutt-1.5.20-patched/globals.h	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 117,122 ****
+--- 117,123 ----
+  WHERE char *SendCharset;
+  WHERE char *Sendmail;
+  WHERE char *Shell;
++ WHERE char *SidebarDelim;
+  WHERE char *Signature;
+  WHERE char *SimpleSearch;
+  #if USE_SMTP
+***************
+*** 206,211 ****
+--- 207,215 ----
+  WHERE short ScoreThresholdRead;
+  WHERE short ScoreThresholdFlag;
+  
++ WHERE struct buffy_t *CurBuffy INITVAL(0);
++ WHERE short DrawFullLine INITVAL(0);
++ WHERE short SidebarWidth;
+  #ifdef USE_IMAP
+  WHERE short ImapKeepalive;
+  WHERE short ImapPipelineDepth;
+*** mutt-1.5.20-orig/init.h	2009-06-13 16:35:21.000000000 -0500
+--- mutt-1.5.20-patched/init.h	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 1941,1946 ****
+--- 1941,1967 ----
+    ** not used.
+    ** (PGP only)
+    */
++   {"sidebar_delim", DT_STR, R_BOTH, UL &SidebarDelim, "|"},
++   /*
++   ** .pp
++   ** This specifies the delimiter between the sidebar (if visible) and 
++   ** other screens.
++   */
++   { "sidebar_visible", DT_BOOL, R_BOTH, OPTSIDEBAR, 0 },
++   /*
++   ** .pp
++   ** This specifies whether or not to show sidebar (left-side list of folders).
++   */
++   { "sidebar_sort", DT_BOOL, R_BOTH, OPTSIDEBARSORT, 0 },
++   /*
++   ** .pp
++   ** This specifies whether or not to sort the sidebar alphabetically.
++   */
++   { "sidebar_width", DT_NUM, R_BOTH, UL &SidebarWidth, 0 },
++   /*
++   ** .pp
++   ** The width of the sidebar.
++   */
+    { "pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0},
+    /*
+    ** .pp
+*** mutt-1.5.20-orig/mailbox.h	2009-04-30 00:36:17.000000000 -0500
+--- mutt-1.5.20-patched/mailbox.h	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 27,32 ****
+--- 27,33 ----
+  #define M_NEWFOLDER	(1<<4) /* create a new folder - same as M_APPEND, but uses
+  				* safe_fopen() for mbox-style folders.
+  				*/
++ #define M_PEEK		(1<<5) /* revert atime back after taking a look (if applicable) */
+  
+  /* mx_open_new_message() */
+  #define M_ADD_FROM	1	/* add a From_ line */
+--- orig/Makefile.am.orig	2010-09-18 13:23:19.000000000 +0200
++++ new/Makefile.am	2010-09-18 13:25:19.000000000 +0200
+@@ -34,7 +34,7 @@
+ 	score.c send.c sendlib.c signal.c sort.c \
+ 	status.c system.c thread.c charset.c history.c lib.c \
+ 	muttlib.c editmsg.c mbyte.c \
+-	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c
++	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c sidebar.c
+ 
+ nodist_mutt_SOURCES = $(BUILT_SOURCES)
+ 
+--- orig/Makefile.in.orig	2010-09-18 13:23:19.000000000 +0200
++++ new/Makefile.in	2010-09-18 13:27:19.000000000 +0200
+@@ -89,7 +89,7 @@
+ 	system.$(OBJEXT) thread.$(OBJEXT) charset.$(OBJEXT) \
+ 	history.$(OBJEXT) lib.$(OBJEXT) muttlib.$(OBJEXT) \
+ 	editmsg.$(OBJEXT) mbyte.$(OBJEXT) url.$(OBJEXT) \
+-	ascii.$(OBJEXT) crypt-mod.$(OBJEXT) safe_asprintf.$(OBJEXT)
++	ascii.$(OBJEXT) crypt-mod.$(OBJEXT) safe_asprintf.$(OBJEXT) sidebar.$(OBJEXT)
+ am__objects_1 =
+ am__objects_2 = patchlist.$(OBJEXT) $(am__objects_1)
+ nodist_mutt_OBJECTS = $(am__objects_2)
+@@ -363,7 +363,7 @@
+ 	score.c send.c sendlib.c signal.c sort.c \
+ 	status.c system.c thread.c charset.c history.c lib.c \
+ 	muttlib.c editmsg.c mbyte.c \
+-	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c
++	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c sidebar.c
+ 
+ nodist_mutt_SOURCES = $(BUILT_SOURCES)
+ mutt_LDADD = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAP) $(MUTTLIBS) \
+@@ -397,7 +397,7 @@
+ 	README.SSL smime.h group.h \
+ 	muttbug pgppacket.h depcomp ascii.h BEWARE PATCHES patchlist.sh \
+ 	ChangeLog mkchangelog.sh mutt_idna.h \
+-	snprintf.c regex.c crypt-gpgme.h hcachever.sh.in
++	snprintf.c regex.c crypt-gpgme.h sidebar.h hcachever.sh.in
+ 
+ EXTRA_SCRIPTS = smime_keys
+ mutt_dotlock_SOURCES = mutt_dotlock.c
+*** mutt-1.5.20-orig/mbox.c	2009-06-10 23:29:41.000000000 -0500
+--- mutt-1.5.20-patched/mbox.c	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 100,105 ****
+--- 100,106 ----
+      mutt_perror (ctx->path);
+      return (-1);
+    }
++   ctx->atime = sb.st_atime;
+    ctx->mtime = sb.st_mtime;
+    ctx->size = sb.st_size;
+  
+***************
+*** 255,260 ****
+--- 256,262 ----
+  
+    ctx->size = sb.st_size;
+    ctx->mtime = sb.st_mtime;
++   ctx->atime = sb.st_atime;
+  
+  #ifdef NFS_ATTRIBUTE_HACK
+    if (sb.st_mtime > sb.st_atime)
+*** mutt-1.5.20-orig/menu.c	2009-06-01 11:29:32.000000000 -0500
+--- mutt-1.5.20-patched/menu.c	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 24,29 ****
+--- 24,30 ----
+  #include "mutt_curses.h"
+  #include "mutt_menu.h"
+  #include "mbyte.h"
++ #include "sidebar.h"
+  
+  #include <string.h>
+  #include <stdlib.h>
+***************
+*** 156,162 ****
+  {
+    char *scratch = safe_strdup (s);
+    int shift = option (OPTARROWCURSOR) ? 3 : 0;
+!   int cols = COLS - shift;
+  
+    mutt_format_string (s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen (scratch), 1);
+    s[n - 1] = 0;
+--- 157,163 ----
+  {
+    char *scratch = safe_strdup (s);
+    int shift = option (OPTARROWCURSOR) ? 3 : 0;
+!   int cols = COLS - shift - SidebarWidth;
+  
+    mutt_format_string (s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen (scratch), 1);
+    s[n - 1] = 0;
+***************
+*** 207,212 ****
+--- 208,214 ----
+    char buf[LONG_STRING];
+    int i;
+  
++   draw_sidebar(1);
+    for (i = menu->top; i < menu->top + menu->pagelen; i++)
+    {
+      if (i < menu->max)
+***************
+*** 217,223 ****
+        if (option (OPTARROWCURSOR))
+        {
+          attrset (menu->color (i));
+! 	CLEARLINE (i - menu->top + menu->offset);
+  
+  	if (i == menu->current)
+  	{
+--- 219,225 ----
+        if (option (OPTARROWCURSOR))
+        {
+          attrset (menu->color (i));
+! 	CLEARLINE_WIN (i - menu->top + menu->offset);
+  
+  	if (i == menu->current)
+  	{
+***************
+*** 246,259 ****
+  	  BKGDSET (MT_COLOR_INDICATOR);
+  	}
+  
+! 	CLEARLINE (i - menu->top + menu->offset);
+  	print_enriched_string (menu->color(i), (unsigned char *) buf, i != menu->current);
+          SETCOLOR (MT_COLOR_NORMAL);
+          BKGDSET (MT_COLOR_NORMAL);
+        }
+      }
+      else
+!       CLEARLINE (i - menu->top + menu->offset);
+    }
+    menu->redraw = 0;
+  }
+--- 248,261 ----
+  	  BKGDSET (MT_COLOR_INDICATOR);
+  	}
+  
+! 	CLEARLINE_WIN (i - menu->top + menu->offset);
+  	print_enriched_string (menu->color(i), (unsigned char *) buf, i != menu->current);
+          SETCOLOR (MT_COLOR_NORMAL);
+          BKGDSET (MT_COLOR_NORMAL);
+        }
+      }
+      else
+!       CLEARLINE_WIN (i - menu->top + menu->offset);
+    }
+    menu->redraw = 0;
+  }
+***************
+*** 268,274 ****
+      return;
+    }
+    
+!   move (menu->oldcurrent + menu->offset - menu->top, 0);
+    SETCOLOR (MT_COLOR_NORMAL);
+    BKGDSET (MT_COLOR_NORMAL);
+  
+--- 270,276 ----
+      return;
+    }
+    
+!   move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth);
+    SETCOLOR (MT_COLOR_NORMAL);
+    BKGDSET (MT_COLOR_NORMAL);
+  
+***************
+*** 283,295 ****
+        clrtoeol ();
+        menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
+        menu_pad_string (buf, sizeof (buf));
+!       move (menu->oldcurrent + menu->offset - menu->top, 3);
+        print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
+        SETCOLOR (MT_COLOR_NORMAL);
+      }
+  
+      /* now draw it in the new location */
+!     move (menu->current + menu->offset - menu->top, 0);
+      attrset (menu->color (menu->current));
+      ADDCOLOR (MT_COLOR_INDICATOR);
+      addstr ("->");
+--- 285,297 ----
+        clrtoeol ();
+        menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
+        menu_pad_string (buf, sizeof (buf));
+!       move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth + 3);
+        print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
+        SETCOLOR (MT_COLOR_NORMAL);
+      }
+  
+      /* now draw it in the new location */
+!     move (menu->current + menu->offset - menu->top, SidebarWidth);
+      attrset (menu->color (menu->current));
+      ADDCOLOR (MT_COLOR_INDICATOR);
+      addstr ("->");
+***************
+*** 310,316 ****
+      attrset (menu->color (menu->current));
+      ADDCOLOR (MT_COLOR_INDICATOR);
+      BKGDSET (MT_COLOR_INDICATOR);
+!     CLEARLINE (menu->current - menu->top + menu->offset);
+      print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0);
+      SETCOLOR (MT_COLOR_NORMAL);
+      BKGDSET (MT_COLOR_NORMAL);
+--- 312,318 ----
+      attrset (menu->color (menu->current));
+      ADDCOLOR (MT_COLOR_INDICATOR);
+      BKGDSET (MT_COLOR_INDICATOR);
+!     CLEARLINE_WIN (menu->current - menu->top + menu->offset);
+      print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0);
+      SETCOLOR (MT_COLOR_NORMAL);
+      BKGDSET (MT_COLOR_NORMAL);
+***************
+*** 322,328 ****
+  {
+    char buf[LONG_STRING];
+    
+!   move (menu->current + menu->offset - menu->top, 0);
+    menu_make_entry (buf, sizeof (buf), menu, menu->current);
+    menu_pad_string (buf, sizeof (buf));
+  
+--- 324,330 ----
+  {
+    char buf[LONG_STRING];
+    
+!   move (menu->current + menu->offset - menu->top, SidebarWidth);
+    menu_make_entry (buf, sizeof (buf), menu, menu->current);
+    menu_pad_string (buf, sizeof (buf));
+  
+***************
+*** 876,882 ****
+      
+      
+      if (option (OPTARROWCURSOR))
+!       move (menu->current - menu->top + menu->offset, 2);
+      else if (option (OPTBRAILLEFRIENDLY))
+        move (menu->current - menu->top + menu->offset, 0);
+      else
+--- 878,884 ----
+      
+      
+      if (option (OPTARROWCURSOR))
+!       move (menu->current - menu->top + menu->offset, SidebarWidth + 2);
+      else if (option (OPTBRAILLEFRIENDLY))
+        move (menu->current - menu->top + menu->offset, 0);
+      else
+*** mutt-1.5.20-orig/mutt_curses.h	2008-11-11 13:55:47.000000000 -0600
+--- mutt-1.5.20-patched/mutt_curses.h	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 64,69 ****
+--- 64,70 ----
+  #undef lines
+  #endif /* lines */
+  
++ #define CLEARLINE_WIN(x) move(x,SidebarWidth), clrtoeol()
+  #define CLEARLINE(x) move(x,0), clrtoeol()
+  #define CENTERLINE(x,y) move(y, (COLS-strlen(x))/2), addstr(x)
+  #define BEEP() do { if (option (OPTBEEP)) beep(); } while (0)
+***************
+*** 126,131 ****
+--- 127,134 ----
+    MT_COLOR_BOLD,
+    MT_COLOR_UNDERLINE,
+    MT_COLOR_INDEX,
++   MT_COLOR_NEW,
++   MT_COLOR_FLAGGED,
+    MT_COLOR_MAX
+  };
+  
+*** mutt-1.5.20-orig/mutt.h	2009-06-12 17:15:42.000000000 -0500
+--- mutt-1.5.20-patched/mutt.h	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 418,423 ****
+--- 418,425 ----
+    OPTSAVEEMPTY,
+    OPTSAVENAME,
+    OPTSCORE,
++   OPTSIDEBAR,
++   OPTSIDEBARSORT,
+    OPTSIGDASHES,
+    OPTSIGONTOP,
+    OPTSORTRE,
+***************
+*** 854,859 ****
+--- 856,862 ----
+  {
+    char *path;
+    FILE *fp;
++   time_t atime;
+    time_t mtime;
+    off_t size;
+    off_t vsize;
+***************
+*** 888,893 ****
+--- 891,897 ----
+    unsigned int quiet : 1;	/* inhibit status messages? */
+    unsigned int collapsed : 1;   /* are all threads collapsed? */
+    unsigned int closing : 1;	/* mailbox is being closed */
++   unsigned int peekonly : 1;	/* just taking a glance, revert atime */
+  
+    /* driver hooks */
+    void *data;			/* driver specific data */
+*** mutt-1.5.20-orig/muttlib.c	2009-05-18 19:11:35.000000000 -0500
+--- mutt-1.5.20-patched/muttlib.c	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 1232,1237 ****
+--- 1232,1239 ----
+  	  pl = pw = 1;
+  
+  	/* see if there's room to add content, else ignore */
++         if ( DrawFullLine )
++         {
+  	if ((col < COLS && wlen < destlen) || soft)
+  	{
+  	  int pad;
+***************
+*** 1274,1279 ****
+--- 1276,1327 ----
+  	  col += wid;
+  	  src += pl;
+  	}
++         }
++         else
++         {
++ 	if ((col < COLS-SidebarWidth && wlen < destlen) || soft)
++         {
++ 	  int pad;
++ 
++ 	  /* get contents after padding */
++ 	  mutt_FormatString (buf, sizeof (buf), 0, src + pl, callback, data, flags);
++ 	  len = mutt_strlen (buf);
++ 	  wid = mutt_strwidth (buf);
++ 
++ 	  /* try to consume as many columns as we can, if we don't have
++ 	   * memory for that, use as much memory as possible */
++ 	  pad = (COLS - SidebarWidth - col - wid) / pw;
++ 	  if (pad > 0 && wlen + (pad * pl) + len > destlen)
++ 	    pad = ((signed)(destlen - wlen - len)) / pl;
++ 	  if (pad > 0)
++ 	  {
++ 	    while (pad--)
++ 	    {
++ 	      memcpy (wptr, src, pl);
++ 	      wptr += pl;
++ 	      wlen += pl;
++ 	      col += pw;
++ 	    }
++ 	  }
++ 	  else if (soft && pad < 0)
++ 	  {
++ 	    /* \0-terminate dest for length computation in mutt_wstr_trunc() */
++ 	    *wptr = 0;
++ 	    /* make sure right part is at most as wide as display */
++ 	    len = mutt_wstr_trunc (buf, destlen, COLS, &wid);
++ 	    /* truncate left so that right part fits completely in */
++ 	    wlen = mutt_wstr_trunc (dest, destlen - len, col + pad, &col);
++ 	    wptr = dest + wlen;
++ 	  }
++ 	  if (len + wlen > destlen)
++ 	    len = mutt_wstr_trunc (buf, destlen - wlen, COLS - SidebarWidth - col, NULL);
++ 	  memcpy (wptr, buf, len);
++ 	  wptr += len;
++ 	  wlen += len;
++ 	  col += wid;
++ 	  src += pl;
++ 	}
++         }
+  	break; /* skip rest of input */
+        }
+        else if (ch == '|')
+*** mutt-1.5.20-orig/mx.c	2009-06-10 23:29:41.000000000 -0500
+--- mutt-1.5.20-patched/mx.c	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 581,586 ****
+--- 581,587 ----
+   *		M_APPEND	open mailbox for appending
+   *		M_READONLY	open mailbox in read-only mode
+   *		M_QUIET		only print error messages
++  *		M_PEEK		revert atime where applicable
+   *	ctx	if non-null, context struct to use
+   */
+  CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx)
+***************
+*** 603,608 ****
+--- 604,611 ----
+      ctx->quiet = 1;
+    if (flags & M_READONLY)
+      ctx->readonly = 1;
++   if (flags & M_PEEK)
++     ctx->peekonly = 1;
+  
+    if (flags & (M_APPEND|M_NEWFOLDER))
+    {
+***************
+*** 702,710 ****
+--- 705,725 ----
+  void mx_fastclose_mailbox (CONTEXT *ctx)
+  {
+    int i;
++ #ifndef BUFFY_SIZE
++   struct utimbuf ut;
++ #endif
+  
+    if(!ctx) 
+      return;
++ #ifndef BUFFY_SIZE
++   /* fix up the times so buffy won't get confused */
++   if (ctx->peekonly && ctx->path && ctx->mtime > ctx->atime)
++   {
++     ut.actime = ctx->atime;
++     ut.modtime = ctx->mtime;
++     utime (ctx->path, &ut); 
++   }
++ #endif
+  
+    if (ctx->mx_close)
+      ctx->mx_close (ctx);
+*** mutt-1.5.20-orig/OPS	2009-05-13 00:01:13.000000000 -0500
+--- mutt-1.5.20-patched/OPS	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 178,180 ****
+--- 178,185 ----
+  OP_MAIN_SHOW_LIMIT "show currently active limit pattern"
+  OP_MAIN_COLLAPSE_THREAD "collapse/uncollapse current thread"
+  OP_MAIN_COLLAPSE_ALL "collapse/uncollapse all threads"
++ OP_SIDEBAR_SCROLL_UP "scroll the mailbox pane up 1 page"
++ OP_SIDEBAR_SCROLL_DOWN "scroll the mailbox pane down 1 page"
++ OP_SIDEBAR_NEXT "go down to next mailbox"
++ OP_SIDEBAR_PREV "go to previous mailbox"
++ OP_SIDEBAR_OPEN "open hilighted mailbox"
+--- orig/pager.c.orig	2010-09-18 13:23:19.000000000 +0200
++++ new/pager.c	2010-09-18 14:03:08.000000000 +0200
+@@ -29,6 +29,7 @@
+ #include "pager.h"
+ #include "attach.h"
+ #include "mbyte.h"
++#include "sidebar.h"
+ 
+ #include "mutt_crypt.h"
+ 
+@@ -1104,6 +1105,7 @@
+   if (check_attachment_marker ((char *)buf) == 0)
+     wrap_cols = COLS;
+ 
++  wrap_cols -= SidebarWidth;
+   /* FIXME: this should come from lineInfo */
+   memset(&mbstate, 0, sizeof(mbstate));
+ 
+@@ -1778,7 +1780,7 @@
+     if ((redraw & REDRAW_BODY) || topline != oldtopline)
+     {
+       do {
+-	move (bodyoffset, 0);
++	move (bodyoffset, SidebarWidth);
+ 	curline = oldtopline = topline;
+ 	lines = 0;
+ 	force_redraw = 0;
+@@ -1791,6 +1793,7 @@
+ 			    &QuoteList, &q_level, &force_redraw, &SearchRE) > 0)
+ 	    lines++;
+ 	  curline++;
++  	  move(lines + bodyoffset, SidebarWidth);
+ 	}
+ 	last_offset = lineInfo[curline].offset;
+       } while (force_redraw);
+@@ -1804,6 +1807,7 @@
+ 	  addch ('~');
+ 	addch ('\n');
+ 	lines++;
++  	move(lines + bodyoffset, SidebarWidth);
+       }
+       /* We are going to update the pager status bar, so it isn't
+        * necessary to reset to normal color now. */
+@@ -1827,21 +1831,21 @@
+       /* print out the pager status bar */
+       SETCOLOR (MT_COLOR_STATUS);
+       BKGDSET (MT_COLOR_STATUS);
+-      CLEARLINE (statusoffset);
++      CLEARLINE_WIN (statusoffset);
+ 
+       if (IsHeader (extra) || IsMsgAttach (extra))
+       {
+-	size_t l1 = COLS * MB_LEN_MAX;
++	size_t l1 = (COLS-SidebarWidth) * MB_LEN_MAX;
+ 	size_t l2 = sizeof (buffer);
+ 	hfi.hdr = (IsHeader (extra)) ? extra->hdr : extra->bdy->hdr;
+ 	mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt), &hfi, M_FORMAT_MAKEPRINT);
+-	mutt_paddstr (COLS, buffer);
++	mutt_paddstr (COLS-SidebarWidth, buffer);
+       }
+       else
+       {
+ 	char bn[STRING];
+ 	snprintf (bn, sizeof (bn), "%s (%s)", banner, pager_progress_str);
+-	mutt_paddstr (COLS, bn);
++	mutt_paddstr (COLS-SidebarWidth, bn);
+       }
+       BKGDSET (MT_COLOR_NORMAL);
+       SETCOLOR (MT_COLOR_NORMAL);
+@@ -1852,18 +1856,23 @@
+       /* redraw the pager_index indicator, because the
+        * flags for this message might have changed. */
+       menu_redraw_current (index);
++      draw_sidebar(MENU_PAGER);
+ 
+       /* print out the index status bar */
+       menu_status_line (buffer, sizeof (buffer), index, NONULL(Status));
+  
+-      move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), 0);
++      move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), SidebarWidth);
+       SETCOLOR (MT_COLOR_STATUS);
+       BKGDSET (MT_COLOR_STATUS);
+-      mutt_paddstr (COLS, buffer);
++      mutt_paddstr (COLS-SidebarWidth, buffer);
+       SETCOLOR (MT_COLOR_NORMAL);
+       BKGDSET (MT_COLOR_NORMAL);
+     }
+ 
++    /* if we're not using the index, update every time */
++    if ( index == 0 )
++      draw_sidebar(MENU_PAGER);
++
+     redraw = 0;
+ 
+     if (option(OPTBRAILLEFRIENDLY)) {
+@@ -2852,6 +2861,13 @@
+ 	mutt_what_key ();
+ 	break;
+ 
++      case OP_SIDEBAR_SCROLL_UP:
++      case OP_SIDEBAR_SCROLL_DOWN:
++      case OP_SIDEBAR_NEXT:
++      case OP_SIDEBAR_PREV:
++	scroll_sidebar(ch, MENU_PAGER);
++ 	break;
++
+       default:
+ 	ch = -1;
+ 	break;
+*** mutt-1.5.20-orig/PATCHES	2008-11-11 13:55:46.000000000 -0600
+--- mutt-1.5.20-patched/PATCHES	2009-06-19 22:20:31.000000000 -0500
+***************
+*** 0 ****
+--- 1 ----
++ patch-1.5.20.sidebar.20090619.txt
+*** mutt-1.5.20-orig/sidebar.c	1969-12-31 18:00:00.000000000 -0600
+--- mutt-1.5.20-patched/sidebar.c	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 0 ****
+--- 1,333 ----
++ /*
++  * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
++  * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
++  * 
++  *     This program is free software; you can redistribute it and/or modify
++  *     it under the terms of the GNU General Public License as published by
++  *     the Free Software Foundation; either version 2 of the License, or
++  *     (at your option) any later version.
++  * 
++  *     This program is distributed in the hope that it will be useful,
++  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
++  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++  *     GNU General Public License for more details.
++  * 
++  *     You should have received a copy of the GNU General Public License
++  *     along with this program; if not, write to the Free Software
++  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
++  */ 
++ 
++ 
++ #if HAVE_CONFIG_H
++ # include "config.h"
++ #endif
++ 
++ #include "mutt.h"
++ #include "mutt_menu.h"
++ #include "mutt_curses.h"
++ #include "sidebar.h"
++ #include "buffy.h"
++ #include <libgen.h>
++ #include "keymap.h"
++ #include <stdbool.h>
++ 
++ /*BUFFY *CurBuffy = 0;*/
++ static BUFFY *TopBuffy = 0;
++ static BUFFY *BottomBuffy = 0;
++ static int known_lines = 0;
++ 
++ static int quick_log10(int n)
++ {
++         char string[32];
++         sprintf(string, "%d", n);
++         return strlen(string);
++ }
++ 
++ void calc_boundaries (int menu)
++ {
++ 	BUFFY *tmp = Incoming;
++ 
++ 	if ( known_lines != LINES ) {
++ 		TopBuffy = BottomBuffy = 0;
++ 		known_lines = LINES;
++ 	}
++ 	for ( ; tmp->next != 0; tmp = tmp->next )
++ 		tmp->next->prev = tmp;
++ 
++ 	if ( TopBuffy == 0 && BottomBuffy == 0 )
++ 		TopBuffy = Incoming;
++ 	if ( BottomBuffy == 0 ) {
++ 		int count = LINES - 2 - (menu != MENU_PAGER || option(OPTSTATUSONTOP));
++ 		BottomBuffy = TopBuffy;
++ 		while ( --count && BottomBuffy->next )
++ 			BottomBuffy = BottomBuffy->next;
++ 	}
++ 	else if ( TopBuffy == CurBuffy->next ) {
++ 		int count = LINES - 2 - (menu != MENU_PAGER);
++ 		BottomBuffy = CurBuffy;
++ 		tmp = BottomBuffy;
++ 		while ( --count && tmp->prev)
++ 			tmp = tmp->prev;
++ 		TopBuffy = tmp;
++ 	}
++ 	else if ( BottomBuffy == CurBuffy->prev ) {
++ 		int count = LINES - 2 - (menu != MENU_PAGER);
++ 		TopBuffy = CurBuffy;
++ 		tmp = TopBuffy;
++ 		while ( --count && tmp->next )
++ 			tmp = tmp->next;
++ 		BottomBuffy = tmp;
++ 	}
++ }
++ 
++ char *make_sidebar_entry(char *box, int size, int new, int flagged)
++ {
++ 	static char *entry = 0;
++ 	char *c;
++ 	int i = 0;
++ 	int delim_len = strlen(SidebarDelim);
++ 
++ 	c = realloc(entry, SidebarWidth - delim_len + 2);
++ 	if ( c ) entry = c;
++ 	entry[SidebarWidth - delim_len + 1] = 0;
++ 	for (; i < SidebarWidth - delim_len + 1; entry[i++] = ' ' );
++ 	i = strlen(box);
++ 	strncpy( entry, box, i < (SidebarWidth - delim_len + 1) ? i : (SidebarWidth - delim_len + 1) );
++ 
++         if (size == -1)
++                 sprintf(entry + SidebarWidth - delim_len - 3, "?");
++         else if ( new ) {
++           if (flagged > 0) {
++               sprintf(
++ 		        entry + SidebarWidth - delim_len - 5 - quick_log10(size) - quick_log10(new) - quick_log10(flagged),
++ 		        "% d(%d)[%d]", size, new, flagged);
++           } else {
++               sprintf(
++                       entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(new),
++                       "% d(%d)", size, new);
++           }
++         } else if (flagged > 0) {
++               sprintf( entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(flagged), "% d[%d]", size, flagged);
++         } else {
++               sprintf( entry + SidebarWidth - delim_len - 1 - quick_log10(size), "% d", size);
++         }
++ 	return entry;
++ }
++ 
++ void set_curbuffy(char buf[LONG_STRING])
++ {
++   BUFFY* tmp = CurBuffy = Incoming;
++ 
++   if (!Incoming)
++     return;
++ 
++   while(1) {
++     if(!strcmp(tmp->path, buf)) {
++       CurBuffy = tmp;
++       break;
++     }
++ 
++     if(tmp->next)
++       tmp = tmp->next;
++     else
++       break;
++   }
++ }
++ 
++ int draw_sidebar(int menu) {
++ 
++ 	int lines = option(OPTHELP) ? 1 : 0;
++ 	BUFFY *tmp;
++ #ifndef USE_SLANG_CURSES
++         attr_t attrs;
++ #endif
++         short delim_len = strlen(SidebarDelim);
++         short color_pair;
++ 
++         static bool initialized = false;
++         static int prev_show_value;
++         static short saveSidebarWidth;
++ 
++         /* initialize first time */
++         if(!initialized) {
++                 prev_show_value = option(OPTSIDEBAR);
++                 saveSidebarWidth = SidebarWidth;
++                 if(!option(OPTSIDEBAR)) SidebarWidth = 0;
++                 initialized = true;
++         }
++ 
++         /* save or restore the value SidebarWidth */
++         if(prev_show_value != option(OPTSIDEBAR)) {
++                 if(prev_show_value && !option(OPTSIDEBAR)) {
++                         saveSidebarWidth = SidebarWidth;
++                         SidebarWidth = 0;
++                 } else if(!prev_show_value && option(OPTSIDEBAR)) {
++                         SidebarWidth = saveSidebarWidth;
++                 }
++                 prev_show_value = option(OPTSIDEBAR);
++         }
++ 
++ 
++ //	if ( SidebarWidth == 0 ) return 0;
++        if (SidebarWidth > 0 && option (OPTSIDEBAR)
++            && delim_len >= SidebarWidth) {
++          unset_option (OPTSIDEBAR);
++          /* saveSidebarWidth = SidebarWidth; */
++          if (saveSidebarWidth > delim_len) {
++            SidebarWidth = saveSidebarWidth;
++            mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar."));
++            sleep (2);
++          } else {
++            SidebarWidth = 0;
++            mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar. Please set your sidebar_width to a sane value."));
++            sleep (4); /* the advise to set a sane value should be seen long enough */
++          }
++          saveSidebarWidth = 0;
++          return (0);
++        }
++ 
++     if ( SidebarWidth == 0 || !option(OPTSIDEBAR)) {
++       if (SidebarWidth > 0) {
++         saveSidebarWidth = SidebarWidth;
++         SidebarWidth = 0;
++       }
++       unset_option(OPTSIDEBAR);
++       return 0;
++     }
++ 
++         /* get attributes for divider */
++ 	SETCOLOR(MT_COLOR_STATUS);
++ #ifndef USE_SLANG_CURSES
++         attr_get(&attrs, &color_pair, 0);
++ #else
++         color_pair = attr_get();
++ #endif
++ 	SETCOLOR(MT_COLOR_NORMAL);
++ 
++ 	/* draw the divider */
++ 
++ 	for ( ; lines < LINES-1-(menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) {
++ 		move(lines, SidebarWidth - delim_len);
++ 		addstr(NONULL(SidebarDelim));
++ #ifndef USE_SLANG_CURSES
++                 mvchgat(lines, SidebarWidth - delim_len, delim_len, 0, color_pair, NULL);
++ #endif
++ 	}
++ 
++ 	if ( Incoming == 0 ) return 0;
++ 	lines = option(OPTHELP) ? 1 : 0; /* go back to the top */
++ 
++ 	if ( known_lines != LINES || TopBuffy == 0 || BottomBuffy == 0 ) 
++ 		calc_boundaries(menu);
++ 	if ( CurBuffy == 0 ) CurBuffy = Incoming;
++ 
++ 	tmp = TopBuffy;
++ 
++ 	SETCOLOR(MT_COLOR_NORMAL);
++ 
++ 	for ( ; tmp && lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); tmp = tmp->next ) {
++ 		if ( tmp == CurBuffy )
++ 			SETCOLOR(MT_COLOR_INDICATOR);
++ 		else if ( tmp->msg_unread > 0 )
++ 			SETCOLOR(MT_COLOR_NEW);
++ 		else if ( tmp->msg_flagged > 0 )
++ 		        SETCOLOR(MT_COLOR_FLAGGED);
++ 		else
++ 			SETCOLOR(MT_COLOR_NORMAL);
++ 
++ 		move( lines, 0 );
++ 		if ( Context && !strcmp( tmp->path, Context->path ) ) {
++ 			tmp->msg_unread = Context->unread;
++ 			tmp->msgcount = Context->msgcount;
++ 			tmp->msg_flagged = Context->flagged;
++ 		}
++ 		// check whether Maildir is a prefix of the current folder's path
++ 		short maildir_is_prefix = 0;
++ 		if ( (strlen(tmp->path) > strlen(Maildir)) &&
++ 			(strncmp(Maildir, tmp->path, strlen(Maildir)) == 0) )
++         		maildir_is_prefix = 1;
++ 		// calculate depth of current folder and generate its display name with indented spaces
++ 		int sidebar_folder_depth = 0;
++ 		char *sidebar_folder_name;
++ 		sidebar_folder_name = basename(tmp->path);
++ 		if ( maildir_is_prefix ) {
++ 			char *tmp_folder_name;
++ 			int i;
++ 			tmp_folder_name = tmp->path + strlen(Maildir);
++ 			for (i = 0; i < strlen(tmp->path) - strlen(Maildir); i++) {
++ 				if (tmp_folder_name[i] == '/') sidebar_folder_depth++;
++ 			}   
++ 			if (sidebar_folder_depth > 0) {
++ 				sidebar_folder_name = malloc(strlen(basename(tmp->path)) + sidebar_folder_depth + 1);
++ 				for (i=0; i < sidebar_folder_depth; i++)
++ 					sidebar_folder_name[i]=' ';
++ 				sidebar_folder_name[i]=0;
++ 				strncat(sidebar_folder_name, basename(tmp->path), strlen(basename(tmp->path)) + sidebar_folder_depth);
++ 			}
++ 		}
++ 		printw( "%.*s", SidebarWidth - delim_len + 1,
++ 			make_sidebar_entry(sidebar_folder_name, tmp->msgcount,
++ 			tmp->msg_unread, tmp->msg_flagged));
++ 		if (sidebar_folder_depth > 0)
++ 		        free(sidebar_folder_name);
++ 		lines++;
++ 	}
++ 	SETCOLOR(MT_COLOR_NORMAL);
++ 	for ( ; lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) {
++ 		int i = 0;
++ 		move( lines, 0 );
++ 		for ( ; i < SidebarWidth - delim_len; i++ )
++ 			addch(' ');
++ 	}
++ 	return 0;
++ }
++ 
++ 
++ void set_buffystats(CONTEXT* Context)
++ {
++         BUFFY *tmp = Incoming;
++         while(tmp) {
++                 if(Context && !strcmp(tmp->path, Context->path)) {
++ 			tmp->msg_unread = Context->unread;
++ 			tmp->msgcount = Context->msgcount;
++                         break;
++                 }
++                 tmp = tmp->next;
++         }
++ }
++ 
++ void scroll_sidebar(int op, int menu)
++ {
++         if(!SidebarWidth) return;
++         if(!CurBuffy) return;
++ 
++ 	switch (op) {
++ 		case OP_SIDEBAR_NEXT:
++ 			if ( CurBuffy->next == NULL ) return;
++ 			CurBuffy = CurBuffy->next;
++ 			break;
++ 		case OP_SIDEBAR_PREV:
++ 			if ( CurBuffy->prev == NULL ) return;
++ 			CurBuffy = CurBuffy->prev;
++ 			break;
++ 		case OP_SIDEBAR_SCROLL_UP:
++ 			CurBuffy = TopBuffy;
++ 			if ( CurBuffy != Incoming ) {
++ 				calc_boundaries(menu);
++ 				CurBuffy = CurBuffy->prev;
++ 			}
++ 			break;
++ 		case OP_SIDEBAR_SCROLL_DOWN:
++ 			CurBuffy = BottomBuffy;
++ 			if ( CurBuffy->next ) {
++ 				calc_boundaries(menu);
++ 				CurBuffy = CurBuffy->next;
++ 			}
++ 			break;
++ 		default:
++ 			return;
++ 	}
++ 	calc_boundaries(menu);
++ 	draw_sidebar(menu);
++ }
++ 
+*** mutt-1.5.20-orig/sidebar.h	1969-12-31 18:00:00.000000000 -0600
+--- mutt-1.5.20-patched/sidebar.h	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 0 ****
+--- 1,36 ----
++ /*
++  * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
++  * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
++  * 
++  *     This program is free software; you can redistribute it and/or modify
++  *     it under the terms of the GNU General Public License as published by
++  *     the Free Software Foundation; either version 2 of the License, or
++  *     (at your option) any later version.
++  * 
++  *     This program is distributed in the hope that it will be useful,
++  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
++  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++  *     GNU General Public License for more details.
++  * 
++  *     You should have received a copy of the GNU General Public License
++  *     along with this program; if not, write to the Free Software
++  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
++  */ 
++ 
++ #ifndef SIDEBAR_H
++ #define SIDEBAR_H
++ 
++ struct MBOX_LIST {
++ 	char *path;
++ 	int msgcount;
++ 	int new;
++ } MBLIST;
++ 
++ /* parameter is whether or not to go to the status line */
++ /* used for omitting the last | that covers up the status bar in the index */
++ int draw_sidebar(int);
++ void scroll_sidebar(int, int);
++ void set_curbuffy(char*);
++ void set_buffystats(CONTEXT*);
++ 
++ #endif /* SIDEBAR_H */
+*** mutt-1.5.20-orig/doc/Muttrc	2009-06-14 13:53:24.000000000 -0500
+--- mutt-1.5.20-patched/doc/Muttrc	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 657,662 ****
+--- 657,682 ----
+  # $crypt_autosign, $crypt_replysign and $smime_is_default.
+  # 
+  # 
++ # set sidebar_visible=no
++ #
++ # Name: sidebar_visible
++ # Type: boolean
++ # Default: no
++ # 
++ # 
++ # This specifies whether or not to show sidebar (left-side list of folders).
++ # 
++ # 
++ # set sidebar_width=0
++ #
++ # Name: sidebar_width
++ # Type: number
++ # Default: 0
++ # 
++ # 
++ # The width of the sidebar.
++ # 
++ # 
+  # set crypt_autosign=no
+  #
+  # Name: crypt_autosign
+*** mutt-1.5.20-orig/imap/imap.c	2009-06-14 12:19:16.000000000 -0500
+--- mutt-1.5.20-patched/imap/imap.c	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 1521,1527 ****
+  
+      imap_munge_mbox_name (munged, sizeof (munged), name);
+      snprintf (command, sizeof (command),
+! 	      "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT)", munged);
+  
+      if (imap_exec (idata, command, IMAP_CMD_QUEUE) < 0)
+      {
+--- 1521,1527 ----
+  
+      imap_munge_mbox_name (munged, sizeof (munged), name);
+      snprintf (command, sizeof (command),
+! 	      "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT MESSAGES)", munged);
+  
+      if (imap_exec (idata, command, IMAP_CMD_QUEUE) < 0)
+      {
+*** mutt-1.5.20-orig/imap/command.c	2009-01-05 20:58:31.000000000 -0600
+--- mutt-1.5.20-patched/imap/command.c	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 1009,1014 ****
+--- 1009,1021 ----
+  	     opened */
+  	  status->uidnext = oldun;
+  
++         /* Added to make the sidebar show the correct numbers */
++         if (status->messages)
++         {
++           inc->msgcount = status->messages;
++           inc->msg_unread = status->unseen;
++         }
++ 
+          FREE (&value);
+          return;
+        }
+--- orig/compose.c.orig	2010-04-14 20:50:19.000000000 +0200
++++ new/compose.c	2010-09-18 15:29:09.000000000 +0200
+@@ -72,7 +72,7 @@
+ 
+ #define HDR_XOFFSET 10
+ #define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */
+-#define W (COLS - HDR_XOFFSET)
++#define W (COLS - HDR_XOFFSET - SidebarWidth)
+ 
+ static char *Prompts[] =
+ {
+@@ -112,7 +112,7 @@
+ {
+   int off = 0;
+ 
+-  mvaddstr (HDR_CRYPT, 0, "Security: ");
++  mvaddstr (HDR_CRYPT, SidebarWidth, "Security: ");
+ 
+   if ((WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME)) == 0)
+   {
+@@ -144,7 +144,7 @@
+   }
+ 
+   clrtoeol ();
+-  move (HDR_CRYPTINFO, 0);
++  move (HDR_CRYPTINFO, SidebarWidth);
+   clrtoeol ();
+ 
+   if ((WithCrypto & APPLICATION_PGP)
+@@ -161,7 +161,7 @@
+       && (msg->security & ENCRYPT)
+       && SmimeCryptAlg
+       && *SmimeCryptAlg) {
+-      mvprintw (HDR_CRYPTINFO, 40, "%s%s", _("Encrypt with: "),
++      mvprintw (HDR_CRYPTINFO, SidebarWidth + 40, "%s%s", _("Encrypt with: "),
+ 		NONULL(SmimeCryptAlg));
+       off = 20;
+   }
+@@ -190,7 +190,7 @@
+     if (t && t[0] == '0' && t[1] == '\0')
+       t = "<random>";
+     
+-    if (c + mutt_strlen (t) + 2 >= COLS)
++    if (c + mutt_strlen (t) + 2 >= COLS - SidebarWidth)
+       break;
+ 
+     addstr (NONULL(t));
+@@ -242,7 +242,7 @@
+ 
+   buf[0] = 0;
+   rfc822_write_address (buf, sizeof (buf), addr, 1);
+-  mvprintw (line, 0, TITLE_FMT, Prompts[line - 1]);
++  mvprintw (line, SidebarWidth, TITLE_FMT, Prompts[line - 1]);
+   mutt_paddstr (W, buf);
+ }
+ 
+@@ -252,10 +252,10 @@
+   draw_envelope_addr (HDR_TO, msg->env->to);
+   draw_envelope_addr (HDR_CC, msg->env->cc);
+   draw_envelope_addr (HDR_BCC, msg->env->bcc);
+-  mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
++  mvprintw (HDR_SUBJECT, SidebarWidth, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
+   mutt_paddstr (W, NONULL (msg->env->subject));
+   draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
+-  mvprintw (HDR_FCC, 0, TITLE_FMT, Prompts[HDR_FCC - 1]);
++  mvprintw (HDR_FCC, SidebarWidth, TITLE_FMT, Prompts[HDR_FCC - 1]);
+   mutt_paddstr (W, fcc);
+ 
+   if (WithCrypto)
+@@ -266,7 +266,7 @@
+ #endif
+ 
+   SETCOLOR (MT_COLOR_STATUS);
+-  mvaddstr (HDR_ATTACH - 1, 0, _("-- Attachments"));
++  mvaddstr (HDR_ATTACH - 1, SidebarWidth, _("-- Attachments"));
+   BKGDSET (MT_COLOR_STATUS);
+   clrtoeol ();
+ 
+@@ -304,7 +304,7 @@
+   /* redraw the expanded list so the user can see the result */
+   buf[0] = 0;
+   rfc822_write_address (buf, sizeof (buf), *addr, 1);
+-  move (line, HDR_XOFFSET);
++  move (line, HDR_XOFFSET+SidebarWidth);
+   mutt_paddstr (W, buf);
+   
+   return 0;
+@@ -549,7 +549,7 @@
+ 	if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0)
+ 	{
+ 	  mutt_str_replace (&msg->env->subject, buf);
+-	  move (HDR_SUBJECT, HDR_XOFFSET);
++	  move (HDR_SUBJECT, HDR_XOFFSET + SidebarWidth);
+ 	  clrtoeol ();
+ 	  if (msg->env->subject)
+ 	    mutt_paddstr (W, msg->env->subject);
+@@ -566,7 +566,7 @@
+ 	{
+ 	  strfcpy (fcc, buf, fcclen);
+ 	  mutt_pretty_mailbox (fcc, fcclen);
+-	  move (HDR_FCC, HDR_XOFFSET);
++	  move (HDR_FCC, HDR_XOFFSET + SidebarWidth);
+ 	  mutt_paddstr (W, fcc);
+ 	  fccSet = 1;
+ 	}
diff -urN mutt-devel/files/extra-patch-sidebar-nntp mutt-devel-1.5.21-ja.2/files/extra-patch-sidebar-nntp
--- mutt-devel/files/extra-patch-sidebar-nntp	1970-01-01 09:00:00.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/extra-patch-sidebar-nntp	2012-07-22 18:15:04.000000000 +0900
@@ -0,0 +1,1616 @@
+--- orig/buffy.c.orig	2010-09-18 14:12:40.000000000 +0200
++++ new/buffy.c	2010-09-18 14:17:36.000000000 +0200
+@@ -161,6 +161,49 @@
+   }
+ }
+ 
++static int buffy_compare_name(const void *a, const void *b) {
++  const BUFFY *b1 = * (BUFFY * const *) a;
++  const BUFFY *b2 = * (BUFFY * const *) b;
++
++  return mutt_strcoll(b1->path, b2->path);
++}
++
++static BUFFY *buffy_sort(BUFFY *b)
++{
++  BUFFY *tmp = b;
++  int buffycount = 0;
++  BUFFY **ary;
++  int i;
++
++  if (!option(OPTSIDEBARSORT))
++    return b;
++
++  for (; tmp != NULL; tmp = tmp->next)
++    buffycount++;
++
++  ary = (BUFFY **) safe_calloc(buffycount, sizeof (*ary));
++
++  tmp = b;
++  for (i = 0; tmp != NULL; tmp = tmp->next, i++) {
++    ary[i] = tmp;
++  }
++
++  qsort(ary, buffycount, sizeof(*ary), buffy_compare_name);
++
++  for (i = 0; i < buffycount - 1; i++) {
++    ary[i]->next = ary[i+1];
++  }
++  ary[buffycount - 1]->next = NULL;
++  for (i = 1; i < buffycount; i++) {
++    ary[i]->prev = ary[i-1];
++  }
++  ary[0]->prev = NULL;
++
++  tmp = ary[0];
++  free(ary);
++  return tmp;
++}
++
+ BUFFY *mutt_find_mailbox (const char *path)
+ {
+   BUFFY *tmp = NULL;
+@@ -282,6 +325,7 @@
+     else
+       (*tmp)->size = 0;
+   }
++  Incoming = buffy_sort(Incoming);
+   return 0;
+ }
+ 
+@@ -371,12 +415,17 @@
+   return rc;
+ }
+ 
++#define STAT_CHECK_SIZE (sb.st_size > tmp->size)
++#define STAT_CHECK_TIME (sb.st_mtime > sb.st_atime || (tmp->newly_created && sb.st_ctime == sb.st_mtime && sb.st_ctime == sb.st_atime))
++#define STAT_CHECK (option(OPTCHECKMBOXSIZE) ? STAT_CHECK_SIZE : STAT_CHECK_TIME)
++
+ int mutt_buffy_check (int force)
+ {
+   BUFFY *tmp;
+   struct stat sb;
+   struct stat contex_sb;
+   time_t t;
++  CONTEXT *ctx;
+ 
+   sb.st_size=0;
+   contex_sb.st_dev=0;
+@@ -416,6 +465,8 @@
+   
+   for (tmp = Incoming; tmp; tmp = tmp->next)
+   {
++    if ( tmp->new == 1 )
++       tmp->has_new = 1;
+     if (tmp->magic != M_IMAP)
+     {
+       tmp->new = 0;
+@@ -455,18 +506,122 @@
+       {
+       case M_MBOX:
+       case M_MMDF:
+-	if (buffy_mbox_hasnew (tmp, &sb) > 0)
+-	  BuffyCount++;
+-	break;
++        {
++          if (STAT_CHECK || tmp->msgcount == 0)
++          {
++            BUFFY b = *tmp;
++            int msgcount = 0;
++            int msg_unread = 0;
++            /* parse the mailbox, to see how much mail there is */
++            ctx = mx_open_mailbox( tmp->path, M_READONLY | M_QUIET | M_NOSORT | M_PEEK, NULL);
++            if(ctx)
++            {
++              msgcount = ctx->msgcount;
++              msg_unread = ctx->unread;
++              mx_close_mailbox(ctx, 0);
++            }
++            *tmp = b;
++            tmp->msgcount = msgcount;
++            tmp->msg_unread = msg_unread;
++            if(STAT_CHECK) {
++              tmp->has_new = tmp->new = 1;
++              BuffyCount++;
++            }
++          }
++          else if (option(OPTCHECKMBOXSIZE))
++          {
++            /* some other program has deleted mail from the folder */
++            tmp->size = (off_t) sb.st_size;
++          }
++          if (tmp->newly_created &&
++              (sb.st_ctime != sb.st_mtime || sb.st_ctime != sb.st_atime))
++            tmp->newly_created = 0;
++        }
++        break;
++
+ 
+       case M_MAILDIR:
+-	if (buffy_maildir_hasnew (tmp) > 0)
+-	  BuffyCount++;
++        { 
++        char path[_POSIX_PATH_MAX];
++        DIR *dirp;
++        struct dirent *de;
++        /* count new message */
++        snprintf (path, sizeof (path), "%s/new", tmp->path);
++        if ((dirp = opendir (path)) == NULL)
++        {
++          tmp->magic = 0;
++          break;
++        }
++        tmp->msgcount = 0;
++        tmp->msg_unread = 0;
++        tmp->msg_flagged = 0;
++        while ((de = readdir (dirp)) != NULL)
++        {
++          char *p;
++          if (*de->d_name != '.' &&
++              (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')))
++          {
++            tmp->has_new = tmp->new = 1;
++            tmp->msgcount++;
++            tmp->msg_unread++;
++          }
++        }
++        if(tmp->msg_unread)
++          BuffyCount++;
++
++        closedir (dirp);
++
++        /*
++         * count read messages (for folderlist (sidebar) we also need to count
++         * messages in cur so that we the total number of messages
++         */
++        snprintf (path, sizeof (path), "%s/cur", tmp->path);
++        if ((dirp = opendir (path)) == NULL)
++        {
++          tmp->magic = 0;
++          break;
++        }
++        while ((de = readdir (dirp)) != NULL)
++        {
++          char *p;
++          if (*de->d_name != '.') {
++                  if ((p = strstr (de->d_name, ":2,"))) {
++                          if (!strchr (p + 3, 'T')) {
++                                  tmp->msgcount++;
++                                  if ( !strchr (p + 3, 'S'))
++                                          tmp->msg_unread++;
++                                  if (strchr(p + 3, 'F'))
++                                          tmp->msg_flagged++;
++                          }
++                  } else
++                          tmp->msgcount++;
++          }
++        }
++        closedir (dirp);
++        } 
+ 	break;
+ 
+       case M_MH:
+-	if ((tmp->new = mh_buffy (tmp->path)) > 0)
+-	  BuffyCount++;
++        {
++        DIR *dp;
++        char path[_POSIX_PATH_MAX];
++        struct dirent *de;
++        if ((tmp->new = mh_buffy (tmp->path)) > 0)
++          BuffyCount++;
++
++        if ((dp = opendir (path)) == NULL)
++          break;
++        tmp->msgcount = 0;
++        while ((de = readdir (dp)))
++        {
++          if (mh_valid_message (de->d_name))
++          {
++            tmp->msgcount++;
++            tmp->has_new = tmp->new = 1;
++          }
++        }
++        closedir (dp);
++        }
+ 	break;
+       }
+     }
+*** mutt-1.5.20-orig/buffy.h	2009-04-30 00:36:16.000000000 -0500
+--- mutt-1.5.20-patched/buffy.h	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 25,31 ****
+--- 25,36 ----
+    char path[_POSIX_PATH_MAX];
+    off_t size;
+    struct buffy_t *next;
++   struct buffy_t *prev;
+    short new;			/* mailbox has new mail */
++   short has_new;		/* set it new if new and not read */
++   int msgcount;			/* total number of messages */
++   int msg_unread;		/* number of unread messages */
++   int msg_flagged;		/* number of flagged messages */
+    short notified;		/* user has been notified */
+    short magic;			/* mailbox type */
+    short newly_created;		/* mbox or mmdf just popped into existence */
+*** mutt-1.5.20-orig/color.c	2009-05-18 19:11:35.000000000 -0500
+--- mutt-1.5.20-patched/color.c	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 93,98 ****
+--- 93,100 ----
+    { "bold",		MT_COLOR_BOLD },
+    { "underline",	MT_COLOR_UNDERLINE },
+    { "index",		MT_COLOR_INDEX },
++   { "sidebar_new",	MT_COLOR_NEW },
++   { "sidebar_flagged",	MT_COLOR_FLAGGED },
+    { NULL,		0 }
+  };
+  
+*** mutt-1.5.20-orig/curs_main.c	2009-06-13 21:48:36.000000000 -0500
+--- mutt-1.5.20-patched/curs_main.c	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 26,32 ****
+--- 26,34 ----
+  #include "mailbox.h"
+  #include "mapping.h"
+  #include "sort.h"
++ #include "buffy.h"
+  #include "mx.h"
++ #include "sidebar.h"
+  
+  #ifdef USE_POP
+  #include "pop.h"
+***************
+*** 523,530 ****
+         menu->redraw |= REDRAW_STATUS;
+       if (do_buffy_notify)
+       {
+!        if (mutt_buffy_notify () && option (OPTBEEPNEW))
+!  	beep ();
+       }
+       else
+         do_buffy_notify = 1;
+--- 525,536 ----
+         menu->redraw |= REDRAW_STATUS;
+       if (do_buffy_notify)
+       {
+!        if (mutt_buffy_notify ())
+!        {
+!          menu->redraw |= REDRAW_FULL;
+!          if (option (OPTBEEPNEW))
+!            beep ();
+!        }
+       }
+       else
+         do_buffy_notify = 1;
+***************
+*** 536,541 ****
+--- 542,548 ----
+      if (menu->redraw & REDRAW_FULL)
+      {
+        menu_redraw_full (menu);
++       draw_sidebar(menu->menu);
+        mutt_show_error ();
+      }
+  
+***************
+*** 558,567 ****
+--- 565,577 ----
+  
+        if (menu->redraw & REDRAW_STATUS)
+        {
++         DrawFullLine = 1;
+  	menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
++         DrawFullLine = 0;
+  	CLEARLINE (option (OPTSTATUSONTOP) ? 0 : LINES-2);
+  	SETCOLOR (MT_COLOR_STATUS);
+          BKGDSET (MT_COLOR_STATUS);
++         set_buffystats(Context);
+  	mutt_paddstr (COLS, buf);
+  	SETCOLOR (MT_COLOR_NORMAL);
+          BKGDSET (MT_COLOR_NORMAL);
+***************
+*** 575,581 ****
+  	menu->oldcurrent = -1;
+  
+        if (option (OPTARROWCURSOR))
+! 	move (menu->current - menu->top + menu->offset, 2);
+        else if (option (OPTBRAILLEFRIENDLY))
+  	move (menu->current - menu->top + menu->offset, 0);
+        else
+--- 585,591 ----
+  	menu->oldcurrent = -1;
+  
+        if (option (OPTARROWCURSOR))
+! 	move (menu->current - menu->top + menu->offset, SidebarWidth + 2);
+        else if (option (OPTBRAILLEFRIENDLY))
+  	move (menu->current - menu->top + menu->offset, 0);
+        else
+***************
+*** 1055,1060 ****
+--- 1065,1071 ----
+  	  menu->redraw = REDRAW_FULL;
+  	break;
+  
++       case OP_SIDEBAR_OPEN:
+        case OP_MAIN_CHANGE_FOLDER:
+        case OP_MAIN_NEXT_UNREAD_MAILBOX:
+  
+***************
+*** 1086,1092 ****
+  	{
+  	  mutt_buffy (buf, sizeof (buf));
+  
+! 	  if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
+  	  {
+  	    if (menu->menu == MENU_PAGER)
+  	    {
+--- 1097,1107 ----
+  	{
+  	  mutt_buffy (buf, sizeof (buf));
+  
+!           if ( op == OP_SIDEBAR_OPEN ) {
+!               if(!CurBuffy)
+!                 break;
+!             strncpy( buf, CurBuffy->path, sizeof(buf) );  
+! 	    } else if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
+  	  {
+  	    if (menu->menu == MENU_PAGER)
+  	    {
+***************
+*** 1104,1109 ****
+--- 1119,1125 ----
+  	}
+  
+  	mutt_expand_path (buf, sizeof (buf));
++         set_curbuffy(buf);
+  	if (mx_get_magic (buf) <= 0)
+  	{
+  	  mutt_error (_("%s is not a mailbox."), buf);
+***************
+*** 2183,2188 ****
+--- 2199,2210 ----
+  	mutt_what_key();
+  	break;
+  
++       case OP_SIDEBAR_SCROLL_UP:
++       case OP_SIDEBAR_SCROLL_DOWN:
++       case OP_SIDEBAR_NEXT:
++       case OP_SIDEBAR_PREV:
++         scroll_sidebar(op, menu->menu);
++         break;
+        default:
+  	if (menu->menu == MENU_MAIN)
+  	  km_error_key (MENU_MAIN);
+*** mutt-1.5.20-orig/flags.c	2008-12-16 21:50:09.000000000 -0600
+--- mutt-1.5.20-patched/flags.c	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 22,29 ****
+--- 22,31 ----
+  
+  #include "mutt.h"
+  #include "mutt_curses.h"
++ #include "mutt_menu.h"
+  #include "sort.h"
+  #include "mx.h"
++ #include "sidebar.h"
+  
+  void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx)
+  {
+***************
+*** 263,268 ****
+--- 265,271 ----
+     */
+    if (h->searched && (changed != h->changed || deleted != ctx->deleted || tagged != ctx->tagged || flagged != ctx->flagged))
+      h->searched = 0;
++ 	draw_sidebar(0);
+  }
+  
+  void mutt_tag_set_flag (int flag, int bf)
+*** mutt-1.5.20-orig/functions.h	2009-04-30 00:36:17.000000000 -0500
+--- mutt-1.5.20-patched/functions.h	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 168,173 ****
+--- 168,178 ----
+    { "decrypt-save",		OP_DECRYPT_SAVE,		NULL },
+  
+  
++  { "sidebar-scroll-up",	OP_SIDEBAR_SCROLL_UP, NULL },
++  { "sidebar-scroll-down",	OP_SIDEBAR_SCROLL_DOWN, NULL },
++  { "sidebar-next",		OP_SIDEBAR_NEXT, NULL },
++  { "sidebar-prev",		OP_SIDEBAR_PREV, NULL },
++  { "sidebar-open",		OP_SIDEBAR_OPEN, NULL },
+    { NULL,			0,				NULL }
+  };
+  
+***************
+*** 268,273 ****
+--- 273,283 ----
+  
+    { "what-key",		OP_WHAT_KEY,		NULL },
+  
++   { "sidebar-scroll-up",	OP_SIDEBAR_SCROLL_UP, NULL },
++   { "sidebar-scroll-down",	OP_SIDEBAR_SCROLL_DOWN, NULL },
++   { "sidebar-next",	OP_SIDEBAR_NEXT, NULL },
++   { "sidebar-prev",	OP_SIDEBAR_PREV, NULL },
++   { "sidebar-open", OP_SIDEBAR_OPEN, NULL },
+    { NULL,		0,				NULL }
+  };
+  
+*** mutt-1.5.20-orig/globals.h	2009-06-03 15:48:31.000000000 -0500
+--- mutt-1.5.20-patched/globals.h	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 117,122 ****
+--- 117,123 ----
+  WHERE char *SendCharset;
+  WHERE char *Sendmail;
+  WHERE char *Shell;
++ WHERE char *SidebarDelim;
+  WHERE char *Signature;
+  WHERE char *SimpleSearch;
+  #if USE_SMTP
+***************
+*** 206,211 ****
+--- 207,215 ----
+  WHERE short ScoreThresholdRead;
+  WHERE short ScoreThresholdFlag;
+  
++ WHERE struct buffy_t *CurBuffy INITVAL(0);
++ WHERE short DrawFullLine INITVAL(0);
++ WHERE short SidebarWidth;
+  #ifdef USE_IMAP
+  WHERE short ImapKeepalive;
+  WHERE short ImapPipelineDepth;
+*** mutt-1.5.20-orig/init.h	2009-06-13 16:35:21.000000000 -0500
+--- mutt-1.5.20-patched/init.h	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 1941,1946 ****
+--- 1941,1967 ----
+    ** not used.
+    ** (PGP only)
+    */
++   {"sidebar_delim", DT_STR, R_BOTH, UL &SidebarDelim, "|"},
++   /*
++   ** .pp
++   ** This specifies the delimiter between the sidebar (if visible) and 
++   ** other screens.
++   */
++   { "sidebar_visible", DT_BOOL, R_BOTH, OPTSIDEBAR, 0 },
++   /*
++   ** .pp
++   ** This specifies whether or not to show sidebar (left-side list of folders).
++   */
++   { "sidebar_sort", DT_BOOL, R_BOTH, OPTSIDEBARSORT, 0 },
++   /*
++   ** .pp
++   ** This specifies whether or not to sort the sidebar alphabetically.
++   */
++   { "sidebar_width", DT_NUM, R_BOTH, UL &SidebarWidth, 0 },
++   /*
++   ** .pp
++   ** The width of the sidebar.
++   */
+    { "pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0},
+    /*
+    ** .pp
+*** mutt-1.5.20-orig/mailbox.h	2009-04-30 00:36:17.000000000 -0500
+--- mutt-1.5.20-patched/mailbox.h	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 27,32 ****
+--- 27,33 ----
+  #define M_NEWFOLDER	(1<<4) /* create a new folder - same as M_APPEND, but uses
+  				* safe_fopen() for mbox-style folders.
+  				*/
++ #define M_PEEK		(1<<5) /* revert atime back after taking a look (if applicable) */
+  
+  /* mx_open_new_message() */
+  #define M_ADD_FROM	1	/* add a From_ line */
+--- orig/Makefile.am.orig	2010-09-18 13:23:19.000000000 +0200
++++ new/Makefile.am	2010-09-18 13:25:19.000000000 +0200
+@@ -34,7 +34,7 @@
+ 	score.c send.c sendlib.c signal.c sort.c \
+ 	status.c system.c thread.c charset.c history.c lib.c \
+ 	muttlib.c editmsg.c mbyte.c \
+-	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c
++	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c sidebar.c
+ 
+ nodist_mutt_SOURCES = $(BUILT_SOURCES)
+ 
+--- orig/Makefile.in.orig	2010-09-18 13:23:19.000000000 +0200
++++ new/Makefile.in	2010-09-18 13:27:19.000000000 +0200
+@@ -89,7 +89,7 @@
+ 	system.$(OBJEXT) thread.$(OBJEXT) charset.$(OBJEXT) \
+ 	history.$(OBJEXT) lib.$(OBJEXT) muttlib.$(OBJEXT) \
+ 	editmsg.$(OBJEXT) mbyte.$(OBJEXT) url.$(OBJEXT) \
+-	ascii.$(OBJEXT) crypt-mod.$(OBJEXT) safe_asprintf.$(OBJEXT)
++	ascii.$(OBJEXT) crypt-mod.$(OBJEXT) safe_asprintf.$(OBJEXT) sidebar.$(OBJEXT)
+ am__objects_1 =
+ am__objects_2 = patchlist.$(OBJEXT) $(am__objects_1)
+ nodist_mutt_OBJECTS = $(am__objects_2)
+@@ -363,7 +363,7 @@
+ 	score.c send.c sendlib.c signal.c sort.c \
+ 	status.c system.c thread.c charset.c history.c lib.c \
+ 	muttlib.c editmsg.c mbyte.c \
+-	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c
++	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c sidebar.c
+ 
+ nodist_mutt_SOURCES = $(BUILT_SOURCES)
+ mutt_LDADD = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAP) $(MUTTLIBS) \
+@@ -397,7 +397,7 @@
+ 	README.SSL smime.h group.h \
+ 	muttbug pgppacket.h depcomp ascii.h BEWARE PATCHES patchlist.sh \
+ 	ChangeLog mkchangelog.sh mutt_idna.h \
+-	snprintf.c regex.c crypt-gpgme.h hcachever.sh.in
++	snprintf.c regex.c crypt-gpgme.h sidebar.h hcachever.sh.in
+ 
+ EXTRA_SCRIPTS = smime_keys
+ mutt_dotlock_SOURCES = mutt_dotlock.c
+*** mutt-1.5.20-orig/mbox.c	2009-06-10 23:29:41.000000000 -0500
+--- mutt-1.5.20-patched/mbox.c	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 100,105 ****
+--- 100,106 ----
+      mutt_perror (ctx->path);
+      return (-1);
+    }
++   ctx->atime = sb.st_atime;
+    ctx->mtime = sb.st_mtime;
+    ctx->size = sb.st_size;
+  
+***************
+*** 255,260 ****
+--- 256,262 ----
+  
+    ctx->size = sb.st_size;
+    ctx->mtime = sb.st_mtime;
++   ctx->atime = sb.st_atime;
+  
+  #ifdef NFS_ATTRIBUTE_HACK
+    if (sb.st_mtime > sb.st_atime)
+*** mutt-1.5.20-orig/menu.c	2009-06-01 11:29:32.000000000 -0500
+--- mutt-1.5.20-patched/menu.c	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 24,29 ****
+--- 24,30 ----
+  #include "mutt_curses.h"
+  #include "mutt_menu.h"
+  #include "mbyte.h"
++ #include "sidebar.h"
+  
+  #include <string.h>
+  #include <stdlib.h>
+***************
+*** 156,162 ****
+  {
+    char *scratch = safe_strdup (s);
+    int shift = option (OPTARROWCURSOR) ? 3 : 0;
+!   int cols = COLS - shift;
+  
+    mutt_format_string (s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen (scratch), 1);
+    s[n - 1] = 0;
+--- 157,163 ----
+  {
+    char *scratch = safe_strdup (s);
+    int shift = option (OPTARROWCURSOR) ? 3 : 0;
+!   int cols = COLS - shift - SidebarWidth;
+  
+    mutt_format_string (s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen (scratch), 1);
+    s[n - 1] = 0;
+***************
+*** 207,212 ****
+--- 208,214 ----
+    char buf[LONG_STRING];
+    int i;
+  
++   draw_sidebar(1);
+    for (i = menu->top; i < menu->top + menu->pagelen; i++)
+    {
+      if (i < menu->max)
+***************
+*** 217,223 ****
+        if (option (OPTARROWCURSOR))
+        {
+          attrset (menu->color (i));
+! 	CLEARLINE (i - menu->top + menu->offset);
+  
+  	if (i == menu->current)
+  	{
+--- 219,225 ----
+        if (option (OPTARROWCURSOR))
+        {
+          attrset (menu->color (i));
+! 	CLEARLINE_WIN (i - menu->top + menu->offset);
+  
+  	if (i == menu->current)
+  	{
+***************
+*** 246,259 ****
+  	  BKGDSET (MT_COLOR_INDICATOR);
+  	}
+  
+! 	CLEARLINE (i - menu->top + menu->offset);
+  	print_enriched_string (menu->color(i), (unsigned char *) buf, i != menu->current);
+          SETCOLOR (MT_COLOR_NORMAL);
+          BKGDSET (MT_COLOR_NORMAL);
+        }
+      }
+      else
+!       CLEARLINE (i - menu->top + menu->offset);
+    }
+    menu->redraw = 0;
+  }
+--- 248,261 ----
+  	  BKGDSET (MT_COLOR_INDICATOR);
+  	}
+  
+! 	CLEARLINE_WIN (i - menu->top + menu->offset);
+  	print_enriched_string (menu->color(i), (unsigned char *) buf, i != menu->current);
+          SETCOLOR (MT_COLOR_NORMAL);
+          BKGDSET (MT_COLOR_NORMAL);
+        }
+      }
+      else
+!       CLEARLINE_WIN (i - menu->top + menu->offset);
+    }
+    menu->redraw = 0;
+  }
+***************
+*** 268,274 ****
+      return;
+    }
+    
+!   move (menu->oldcurrent + menu->offset - menu->top, 0);
+    SETCOLOR (MT_COLOR_NORMAL);
+    BKGDSET (MT_COLOR_NORMAL);
+  
+--- 270,276 ----
+      return;
+    }
+    
+!   move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth);
+    SETCOLOR (MT_COLOR_NORMAL);
+    BKGDSET (MT_COLOR_NORMAL);
+  
+***************
+*** 283,295 ****
+        clrtoeol ();
+        menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
+        menu_pad_string (buf, sizeof (buf));
+!       move (menu->oldcurrent + menu->offset - menu->top, 3);
+        print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
+        SETCOLOR (MT_COLOR_NORMAL);
+      }
+  
+      /* now draw it in the new location */
+!     move (menu->current + menu->offset - menu->top, 0);
+      attrset (menu->color (menu->current));
+      ADDCOLOR (MT_COLOR_INDICATOR);
+      addstr ("->");
+--- 285,297 ----
+        clrtoeol ();
+        menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
+        menu_pad_string (buf, sizeof (buf));
+!       move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth + 3);
+        print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
+        SETCOLOR (MT_COLOR_NORMAL);
+      }
+  
+      /* now draw it in the new location */
+!     move (menu->current + menu->offset - menu->top, SidebarWidth);
+      attrset (menu->color (menu->current));
+      ADDCOLOR (MT_COLOR_INDICATOR);
+      addstr ("->");
+***************
+*** 310,316 ****
+      attrset (menu->color (menu->current));
+      ADDCOLOR (MT_COLOR_INDICATOR);
+      BKGDSET (MT_COLOR_INDICATOR);
+!     CLEARLINE (menu->current - menu->top + menu->offset);
+      print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0);
+      SETCOLOR (MT_COLOR_NORMAL);
+      BKGDSET (MT_COLOR_NORMAL);
+--- 312,318 ----
+      attrset (menu->color (menu->current));
+      ADDCOLOR (MT_COLOR_INDICATOR);
+      BKGDSET (MT_COLOR_INDICATOR);
+!     CLEARLINE_WIN (menu->current - menu->top + menu->offset);
+      print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0);
+      SETCOLOR (MT_COLOR_NORMAL);
+      BKGDSET (MT_COLOR_NORMAL);
+***************
+*** 322,328 ****
+  {
+    char buf[LONG_STRING];
+    
+!   move (menu->current + menu->offset - menu->top, 0);
+    menu_make_entry (buf, sizeof (buf), menu, menu->current);
+    menu_pad_string (buf, sizeof (buf));
+  
+--- 324,330 ----
+  {
+    char buf[LONG_STRING];
+    
+!   move (menu->current + menu->offset - menu->top, SidebarWidth);
+    menu_make_entry (buf, sizeof (buf), menu, menu->current);
+    menu_pad_string (buf, sizeof (buf));
+  
+***************
+*** 876,882 ****
+      
+      
+      if (option (OPTARROWCURSOR))
+!       move (menu->current - menu->top + menu->offset, 2);
+      else if (option (OPTBRAILLEFRIENDLY))
+        move (menu->current - menu->top + menu->offset, 0);
+      else
+--- 878,884 ----
+      
+      
+      if (option (OPTARROWCURSOR))
+!       move (menu->current - menu->top + menu->offset, SidebarWidth + 2);
+      else if (option (OPTBRAILLEFRIENDLY))
+        move (menu->current - menu->top + menu->offset, 0);
+      else
+*** mutt-1.5.20-orig/mutt_curses.h	2008-11-11 13:55:47.000000000 -0600
+--- mutt-1.5.20-patched/mutt_curses.h	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 64,69 ****
+--- 64,70 ----
+  #undef lines
+  #endif /* lines */
+  
++ #define CLEARLINE_WIN(x) move(x,SidebarWidth), clrtoeol()
+  #define CLEARLINE(x) move(x,0), clrtoeol()
+  #define CENTERLINE(x,y) move(y, (COLS-strlen(x))/2), addstr(x)
+  #define BEEP() do { if (option (OPTBEEP)) beep(); } while (0)
+***************
+*** 126,131 ****
+--- 127,134 ----
+    MT_COLOR_BOLD,
+    MT_COLOR_UNDERLINE,
+    MT_COLOR_INDEX,
++   MT_COLOR_NEW,
++   MT_COLOR_FLAGGED,
+    MT_COLOR_MAX
+  };
+  
+*** mutt-1.5.20-orig/mutt.h	2009-06-12 17:15:42.000000000 -0500
+--- mutt-1.5.20-patched/mutt.h	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 418,423 ****
+--- 418,425 ----
+    OPTSAVEEMPTY,
+    OPTSAVENAME,
+    OPTSCORE,
++   OPTSIDEBAR,
++   OPTSIDEBARSORT,
+    OPTSIGDASHES,
+    OPTSIGONTOP,
+    OPTSORTRE,
+***************
+*** 854,859 ****
+--- 856,862 ----
+  {
+    char *path;
+    FILE *fp;
++   time_t atime;
+    time_t mtime;
+    off_t size;
+    off_t vsize;
+***************
+*** 888,893 ****
+--- 891,897 ----
+    unsigned int quiet : 1;	/* inhibit status messages? */
+    unsigned int collapsed : 1;   /* are all threads collapsed? */
+    unsigned int closing : 1;	/* mailbox is being closed */
++   unsigned int peekonly : 1;	/* just taking a glance, revert atime */
+  
+    /* driver hooks */
+    void *data;			/* driver specific data */
+*** mutt-1.5.20-orig/muttlib.c	2009-05-18 19:11:35.000000000 -0500
+--- mutt-1.5.20-patched/muttlib.c	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 1232,1237 ****
+--- 1232,1239 ----
+  	  pl = pw = 1;
+  
+  	/* see if there's room to add content, else ignore */
++         if ( DrawFullLine )
++         {
+  	if ((col < COLS && wlen < destlen) || soft)
+  	{
+  	  int pad;
+***************
+*** 1274,1279 ****
+--- 1276,1327 ----
+  	  col += wid;
+  	  src += pl;
+  	}
++         }
++         else
++         {
++ 	if ((col < COLS-SidebarWidth && wlen < destlen) || soft)
++         {
++ 	  int pad;
++ 
++ 	  /* get contents after padding */
++ 	  mutt_FormatString (buf, sizeof (buf), 0, src + pl, callback, data, flags);
++ 	  len = mutt_strlen (buf);
++ 	  wid = mutt_strwidth (buf);
++ 
++ 	  /* try to consume as many columns as we can, if we don't have
++ 	   * memory for that, use as much memory as possible */
++ 	  pad = (COLS - SidebarWidth - col - wid) / pw;
++ 	  if (pad > 0 && wlen + (pad * pl) + len > destlen)
++ 	    pad = ((signed)(destlen - wlen - len)) / pl;
++ 	  if (pad > 0)
++ 	  {
++ 	    while (pad--)
++ 	    {
++ 	      memcpy (wptr, src, pl);
++ 	      wptr += pl;
++ 	      wlen += pl;
++ 	      col += pw;
++ 	    }
++ 	  }
++ 	  else if (soft && pad < 0)
++ 	  {
++ 	    /* \0-terminate dest for length computation in mutt_wstr_trunc() */
++ 	    *wptr = 0;
++ 	    /* make sure right part is at most as wide as display */
++ 	    len = mutt_wstr_trunc (buf, destlen, COLS, &wid);
++ 	    /* truncate left so that right part fits completely in */
++ 	    wlen = mutt_wstr_trunc (dest, destlen - len, col + pad, &col);
++ 	    wptr = dest + wlen;
++ 	  }
++ 	  if (len + wlen > destlen)
++ 	    len = mutt_wstr_trunc (buf, destlen - wlen, COLS - SidebarWidth - col, NULL);
++ 	  memcpy (wptr, buf, len);
++ 	  wptr += len;
++ 	  wlen += len;
++ 	  col += wid;
++ 	  src += pl;
++ 	}
++         }
+  	break; /* skip rest of input */
+        }
+        else if (ch == '|')
+*** mutt-1.5.20-orig/mx.c	2009-06-10 23:29:41.000000000 -0500
+--- mutt-1.5.20-patched/mx.c	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 581,586 ****
+--- 581,587 ----
+   *		M_APPEND	open mailbox for appending
+   *		M_READONLY	open mailbox in read-only mode
+   *		M_QUIET		only print error messages
++  *		M_PEEK		revert atime where applicable
+   *	ctx	if non-null, context struct to use
+   */
+  CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx)
+***************
+*** 603,608 ****
+--- 604,611 ----
+      ctx->quiet = 1;
+    if (flags & M_READONLY)
+      ctx->readonly = 1;
++   if (flags & M_PEEK)
++     ctx->peekonly = 1;
+  
+    if (flags & (M_APPEND|M_NEWFOLDER))
+    {
+***************
+*** 702,710 ****
+--- 705,725 ----
+  void mx_fastclose_mailbox (CONTEXT *ctx)
+  {
+    int i;
++ #ifndef BUFFY_SIZE
++   struct utimbuf ut;
++ #endif
+  
+    if(!ctx) 
+      return;
++ #ifndef BUFFY_SIZE
++   /* fix up the times so buffy won't get confused */
++   if (ctx->peekonly && ctx->path && ctx->mtime > ctx->atime)
++   {
++     ut.actime = ctx->atime;
++     ut.modtime = ctx->mtime;
++     utime (ctx->path, &ut); 
++   }
++ #endif
+  
+    if (ctx->mx_close)
+      ctx->mx_close (ctx);
+*** mutt-1.5.20-orig/OPS	2009-05-13 00:01:13.000000000 -0500
+--- mutt-1.5.20-patched/OPS	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 178,180 ****
+--- 178,185 ----
+  OP_MAIN_SHOW_LIMIT "show currently active limit pattern"
+  OP_MAIN_COLLAPSE_THREAD "collapse/uncollapse current thread"
+  OP_MAIN_COLLAPSE_ALL "collapse/uncollapse all threads"
++ OP_SIDEBAR_SCROLL_UP "scroll the mailbox pane up 1 page"
++ OP_SIDEBAR_SCROLL_DOWN "scroll the mailbox pane down 1 page"
++ OP_SIDEBAR_NEXT "go down to next mailbox"
++ OP_SIDEBAR_PREV "go to previous mailbox"
++ OP_SIDEBAR_OPEN "open hilighted mailbox"
+--- orig/pager.c.orig	2010-09-18 13:23:19.000000000 +0200
++++ new/pager.c	2010-09-18 14:03:08.000000000 +0200
+@@ -29,6 +29,7 @@
+ #include "pager.h"
+ #include "attach.h"
+ #include "mbyte.h"
++#include "sidebar.h"
+ 
+ #include "mutt_crypt.h"
+ 
+@@ -1104,6 +1105,7 @@
+   if (check_attachment_marker ((char *)buf) == 0)
+     wrap_cols = COLS;
+ 
++  wrap_cols -= SidebarWidth;
+   /* FIXME: this should come from lineInfo */
+   memset(&mbstate, 0, sizeof(mbstate));
+ 
+@@ -1778,7 +1780,7 @@
+     if ((redraw & REDRAW_BODY) || topline != oldtopline)
+     {
+       do {
+-	move (bodyoffset, 0);
++	move (bodyoffset, SidebarWidth);
+ 	curline = oldtopline = topline;
+ 	lines = 0;
+ 	force_redraw = 0;
+@@ -1791,6 +1793,7 @@
+ 			    &QuoteList, &q_level, &force_redraw, &SearchRE) > 0)
+ 	    lines++;
+ 	  curline++;
++  	  move(lines + bodyoffset, SidebarWidth);
+ 	}
+ 	last_offset = lineInfo[curline].offset;
+       } while (force_redraw);
+@@ -1804,6 +1807,7 @@
+ 	  addch ('~');
+ 	addch ('\n');
+ 	lines++;
++  	move(lines + bodyoffset, SidebarWidth);
+       }
+       /* We are going to update the pager status bar, so it isn't
+        * necessary to reset to normal color now. */
+@@ -1827,21 +1831,21 @@
+       /* print out the pager status bar */
+       SETCOLOR (MT_COLOR_STATUS);
+       BKGDSET (MT_COLOR_STATUS);
+-      CLEARLINE (statusoffset);
++      CLEARLINE_WIN (statusoffset);
+ 
+       if (IsHeader (extra) || IsMsgAttach (extra))
+       {
+-	size_t l1 = COLS * MB_LEN_MAX;
++	size_t l1 = (COLS-SidebarWidth) * MB_LEN_MAX;
+ 	size_t l2 = sizeof (buffer);
+ 	hfi.hdr = (IsHeader (extra)) ? extra->hdr : extra->bdy->hdr;
+ 	mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt), &hfi, M_FORMAT_MAKEPRINT);
+-	mutt_paddstr (COLS, buffer);
++	mutt_paddstr (COLS-SidebarWidth, buffer);
+       }
+       else
+       {
+ 	char bn[STRING];
+ 	snprintf (bn, sizeof (bn), "%s (%s)", banner, pager_progress_str);
+-	mutt_paddstr (COLS, bn);
++	mutt_paddstr (COLS-SidebarWidth, bn);
+       }
+       BKGDSET (MT_COLOR_NORMAL);
+       SETCOLOR (MT_COLOR_NORMAL);
+@@ -1852,18 +1856,23 @@
+       /* redraw the pager_index indicator, because the
+        * flags for this message might have changed. */
+       menu_redraw_current (index);
++      draw_sidebar(MENU_PAGER);
+ 
+       /* print out the index status bar */
+       menu_status_line (buffer, sizeof (buffer), index, NONULL(Status));
+  
+-      move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), 0);
++      move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), SidebarWidth);
+       SETCOLOR (MT_COLOR_STATUS);
+       BKGDSET (MT_COLOR_STATUS);
+-      mutt_paddstr (COLS, buffer);
++      mutt_paddstr (COLS-SidebarWidth, buffer);
+       SETCOLOR (MT_COLOR_NORMAL);
+       BKGDSET (MT_COLOR_NORMAL);
+     }
+ 
++    /* if we're not using the index, update every time */
++    if ( index == 0 )
++      draw_sidebar(MENU_PAGER);
++
+     redraw = 0;
+ 
+     if (option(OPTBRAILLEFRIENDLY)) {
+@@ -2852,6 +2861,13 @@
+ 	mutt_what_key ();
+ 	break;
+ 
++      case OP_SIDEBAR_SCROLL_UP:
++      case OP_SIDEBAR_SCROLL_DOWN:
++      case OP_SIDEBAR_NEXT:
++      case OP_SIDEBAR_PREV:
++	scroll_sidebar(ch, MENU_PAGER);
++ 	break;
++
+       default:
+ 	ch = -1;
+ 	break;
+*** mutt-1.5.20-orig/PATCHES	2008-11-11 13:55:46.000000000 -0600
+--- mutt-1.5.20-patched/PATCHES	2009-06-19 22:20:31.000000000 -0500
+***************
+*** 0 ****
+--- 1 ----
++ patch-1.5.20.sidebar.20090619.txt
+*** mutt-1.5.20-orig/sidebar.c	1969-12-31 18:00:00.000000000 -0600
+--- mutt-1.5.20-patched/sidebar.c	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 0 ****
+--- 1,333 ----
++ /*
++  * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
++  * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
++  * 
++  *     This program is free software; you can redistribute it and/or modify
++  *     it under the terms of the GNU General Public License as published by
++  *     the Free Software Foundation; either version 2 of the License, or
++  *     (at your option) any later version.
++  * 
++  *     This program is distributed in the hope that it will be useful,
++  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
++  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++  *     GNU General Public License for more details.
++  * 
++  *     You should have received a copy of the GNU General Public License
++  *     along with this program; if not, write to the Free Software
++  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
++  */ 
++ 
++ 
++ #if HAVE_CONFIG_H
++ # include "config.h"
++ #endif
++ 
++ #include "mutt.h"
++ #include "mutt_menu.h"
++ #include "mutt_curses.h"
++ #include "sidebar.h"
++ #include "buffy.h"
++ #include <libgen.h>
++ #include "keymap.h"
++ #include <stdbool.h>
++ 
++ /*BUFFY *CurBuffy = 0;*/
++ static BUFFY *TopBuffy = 0;
++ static BUFFY *BottomBuffy = 0;
++ static int known_lines = 0;
++ 
++ static int quick_log10(int n)
++ {
++         char string[32];
++         sprintf(string, "%d", n);
++         return strlen(string);
++ }
++ 
++ void calc_boundaries (int menu)
++ {
++ 	BUFFY *tmp = Incoming;
++ 
++ 	if ( known_lines != LINES ) {
++ 		TopBuffy = BottomBuffy = 0;
++ 		known_lines = LINES;
++ 	}
++ 	for ( ; tmp->next != 0; tmp = tmp->next )
++ 		tmp->next->prev = tmp;
++ 
++ 	if ( TopBuffy == 0 && BottomBuffy == 0 )
++ 		TopBuffy = Incoming;
++ 	if ( BottomBuffy == 0 ) {
++ 		int count = LINES - 2 - (menu != MENU_PAGER || option(OPTSTATUSONTOP));
++ 		BottomBuffy = TopBuffy;
++ 		while ( --count && BottomBuffy->next )
++ 			BottomBuffy = BottomBuffy->next;
++ 	}
++ 	else if ( TopBuffy == CurBuffy->next ) {
++ 		int count = LINES - 2 - (menu != MENU_PAGER);
++ 		BottomBuffy = CurBuffy;
++ 		tmp = BottomBuffy;
++ 		while ( --count && tmp->prev)
++ 			tmp = tmp->prev;
++ 		TopBuffy = tmp;
++ 	}
++ 	else if ( BottomBuffy == CurBuffy->prev ) {
++ 		int count = LINES - 2 - (menu != MENU_PAGER);
++ 		TopBuffy = CurBuffy;
++ 		tmp = TopBuffy;
++ 		while ( --count && tmp->next )
++ 			tmp = tmp->next;
++ 		BottomBuffy = tmp;
++ 	}
++ }
++ 
++ char *make_sidebar_entry(char *box, int size, int new, int flagged)
++ {
++ 	static char *entry = 0;
++ 	char *c;
++ 	int i = 0;
++ 	int delim_len = strlen(SidebarDelim);
++ 
++ 	c = realloc(entry, SidebarWidth - delim_len + 2);
++ 	if ( c ) entry = c;
++ 	entry[SidebarWidth - delim_len + 1] = 0;
++ 	for (; i < SidebarWidth - delim_len + 1; entry[i++] = ' ' );
++ 	i = strlen(box);
++ 	strncpy( entry, box, i < (SidebarWidth - delim_len + 1) ? i : (SidebarWidth - delim_len + 1) );
++ 
++         if (size == -1)
++                 sprintf(entry + SidebarWidth - delim_len - 3, "?");
++         else if ( new ) {
++           if (flagged > 0) {
++               sprintf(
++ 		        entry + SidebarWidth - delim_len - 5 - quick_log10(size) - quick_log10(new) - quick_log10(flagged),
++ 		        "% d(%d)[%d]", size, new, flagged);
++           } else {
++               sprintf(
++                       entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(new),
++                       "% d(%d)", size, new);
++           }
++         } else if (flagged > 0) {
++               sprintf( entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(flagged), "% d[%d]", size, flagged);
++         } else {
++               sprintf( entry + SidebarWidth - delim_len - 1 - quick_log10(size), "% d", size);
++         }
++ 	return entry;
++ }
++ 
++ void set_curbuffy(char buf[LONG_STRING])
++ {
++   BUFFY* tmp = CurBuffy = Incoming;
++ 
++   if (!Incoming)
++     return;
++ 
++   while(1) {
++     if(!strcmp(tmp->path, buf)) {
++       CurBuffy = tmp;
++       break;
++     }
++ 
++     if(tmp->next)
++       tmp = tmp->next;
++     else
++       break;
++   }
++ }
++ 
++ int draw_sidebar(int menu) {
++ 
++ 	int lines = option(OPTHELP) ? 1 : 0;
++ 	BUFFY *tmp;
++ #ifndef USE_SLANG_CURSES
++         attr_t attrs;
++ #endif
++         short delim_len = strlen(SidebarDelim);
++         short color_pair;
++ 
++         static bool initialized = false;
++         static int prev_show_value;
++         static short saveSidebarWidth;
++ 
++         /* initialize first time */
++         if(!initialized) {
++                 prev_show_value = option(OPTSIDEBAR);
++                 saveSidebarWidth = SidebarWidth;
++                 if(!option(OPTSIDEBAR)) SidebarWidth = 0;
++                 initialized = true;
++         }
++ 
++         /* save or restore the value SidebarWidth */
++         if(prev_show_value != option(OPTSIDEBAR)) {
++                 if(prev_show_value && !option(OPTSIDEBAR)) {
++                         saveSidebarWidth = SidebarWidth;
++                         SidebarWidth = 0;
++                 } else if(!prev_show_value && option(OPTSIDEBAR)) {
++                         SidebarWidth = saveSidebarWidth;
++                 }
++                 prev_show_value = option(OPTSIDEBAR);
++         }
++ 
++ 
++ //	if ( SidebarWidth == 0 ) return 0;
++        if (SidebarWidth > 0 && option (OPTSIDEBAR)
++            && delim_len >= SidebarWidth) {
++          unset_option (OPTSIDEBAR);
++          /* saveSidebarWidth = SidebarWidth; */
++          if (saveSidebarWidth > delim_len) {
++            SidebarWidth = saveSidebarWidth;
++            mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar."));
++            sleep (2);
++          } else {
++            SidebarWidth = 0;
++            mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar. Please set your sidebar_width to a sane value."));
++            sleep (4); /* the advise to set a sane value should be seen long enough */
++          }
++          saveSidebarWidth = 0;
++          return (0);
++        }
++ 
++     if ( SidebarWidth == 0 || !option(OPTSIDEBAR)) {
++       if (SidebarWidth > 0) {
++         saveSidebarWidth = SidebarWidth;
++         SidebarWidth = 0;
++       }
++       unset_option(OPTSIDEBAR);
++       return 0;
++     }
++ 
++         /* get attributes for divider */
++ 	SETCOLOR(MT_COLOR_STATUS);
++ #ifndef USE_SLANG_CURSES
++         attr_get(&attrs, &color_pair, 0);
++ #else
++         color_pair = attr_get();
++ #endif
++ 	SETCOLOR(MT_COLOR_NORMAL);
++ 
++ 	/* draw the divider */
++ 
++ 	for ( ; lines < LINES-1-(menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) {
++ 		move(lines, SidebarWidth - delim_len);
++ 		addstr(NONULL(SidebarDelim));
++ #ifndef USE_SLANG_CURSES
++                 mvchgat(lines, SidebarWidth - delim_len, delim_len, 0, color_pair, NULL);
++ #endif
++ 	}
++ 
++ 	if ( Incoming == 0 ) return 0;
++ 	lines = option(OPTHELP) ? 1 : 0; /* go back to the top */
++ 
++ 	if ( known_lines != LINES || TopBuffy == 0 || BottomBuffy == 0 ) 
++ 		calc_boundaries(menu);
++ 	if ( CurBuffy == 0 ) CurBuffy = Incoming;
++ 
++ 	tmp = TopBuffy;
++ 
++ 	SETCOLOR(MT_COLOR_NORMAL);
++ 
++ 	for ( ; tmp && lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); tmp = tmp->next ) {
++ 		if ( tmp == CurBuffy )
++ 			SETCOLOR(MT_COLOR_INDICATOR);
++ 		else if ( tmp->msg_unread > 0 )
++ 			SETCOLOR(MT_COLOR_NEW);
++ 		else if ( tmp->msg_flagged > 0 )
++ 		        SETCOLOR(MT_COLOR_FLAGGED);
++ 		else
++ 			SETCOLOR(MT_COLOR_NORMAL);
++ 
++ 		move( lines, 0 );
++ 		if ( Context && !strcmp( tmp->path, Context->path ) ) {
++ 			tmp->msg_unread = Context->unread;
++ 			tmp->msgcount = Context->msgcount;
++ 			tmp->msg_flagged = Context->flagged;
++ 		}
++ 		// check whether Maildir is a prefix of the current folder's path
++ 		short maildir_is_prefix = 0;
++ 		if ( (strlen(tmp->path) > strlen(Maildir)) &&
++ 			(strncmp(Maildir, tmp->path, strlen(Maildir)) == 0) )
++         		maildir_is_prefix = 1;
++ 		// calculate depth of current folder and generate its display name with indented spaces
++ 		int sidebar_folder_depth = 0;
++ 		char *sidebar_folder_name;
++ 		sidebar_folder_name = basename(tmp->path);
++ 		if ( maildir_is_prefix ) {
++ 			char *tmp_folder_name;
++ 			int i;
++ 			tmp_folder_name = tmp->path + strlen(Maildir);
++ 			for (i = 0; i < strlen(tmp->path) - strlen(Maildir); i++) {
++ 				if (tmp_folder_name[i] == '/') sidebar_folder_depth++;
++ 			}   
++ 			if (sidebar_folder_depth > 0) {
++ 				sidebar_folder_name = malloc(strlen(basename(tmp->path)) + sidebar_folder_depth + 1);
++ 				for (i=0; i < sidebar_folder_depth; i++)
++ 					sidebar_folder_name[i]=' ';
++ 				sidebar_folder_name[i]=0;
++ 				strncat(sidebar_folder_name, basename(tmp->path), strlen(basename(tmp->path)) + sidebar_folder_depth);
++ 			}
++ 		}
++ 		printw( "%.*s", SidebarWidth - delim_len + 1,
++ 			make_sidebar_entry(sidebar_folder_name, tmp->msgcount,
++ 			tmp->msg_unread, tmp->msg_flagged));
++ 		if (sidebar_folder_depth > 0)
++ 		        free(sidebar_folder_name);
++ 		lines++;
++ 	}
++ 	SETCOLOR(MT_COLOR_NORMAL);
++ 	for ( ; lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) {
++ 		int i = 0;
++ 		move( lines, 0 );
++ 		for ( ; i < SidebarWidth - delim_len; i++ )
++ 			addch(' ');
++ 	}
++ 	return 0;
++ }
++ 
++ 
++ void set_buffystats(CONTEXT* Context)
++ {
++         BUFFY *tmp = Incoming;
++         while(tmp) {
++                 if(Context && !strcmp(tmp->path, Context->path)) {
++ 			tmp->msg_unread = Context->unread;
++ 			tmp->msgcount = Context->msgcount;
++                         break;
++                 }
++                 tmp = tmp->next;
++         }
++ }
++ 
++ void scroll_sidebar(int op, int menu)
++ {
++         if(!SidebarWidth) return;
++         if(!CurBuffy) return;
++ 
++ 	switch (op) {
++ 		case OP_SIDEBAR_NEXT:
++ 			if ( CurBuffy->next == NULL ) return;
++ 			CurBuffy = CurBuffy->next;
++ 			break;
++ 		case OP_SIDEBAR_PREV:
++ 			if ( CurBuffy->prev == NULL ) return;
++ 			CurBuffy = CurBuffy->prev;
++ 			break;
++ 		case OP_SIDEBAR_SCROLL_UP:
++ 			CurBuffy = TopBuffy;
++ 			if ( CurBuffy != Incoming ) {
++ 				calc_boundaries(menu);
++ 				CurBuffy = CurBuffy->prev;
++ 			}
++ 			break;
++ 		case OP_SIDEBAR_SCROLL_DOWN:
++ 			CurBuffy = BottomBuffy;
++ 			if ( CurBuffy->next ) {
++ 				calc_boundaries(menu);
++ 				CurBuffy = CurBuffy->next;
++ 			}
++ 			break;
++ 		default:
++ 			return;
++ 	}
++ 	calc_boundaries(menu);
++ 	draw_sidebar(menu);
++ }
++ 
+*** mutt-1.5.20-orig/sidebar.h	1969-12-31 18:00:00.000000000 -0600
+--- mutt-1.5.20-patched/sidebar.h	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 0 ****
+--- 1,36 ----
++ /*
++  * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
++  * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
++  * 
++  *     This program is free software; you can redistribute it and/or modify
++  *     it under the terms of the GNU General Public License as published by
++  *     the Free Software Foundation; either version 2 of the License, or
++  *     (at your option) any later version.
++  * 
++  *     This program is distributed in the hope that it will be useful,
++  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
++  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++  *     GNU General Public License for more details.
++  * 
++  *     You should have received a copy of the GNU General Public License
++  *     along with this program; if not, write to the Free Software
++  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
++  */ 
++ 
++ #ifndef SIDEBAR_H
++ #define SIDEBAR_H
++ 
++ struct MBOX_LIST {
++ 	char *path;
++ 	int msgcount;
++ 	int new;
++ } MBLIST;
++ 
++ /* parameter is whether or not to go to the status line */
++ /* used for omitting the last | that covers up the status bar in the index */
++ int draw_sidebar(int);
++ void scroll_sidebar(int, int);
++ void set_curbuffy(char*);
++ void set_buffystats(CONTEXT*);
++ 
++ #endif /* SIDEBAR_H */
+*** mutt-1.5.20-orig/doc/Muttrc	2009-06-14 13:53:24.000000000 -0500
+--- mutt-1.5.20-patched/doc/Muttrc	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 657,662 ****
+--- 657,682 ----
+  # $crypt_autosign, $crypt_replysign and $smime_is_default.
+  # 
+  # 
++ # set sidebar_visible=no
++ #
++ # Name: sidebar_visible
++ # Type: boolean
++ # Default: no
++ # 
++ # 
++ # This specifies whether or not to show sidebar (left-side list of folders).
++ # 
++ # 
++ # set sidebar_width=0
++ #
++ # Name: sidebar_width
++ # Type: number
++ # Default: 0
++ # 
++ # 
++ # The width of the sidebar.
++ # 
++ # 
+  # set crypt_autosign=no
+  #
+  # Name: crypt_autosign
+*** mutt-1.5.20-orig/imap/imap.c	2009-06-14 12:19:16.000000000 -0500
+--- mutt-1.5.20-patched/imap/imap.c	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 1521,1527 ****
+  
+      imap_munge_mbox_name (munged, sizeof (munged), name);
+      snprintf (command, sizeof (command),
+! 	      "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT)", munged);
+  
+      if (imap_exec (idata, command, IMAP_CMD_QUEUE) < 0)
+      {
+--- 1521,1527 ----
+  
+      imap_munge_mbox_name (munged, sizeof (munged), name);
+      snprintf (command, sizeof (command),
+! 	      "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT MESSAGES)", munged);
+  
+      if (imap_exec (idata, command, IMAP_CMD_QUEUE) < 0)
+      {
+*** mutt-1.5.20-orig/imap/command.c	2009-01-05 20:58:31.000000000 -0600
+--- mutt-1.5.20-patched/imap/command.c	2009-06-19 22:07:04.000000000 -0500
+***************
+*** 1009,1014 ****
+--- 1009,1021 ----
+  	     opened */
+  	  status->uidnext = oldun;
+  
++         /* Added to make the sidebar show the correct numbers */
++         if (status->messages)
++         {
++           inc->msgcount = status->messages;
++           inc->msg_unread = status->unseen;
++         }
++ 
+          FREE (&value);
+          return;
+        }
+--- orig/compose.c.orig	2010-09-18 13:23:18.000000000 +0200
++++ new/compose.c	2010-09-18 14:01:09.000000000 +0200
+@@ -80,7 +80,7 @@
+ 
+ #define HDR_XOFFSET 14
+ #define TITLE_FMT "%14s" /* Used for Prompts, which are ASCII */
+-#define W (COLS - HDR_XOFFSET)
++#define W (COLS - HDR_XOFFSET - SidebarWidth)
+ 
+ static char *Prompts[] =
+ {
+@@ -143,7 +143,7 @@
+ {
+   int off = 0;
+ 
+-  mvprintw (HDR_CRYPT, 0, TITLE_FMT, "Security: ");
++  mvprintw (HDR_CRYPT, SidebarWidth, TITLE_FMT, "Security: ");
+ 
+   if ((WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME)) == 0)
+   {
+@@ -175,7 +175,7 @@
+   }
+ 
+   clrtoeol ();
+-  move (HDR_CRYPTINFO, 0);
++  move (HDR_CRYPTINFO, SidebarWidth);
+   clrtoeol ();
+ 
+   if ((WithCrypto & APPLICATION_PGP)
+@@ -195,7 +195,7 @@
+       && (msg->security & ENCRYPT)
+       && SmimeCryptAlg
+       && *SmimeCryptAlg) {
+-      mvprintw (HDR_CRYPTINFO, 40, "%s%s", _("Encrypt with: "),
++      mvprintw (HDR_CRYPTINFO, SidebarWidth + 40, "%s%s", _("Encrypt with: "),
+ 		NONULL(SmimeCryptAlg));
+       off = 20;
+   }
+@@ -224,7 +224,7 @@
+     if (t && t[0] == '0' && t[1] == '\0')
+       t = "<random>";
+     
+-    if (c + mutt_strlen (t) + 2 >= COLS)
++    if (c + mutt_strlen (t) + 2 >= COLS - SidebarWidth)
+       break;
+ 
+     addstr (NONULL(t));
+@@ -276,7 +276,7 @@
+ 
+   buf[0] = 0;
+   rfc822_write_address (buf, sizeof (buf), addr, 1);
+-  mvprintw (line, 0, TITLE_FMT, Prompts[line - 1]);
++  mvprintw (line, SidebarWidth, TITLE_FMT, Prompts[line - 1]);
+   mutt_paddstr (W, buf);
+ }
+ 
+@@ -294,21 +294,21 @@
+   }
+   else
+   {
+-    mvprintw (HDR_TO, 0, TITLE_FMT , Prompts[HDR_NEWSGROUPS - 1]);
++    mvprintw (HDR_TO, SidebarWidth, TITLE_FMT , Prompts[HDR_NEWSGROUPS - 1]);
+     mutt_paddstr (W, NONULL (msg->env->newsgroups));
+-    mvprintw (HDR_CC, 0, TITLE_FMT , Prompts[HDR_FOLLOWUPTO - 1]);
++    mvprintw (HDR_CC, SidebarWidth, TITLE_FMT , Prompts[HDR_FOLLOWUPTO - 1]);
+     mutt_paddstr (W, NONULL (msg->env->followup_to));
+     if (option (OPTXCOMMENTTO))
+     {
+-      mvprintw (HDR_BCC, 0, TITLE_FMT , Prompts[HDR_XCOMMENTTO - 1]);
++      mvprintw (HDR_BCC, SidebarWidth, TITLE_FMT , Prompts[HDR_XCOMMENTTO - 1]);
+       mutt_paddstr (W, NONULL (msg->env->x_comment_to));
+     }
+   }
+ #endif
+-  mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
++  mvprintw (HDR_SUBJECT, SidebarWidth, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
+   mutt_paddstr (W, NONULL (msg->env->subject));
+   draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
+-  mvprintw (HDR_FCC, 0, TITLE_FMT, Prompts[HDR_FCC - 1]);
++  mvprintw (HDR_FCC, SidebarWidth, TITLE_FMT, Prompts[HDR_FCC - 1]);
+   mutt_paddstr (W, fcc);
+ 
+   if (WithCrypto)
+@@ -319,7 +319,7 @@
+ #endif
+ 
+   SETCOLOR (MT_COLOR_STATUS);
+-  mvaddstr (HDR_ATTACH - 1, 0, _("-- Attachments"));
++  mvaddstr (HDR_ATTACH - 1, SidebarWidth, _("-- Attachments"));
+   BKGDSET (MT_COLOR_STATUS);
+   clrtoeol ();
+ 
+@@ -357,7 +357,7 @@
+   /* redraw the expanded list so the user can see the result */
+   buf[0] = 0;
+   rfc822_write_address (buf, sizeof (buf), *addr, 1);
+-  move (line, HDR_XOFFSET);
++  move (line, HDR_XOFFSET+SidebarWidth);
+   mutt_paddstr (W, buf);
+   
+   return 0;
+@@ -686,7 +686,7 @@
+ 	if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0)
+ 	{
+ 	  mutt_str_replace (&msg->env->subject, buf);
+-	  move (HDR_SUBJECT, HDR_XOFFSET);
++	  move (HDR_SUBJECT, HDR_XOFFSET + SidebarWidth);
+ 	  clrtoeol ();
+ 	  if (msg->env->subject)
+ 	    mutt_paddstr (W, msg->env->subject);
+@@ -703,7 +703,7 @@
+ 	{
+ 	  strfcpy (fcc, buf, fcclen);
+ 	  mutt_pretty_mailbox (fcc, fcclen);
+-	  move (HDR_FCC, HDR_XOFFSET);
++	  move (HDR_FCC, HDR_XOFFSET + SidebarWidth);
+ 	  mutt_paddstr (W, fcc);
+ 	  fccSet = 1;
diff -urN mutt-devel/files/extra-patch-signature-menu mutt-devel-1.5.21-ja.2/files/extra-patch-signature-menu
--- mutt-devel/files/extra-patch-signature-menu	1970-01-01 09:00:00.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/extra-patch-signature-menu	2012-07-22 18:15:04.000000000 +0900
@@ -0,0 +1,729 @@
+--- mutt-1.5.11/PATCHES Dec 2002 17:44:54 -0000	3.6
++++ mutt-1.5.11/PATCHES Feb 2004 13:19:42 -0000
+@@ -0,0 +1 @@
++patch-1.5.11.cd.signatures_menu.2.1
+--- mutt-1.5.11/Makefile.am.orig	Thu Aug 11 23:27:28 2005
++++ mutt-1.5.11/Makefile.am	Sat Mar 11 21:47:55 2006
+@@ -25,7 +25,7 @@
+ 	main.c mbox.c menu.c mh.c mx.c pager.c parse.c pattern.c \
+ 	postpone.c query.c recvattach.c recvcmd.c \
+ 	rfc822.c rfc1524.c rfc2047.c rfc2231.c \
+-	score.c send.c sendlib.c signal.c sort.c \
++	score.c send.c sendlib.c signal.c signature.c sort.c \
+ 	status.c system.c thread.c charset.c history.c lib.c \
+ 	muttlib.c editmsg.c utf8.c mbyte.c wcwidth.c \
+ 	url.c ascii.c mutt_idna.c crypt-mod.c crypt-mod.h
+--- mutt-1.5.12/Makefile.in.orig	Mon Jul 17 16:29:15 2006
++++ mutt-1.5.12/Makefile.in	Mon Jul 17 16:30:26 2006
+@@ -90,7 +90,7 @@
+ 	query.$(OBJEXT) recvattach.$(OBJEXT) recvcmd.$(OBJEXT) \
+ 	rfc822.$(OBJEXT) rfc1524.$(OBJEXT) rfc2047.$(OBJEXT) \
+ 	rfc2231.$(OBJEXT) score.$(OBJEXT) send.$(OBJEXT) \
+-	sendlib.$(OBJEXT) signal.$(OBJEXT) sort.$(OBJEXT) \
++	sendlib.$(OBJEXT) signal.$(OBJEXT) signature.$(OBJEXT) sort.$(OBJEXT) \
+ 	status.$(OBJEXT) system.$(OBJEXT) thread.$(OBJEXT) \
+ 	charset.$(OBJEXT) history.$(OBJEXT) lib.$(OBJEXT) \
+ 	muttlib.$(OBJEXT) editmsg.$(OBJEXT) utf8.$(OBJEXT) \
+@@ -309,7 +309,7 @@
+ 	main.c mbox.c menu.c mh.c mx.c pager.c parse.c pattern.c \
+ 	postpone.c query.c recvattach.c recvcmd.c \
+ 	rfc822.c rfc1524.c rfc2047.c rfc2231.c \
+-	score.c send.c sendlib.c signal.c sort.c \
++	score.c send.c sendlib.c signal.c signature.c sort.c \
+ 	status.c system.c thread.c charset.c history.c lib.c \
+ 	muttlib.c editmsg.c utf8.c mbyte.c wcwidth.c \
+ 	url.c ascii.c mutt_idna.c crypt-mod.c crypt-mod.h
+--- mutt-1.5.11/OPS.orig	Sun Jul 24 18:56:42 2005
++++ mutt-1.5.11/OPS	Sat Mar 11 21:47:55 2006
+@@ -38,6 +38,7 @@
+ OP_COMPOSE_POSTPONE_MESSAGE "save this message to send later"
+ OP_COMPOSE_RENAME_FILE "rename/move an attached file"
+ OP_COMPOSE_SEND_MESSAGE "send the message"
++OP_COMPOSE_SIG "choose a signature"
+ OP_COMPOSE_TOGGLE_DISPOSITION "toggle disposition between inline/attachment"
+ OP_COMPOSE_TOGGLE_UNLINK "toggle whether to delete file after sending it"
+ OP_COMPOSE_UPDATE_ENCODING "update an attachment's encoding info"
+@@ -131,6 +132,7 @@
+ OP_NEXT_ENTRY "move to the next entry"
+ OP_NEXT_LINE "scroll down one line"
+ OP_NEXT_PAGE "move to the next page"
++OP_NEXT_SIG "move to the next signature"
+ OP_PAGER_BOTTOM "jump to the bottom of the message"
+ OP_PAGER_HIDE_QUOTED "toggle display of quoted text"
+ OP_PAGER_SKIP_QUOTED "skip beyond quoted text"
+@@ -139,10 +141,12 @@
+ OP_PREV_ENTRY "move to the previous entry"
+ OP_PREV_LINE "scroll up one line"
+ OP_PREV_PAGE "move to the previous page"
++OP_PREV_SIG "move to the previous signature"
+ OP_PRINT "print the current entry"
+ OP_QUERY "query external program for addresses"
+ OP_QUERY_APPEND "append new query results to current results"
+ OP_QUIT "save changes to mailbox and quit"
++OP_RANDOM_SIG "pick a signature at random"
+ OP_RECALL_MESSAGE "recall a postponed message"
+ OP_REDRAW "clear and redraw the screen"
+ OP_REFORMAT_WINCH "{internal}"
+@@ -156,6 +160,7 @@
+ OP_SEARCH_OPPOSITE "search for next match in opposite direction"
+ OP_SEARCH_TOGGLE "toggle search pattern coloring"
+ OP_SHELL_ESCAPE "invoke a command in a subshell"
++OP_SIG_SEARCH "search signatures matching a pattern"
+ OP_SORT "sort messages"
+ OP_SORT_REVERSE "sort messages in reverse order"
+ OP_TAG "tag the current entry"
+--- mutt-1.5.11/compose.c.orig	Thu Aug 11 21:37:23 2005
++++ mutt-1.5.11/compose.c	Sat Mar 11 21:47:55 2006
+@@ -1128,6 +1128,12 @@
+         /* no send2hook, since this doesn't modify the message */
+ 	break;
+ 
++      case OP_COMPOSE_SIG:
++	mutt_signature(msg->content->filename);
++	MAYBE_REDRAW (menu->redraw);
++	mutt_update_encoding (msg->content);
++	break;
++
+       case OP_PIPE:
+       case OP_FILTER:
+         CHECK_COUNT;
+--- mutt-1.5.12/doc/manual.xml.head.orig	Mon Jul 17 16:21:01 2006
++++ mutt-1.5.12/doc/manual.xml.head	Mon Jul 17 16:24:46 2006
+@@ -999,6 +999,7 @@
+ <row><entry>c</entry><entry>edit-cc</entry><entry>edit the Cc field</entry></row>
+ <row><entry>b</entry><entry>edit-bcc</entry><entry>edit the Bcc field</entry></row>
+ <row><entry>y</entry><entry>send-message</entry><entry>send the message</entry></row>
++<row><entry>ESC s</entry><entry>signature-menu</entry><entry>select a signature and append it to your mail</entry></row>
+ <row><entry>s</entry><entry>edit-subject</entry><entry>edit the Subject</entry></row>
+ <row><entry>S</entry><entry>smime-menu</entry><entry>select S/MIME options</entry></row>
+ <row><entry>f</entry><entry>edit-fcc</entry><entry>specify an ``Fcc'' mailbox</entry></row>
+--- mutt-1.5.11/functions.h.orig	Sun Jul 24 18:56:42 2005
++++ mutt-1.5.11/functions.h	Sat Mar 11 21:48:05 2006
+@@ -311,6 +311,7 @@
+   { "view-attach",	OP_VIEW_ATTACH,			M_ENTER_S },
+   { "send-message",	OP_COMPOSE_SEND_MESSAGE,	"y" },
+   { "pipe-entry",	OP_PIPE,			"|" },
++  { "signature-menu",	OP_COMPOSE_SIG,			"\033s" },
+ 
+   { "attach-key",	OP_COMPOSE_ATTACH_KEY,		"\033k" },
+   { "pgp-menu",		OP_COMPOSE_PGP_MENU,		"p" 	},
+@@ -368,6 +369,19 @@
+   { "mail",		OP_MAIL,		"m" },
+   { "query",		OP_QUERY,		"Q" },
+   { "query-append",	OP_QUERY_APPEND,	"A" },
++  { NULL,		0,			NULL }
++};
++
++/* Signature Menu */
++struct binding_t OpSig[] = {
++  { "next-sig",		OP_NEXT_SIG,		"j" },
++  { "previous-sig",	OP_PREV_SIG,		"k" },
++  { "random-sig",	OP_RANDOM_SIG,		"r" },
++  { NULL,		0,			NULL }
++};
++
++struct binding_t OpSigDir[] = {
++  { "search-sig",	OP_SIG_SEARCH,		"/" },
+   { NULL,		0,			NULL }
+ };
+ 
+--- mutt-1.5.11/globals.h.orig	Thu Sep 15 16:19:54 2005
++++ mutt-1.5.11/globals.h	Sat Mar 11 21:48:05 2006
+@@ -109,6 +109,7 @@
+ WHERE char *Sendmail;
+ WHERE char *Shell;
+ WHERE char *Signature;
++WHERE char *SigDirectory;
+ WHERE char *SimpleSearch;
+ WHERE char *Spoolfile;
+ WHERE char *SpamSep;
+--- mutt-1.5.11/init.h.orig	Thu Sep 15 16:19:54 2005
++++ mutt-1.5.11/init.h	Sat Mar 11 21:48:05 2006
+@@ -2457,6 +2457,14 @@
+   ** assumed that filename is a shell command and input should be read from
+   ** its stdout.
+   */
++  { "signatures_directory",	DT_PATH, R_NONE, UL &SigDirectory, UL "" },
++  /*
++  ** .pp
++  ** Specifies the path where your signatures are located. In the files of
++  ** this directory, the signatures are separated by blank lines and/or
++  ** sig_dashes (``-- '').
++  ** You can choose between these signatures from the compose menu.
++  */
+   { "simple_search",	DT_STR,	 R_NONE, UL &SimpleSearch, UL "~f %s | ~s %s" },
+   /*
+   ** .pp
+--- mutt-1.5.11/keymap.c.orig	Wed Sep  7 10:19:43 2005
++++ mutt-1.5.11/keymap.c	Sat Mar 11 21:48:05 2006
+@@ -55,6 +55,8 @@
+   
+ 
+  { "query",	MENU_QUERY },
++ { "signature",	MENU_SIG },
++ { "sig_directory",	MENU_SIG_DIR },
+  { "generic",	MENU_GENERIC },
+  { NULL,	0 }
+ };
+@@ -560,6 +562,8 @@
+   create_bindings (OpPost, MENU_POST);
+   create_bindings (OpQuery, MENU_QUERY);
+   create_bindings (OpAlias, MENU_ALIAS);
++  create_bindings (OpSig, MENU_SIG);
++  create_bindings (OpSigDir, MENU_SIG_DIR);
+ 
+ 
+   if ((WithCrypto & APPLICATION_PGP))
+@@ -658,6 +662,9 @@
+   km_bindkey ("<enter>", MENU_ATTACH, OP_VIEW_ATTACH);
+   km_bindkey ("<enter>", MENU_COMPOSE, OP_VIEW_ATTACH);
+ 
++  km_bindkey ("<up>", MENU_SIG, OP_PREV_SIG);
++  km_bindkey ("<down>", MENU_SIG, OP_NEXT_SIG);
++
+   /* edit-to (default "t") hides generic tag-entry in Compose menu
+      This will bind tag-entry to  "T" in the Compose menu */
+   km_bindkey ("T", MENU_COMPOSE, OP_TAG);
+@@ -793,6 +800,10 @@
+       return OpEditor;
+     case MENU_QUERY:
+       return OpQuery;
++    case MENU_SIG:
++      return OpSig;
++    case MENU_SIG_DIR:
++      return OpSigDir;
+ 
+     case MENU_PGP:
+       return (WithCrypto & APPLICATION_PGP)? OpPgp:NULL;
+--- mutt-1.5.11/keymap.h.orig	Thu Jun 17 22:33:04 2004
++++ mutt-1.5.11/keymap.h	Sat Mar 11 21:48:05 2006
+@@ -62,6 +62,8 @@
+   MENU_PAGER,
+   MENU_POST,
+   MENU_QUERY,
++  MENU_SIG,
++  MENU_SIG_DIR,
+ 
+   
+   MENU_PGP,
+@@ -108,6 +110,8 @@
+ extern struct binding_t OpEditor[];
+ extern struct binding_t OpQuery[];
+ extern struct binding_t OpAlias[];
++extern struct binding_t OpSig[];
++extern struct binding_t OpSigDir[];
+ 
+ extern struct binding_t OpPgp[];
+ 
+--- mutt-1.5.11/protos.h.orig	Wed Sep  7 10:19:43 2005
++++ mutt-1.5.11/protos.h	Sat Mar 11 21:48:05 2006
+@@ -242,6 +242,7 @@
+ void mutt_shell_escape (void);
+ void mutt_show_error (void);
+ void mutt_signal_init (void);
++void mutt_signature (char *);
+ void mutt_stamp_attachment (BODY *a);
+ void mutt_tabs_to_spaces (char *);
+ void mutt_tag_set_flag (int, int);
+--- mutt-1.5.11/signature.c.orig	Sat Mar 11 21:58:38 2006
++++ mutt-1.5.11/signature.c	Sat Mar 11 22:07:31 2006
+@@ -0,0 +1,499 @@
++/*
++ * Copyright (C) 2001 Cedric Duval <cedricduval@free.fr>
++ * 
++ *     This program is free software; you can redistribute it and/or modify
++ *     it under the terms of the GNU General Public License as published by
++ *     the Free Software Foundation; either version 2 of the License, or
++ *     (at your option) any later version.
++ * 
++ *     This program is distributed in the hope that it will be useful,
++ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
++ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ *     GNU General Public License for more details.
++ * 
++ *     You should have received a copy of the GNU General Public License
++ *     along with this program; if not, write to the Free Software
++ *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
++ */
++
++#if HAVE_CONFIG_H
++# include "config.h"
++#endif
++
++#include "mutt.h"
++#include "mutt_menu.h"
++#include "mapping.h"
++#include "mutt_curses.h"
++
++#include <stdio.h>
++#include <string.h>
++#include <stdlib.h>
++#include <dirent.h>
++#include <sys/stat.h>
++
++#define SIG_DISPLAY_LINES 4
++#define SEPARATOR(x) ((*x == '\n') || (mutt_strcmp (x, "-- \n") == 0))
++#define SIG_ADD_LINE(x,y) mutt_add_list (x, strtok (y, "\n"))
++
++typedef struct sig_list
++{
++  struct sig_list *next;
++  LIST *sig;
++} SIG_LIST;
++
++typedef struct sig_dir
++{
++  struct sig_dir *next;
++  char *name;
++} SIG_DIR;
++
++typedef LIST * ENTRY;
++
++typedef struct entry_dir
++{
++  int tagged;
++  SIG_DIR *data;
++} ENTRY_DIR;
++
++static struct mapping_t SigHelp[] = {
++  { N_("Exit"),   OP_EXIT },
++  { N_("Search"), OP_SEARCH },
++  { N_("Random"), OP_RANDOM_SIG },
++  { N_("Help"),   OP_HELP },
++  { NULL }
++};
++
++static struct mapping_t SigDirHelp[] = {
++  { N_("Exit"),   OP_EXIT },
++  { N_("Search signature"), OP_SIG_SEARCH },
++  { N_("Help"),   OP_HELP },
++  { NULL }
++};
++
++void menu_next_entry (MUTTMENU *menu);
++void menu_prev_entry (MUTTMENU *menu);
++
++
++static int sig_match (LIST *s, regex_t *re)
++{
++  while (s)
++  {
++    if (regexec (re, s->data, (size_t)0, NULL, (int)0) == 0)
++      return 1;
++    s = s->next;
++  }
++  return 0;
++}
++
++static void read_sig_file (char *name, SIG_LIST **begin, regex_t *re)
++{
++  FILE *fp;
++  char buf[STRING];
++  LIST *sig = NULL;
++  SIG_LIST *first, *cur;
++  int append = 0;
++
++  if (!(fp = safe_fopen (name, "r")))
++  {
++    mutt_error (_("Can't open signature file %s"), name);
++    return;
++  }
++
++  for (first = *begin; first && first->next; first = first->next, append++)
++    ; /* append results to an existing list */
++  cur = first;
++
++  while (fgets (buf, sizeof (buf), fp))
++  {
++    if (buf[0] && !SEPARATOR (buf))
++    {
++      sig = SIG_ADD_LINE (NULL, buf);
++
++      while (fgets (buf, sizeof (buf), fp) && buf[0] && !SEPARATOR (buf))
++	SIG_ADD_LINE (sig, buf);
++
++      if (re && !sig_match (sig, re))
++	mutt_free_list (&sig); /* previous sig didn't match the regexp */
++      else
++      {
++	/* add signature */
++	if (first == NULL)
++	  first = cur = (SIG_LIST *) safe_calloc (1, sizeof (SIG_LIST));
++	else
++	{
++	  cur->next = (SIG_LIST *) safe_calloc (1, sizeof (SIG_LIST));
++	  cur = cur->next;
++	}
++
++	cur->sig = sig;
++	cur->next = NULL;
++      }
++    }
++  }
++
++  if (!append)
++    *begin = first;
++
++  safe_fclose (&fp);
++}
++
++static void sig_make_entry (char *s, size_t slen, MUTTMENU *menu, int num)
++{
++  ENTRY *table = (ENTRY *) menu->data;
++
++  snprintf (s, slen, "%3d %s",
++	    num + 1,
++	    table[num]->data);
++}
++
++static int sig_menu_search (MUTTMENU *menu, regex_t *re, int num)
++{
++  return (sig_match (((ENTRY *)menu->data)[num], re) ? 0 : REG_NOMATCH);
++}
++
++static void draw_sig_frame (LIST *s)
++{
++  int i;
++
++  for (i = 1; i <= SIG_DISPLAY_LINES; i++)
++  {
++    if (s)
++    {
++      mvaddstr (i, 0, s->data);
++      s = s->next;
++    }
++    else
++      move (i, 0);
++
++    clrtoeol ();
++  }
++
++  SETCOLOR (MT_COLOR_STATUS);
++  mvaddstr (SIG_DISPLAY_LINES + 1, 0, _("-- Signature"));
++  BKGDSET (MT_COLOR_STATUS);
++  clrtoeol ();
++
++  BKGDSET (MT_COLOR_NORMAL);
++  SETCOLOR (MT_COLOR_NORMAL);
++}
++
++static void free_sig_list (SIG_LIST **sigs)
++{
++  SIG_LIST *cur;
++
++  while (*sigs)
++  {
++    cur = *sigs;
++    *sigs = (*sigs)->next;
++    mutt_free_list (&cur->sig);
++    safe_free ((void **)&cur);
++  }
++}
++
++static void append_signature (char *msg_file, LIST *s)
++{
++  FILE *fp;
++
++  if ((fp = safe_fopen (msg_file, "a")) == 0)
++    mutt_perror (msg_file);
++  else
++  {
++    if (option (OPTSIGDASHES))
++      fputs ("\n-- \n", fp);
++
++    for (; s; s = s->next)
++      fprintf (fp, "%s\n", s->data);
++
++    mutt_message (_("Signature appended to your mail"));
++    safe_fclose (&fp);
++  }
++}
++
++static LIST *sig_list_menu (char *file, SIG_LIST *list)
++{
++  LIST *result = NULL;
++  SIG_LIST *sigl;
++  MUTTMENU *menu;
++  ENTRY *SigTable;
++  char helpstr[SHORT_STRING], title[SHORT_STRING];
++  int i, done = 0;
++
++  snprintf (title, sizeof (title), _("Signature : %s"), file);
++
++  menu = mutt_new_menu ();
++  menu->make_entry = sig_make_entry;
++  menu->tag = NULL;
++  menu->search = sig_menu_search;
++  menu->menu = MENU_SIG;
++  menu->title = title;
++  menu->help = mutt_compile_help (helpstr, sizeof (helpstr),
++				  MENU_SIG, SigHelp);
++  menu->offset = SIG_DISPLAY_LINES + 2;
++  menu->pagelen = LINES - SIG_DISPLAY_LINES - 4;
++  
++  for (sigl = list; sigl; sigl = sigl->next)
++    menu->max++;
++
++  menu->data = SigTable = (ENTRY *) safe_calloc (menu->max, sizeof (ENTRY));
++
++  for (i = 0, sigl = list; sigl; i++, sigl = sigl->next)
++    SigTable[i] = sigl->sig;
++
++  while (!done)
++  {
++    switch (mutt_menuLoop (menu))
++    {
++      case OP_GENERIC_SELECT_ENTRY:
++        result = SigTable[menu->current];
++	done = 1;
++	break;
++
++      case OP_PREV_SIG:
++	menu_prev_entry (menu);
++	draw_sig_frame (SigTable[menu->current]);
++	break;
++
++      case OP_NEXT_SIG:
++	menu_next_entry (menu);
++	draw_sig_frame (SigTable[menu->current]);
++	break;
++
++      case OP_REDRAW:
++	menu->offset = SIG_DISPLAY_LINES + 2;
++	menu->pagelen = LINES - SIG_DISPLAY_LINES - 4;
++	draw_sig_frame (SigTable[menu->current]);
++	break;
++
++      case OP_RANDOM_SIG:
++	menu->current = LRAND () % menu->max;
++	draw_sig_frame (SigTable[menu->current]);
++	menu->redraw |= REDRAW_MOTION;
++	break;
++
++      case OP_EXIT:
++	set_option (OPTNEEDREDRAW);
++        done = 1;
++        break;
++    }
++  }
++  
++  mutt_menuDestroy (&menu);
++  safe_free ((void **)&SigTable);
++  return result;
++}
++
++static SIG_LIST *sig_search_filter (MUTTMENU *menu, char *path)
++{
++  regex_t re;
++  char buf[STRING];
++  SIG_LIST *result = NULL;
++  int i;
++
++  snprintf (buf, sizeof(buf), menu->searchBuf ? menu->searchBuf : "");
++  if (mutt_get_field (_("Search for: "), buf,
++		      sizeof (buf), M_CLEAR) != 0 || !buf[0])
++    return (NULL);
++  mutt_str_replace (&menu->searchBuf, buf);
++
++  if ((i = regcomp (&re, menu->searchBuf, REG_NOSUB | REG_EXTENDED | REG_WORDS
++		    | mutt_which_case (menu->searchBuf))) != 0)
++  {
++    regerror (i, &re, buf, sizeof (buf));
++    regfree (&re);
++    mutt_error ("%s", buf);
++    return (NULL);
++  }
++
++  /* building list of sigs matching the regexp */
++  for (i = 0; i < menu->max; i++)
++  {
++    /* search in every file if none is tagged */
++    if (((ENTRY_DIR *) menu->data)[i].tagged || (menu->tagged == 0))
++    {
++      snprintf (buf, sizeof (buf), "%s/%s", path,
++		((ENTRY_DIR *) menu->data)[i].data->name);
++      read_sig_file (buf, &result, &re);
++    }
++  }
++
++  regfree (&re);
++  if (!result)
++    mutt_error (_("Not found."));
++
++  return (result);
++}
++
++/* returns the list of files in this directory */
++static SIG_DIR *sig_directory (char *path)
++{
++  DIR *dp;
++  struct dirent *de;
++  struct stat s;
++  SIG_DIR *first = NULL, *cur = NULL;
++  char file[_POSIX_PATH_MAX + SHORT_STRING];
++
++  if ((dp = opendir (path)) == NULL)
++  {
++    mutt_perror (path);
++    return (NULL);
++  }
++  
++  while ((de = readdir (dp)))
++  {
++    if ((de->d_name)[0] == '.') /* no hidden files */
++      continue;
++
++    snprintf (file, sizeof (file), "%s/%s", path, de->d_name);
++    if (lstat (file, &s) == -1)
++      continue;
++
++    if ((!S_ISREG (s.st_mode)) && (!S_ISLNK (s.st_mode)))
++      continue;
++
++    if (first == NULL)
++      cur = first = safe_calloc (1, sizeof (SIG_DIR));
++    else
++    {
++      cur->next = safe_calloc (1, sizeof (SIG_DIR));
++      cur = cur->next;
++    }
++    cur->name = safe_strdup (de->d_name);
++    cur->next = NULL;
++  }
++  closedir (dp);
++  return first;
++}
++
++static void sig_dir_make_entry (char *s, size_t slen, MUTTMENU *menu, int num)
++{
++  ENTRY_DIR *table = (ENTRY_DIR *) menu->data;
++
++  snprintf (s, slen, "%c %3d - %s",
++	    table[num].tagged ? '*' : ' ',
++	    num + 1,
++	    table[num].data->name);
++}
++
++static int sig_dir_tag (MUTTMENU *menu, int n, int m)
++{
++  ENTRY_DIR *cur = &((ENTRY_DIR *) menu->data)[n];
++  int ot = cur->tagged;
++  
++  cur->tagged = m >= 0 ? m : !cur->tagged;
++  return cur->tagged - ot;
++
++}
++
++static int sig_dir_sort (const void *a, const void *b)
++{
++  ENTRY_DIR *pa = (ENTRY_DIR *) a;
++  ENTRY_DIR *pb = (ENTRY_DIR *) b;
++
++  return (mutt_strcmp (pa->data->name, pb->data->name));
++}
++
++static int sig_dir_menu (char *path, char *msg_file)
++{
++  MUTTMENU *menu;
++  SIG_LIST *sigl;
++  LIST *result = NULL;
++  ENTRY_DIR *FileTable;
++  SIG_DIR *list, *files;
++  char buf[STRING], helpstr[SHORT_STRING], title[SHORT_STRING];
++  int i, done = 0;
++
++  if ((list = sig_directory (path)) == NULL)
++    return -1;
++
++  snprintf (title, sizeof (title), "Signature directory : %s", path);
++
++  menu = mutt_new_menu ();
++  menu->make_entry = sig_dir_make_entry;
++  menu->search = NULL; /* search within files with sig_search_filter() */
++  menu->tag = sig_dir_tag;
++  menu->menu = MENU_SIG_DIR;
++  menu->title = title;
++  menu->help = mutt_compile_help (helpstr, sizeof (helpstr),
++				  MENU_SIG_DIR, SigDirHelp);
++
++  for (files = list; files; files = files->next)
++    menu->max++;
++
++  menu->data = FileTable = (ENTRY_DIR *) safe_calloc (menu->max,
++						      sizeof (ENTRY_DIR));
++
++  for (i = 0, files = list; files; i++, files = files->next)
++    FileTable[i].data = files;
++
++  qsort (FileTable, menu->max, sizeof (ENTRY_DIR), sig_dir_sort);
++
++  while (!done)
++  {
++    switch (mutt_menuLoop (menu))
++    {
++      case OP_SIG_SEARCH:
++	sigl = sig_search_filter (menu, path);
++
++	if (sigl)
++	{
++	  if ((result = sig_list_menu (_("query results"), sigl)) != NULL)
++	  {
++	    append_signature (msg_file, result);
++	    done = 1;
++	  }
++
++	  MAYBE_REDRAW (menu->redraw);
++	  free_sig_list (&sigl);
++	}
++	break;
++
++      case OP_GENERIC_SELECT_ENTRY:
++	snprintf (buf, sizeof (buf), "%s/%s", path,
++		  FileTable[menu->current].data->name);
++	sigl = NULL;
++	read_sig_file (buf, &sigl, NULL);
++
++	if (sigl)
++	{
++	  if ((result = sig_list_menu (buf, sigl)) != NULL)
++	  {
++	    append_signature (msg_file, result);
++	    done = 1;
++	  }
++
++	  MAYBE_REDRAW (menu->redraw);
++	  free_sig_list (&sigl);
++      	}
++	break;
++
++      case OP_EXIT:
++        done = 1;
++        break;
++    }
++  }
++
++  while (list)
++  {
++    safe_free ((void **)&list->name);
++    files = list;
++    list = list->next;
++    safe_free ((void **)&files);
++  }
++  safe_free ((void **)&FileTable);
++  mutt_menuDestroy (&menu);
++  return 0;
++}
++
++void mutt_signature (char *msg_file)
++{
++  if (!SigDirectory)
++  {
++    mutt_error (_("variable 'signatures_directory' is unset"));
++    return;
++  }
++
++  if (sig_dir_menu (SigDirectory, msg_file) == -1)
++    mutt_error (_("%s: no files in this directory"), SigDirectory);
++  else
++    set_option (OPTNEEDREDRAW);
++}
diff -urN mutt-devel/files/extra-patch-smime-outlook mutt-devel-1.5.21-ja.2/files/extra-patch-smime-outlook
--- mutt-devel/files/extra-patch-smime-outlook	1970-01-01 09:00:00.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/extra-patch-smime-outlook	2012-07-22 18:15:04.000000000 +0900
@@ -0,0 +1,11 @@
+--- crypt.c.orig	Fri Mar  7 09:23:44 2003
++++ crypt.c	Fri Mar 21 00:06:48 2003
+@@ -440,7 +440,7 @@
+     {
+       len++;
+       if (!ascii_strcasecmp ((t+len), "p7m"))
+-#if 0
++#if 1
+        return SMIMEENCRYPT;
+ #else
+       /* Not sure if this is the correct thing to do, but 
diff -urN mutt-devel/files/extra-patch-trash-purge mutt-devel-1.5.21-ja.2/files/extra-patch-trash-purge
--- mutt-devel/files/extra-patch-trash-purge	1970-01-01 09:00:00.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/extra-patch-trash-purge	2012-07-22 18:15:04.000000000 +0900
@@ -0,0 +1,403 @@
+diff -pruN -x'*.orig' mutt-1.5.20/OPS mutt-1.5.20-trash/OPS
+--- mutt-1.5.20/OPS	2009-05-13 01:01:13.000000000 -0400
++++ mutt-1.5.20-trash/OPS	2009-07-23 09:44:40.000000000 -0400
+@@ -141,6 +141,7 @@ OP_PREV_ENTRY "move to the previous entr
+ OP_PREV_LINE "scroll up one line"
+ OP_PREV_PAGE "move to the previous page"
+ OP_PRINT "print the current entry"
++OP_PURGE_MESSAGE "really delete the current entry, bypassing the trash folder"
+ OP_QUERY "query external program for addresses"
+ OP_QUERY_APPEND "append new query results to current results"
+ OP_QUIT "save changes to mailbox and quit"
+diff -pruN -x'*.orig' mutt-1.5.20/PATCHES mutt-1.5.20-trash/PATCHES
+--- mutt-1.5.20/PATCHES	2008-11-11 14:55:46.000000000 -0500
++++ mutt-1.5.20-trash/PATCHES	2009-07-23 09:53:20.000000000 -0400
+@@ -0,0 +1 @@
++patch-1.5.20.bk.trash_folder-purge_message.1
+diff -pruN -x'*.orig' mutt-1.5.20/commands.c mutt-1.5.20-trash/commands.c
+--- mutt-1.5.20/commands.c	2009-06-12 19:38:52.000000000 -0400
++++ mutt-1.5.20-trash/commands.c	2009-07-23 09:44:40.000000000 -0400
+@@ -716,6 +716,7 @@ int _mutt_save_message (HEADER *h, CONTE
+     if (option (OPTDELETEUNTAG))
+       mutt_set_flag (Context, h, M_TAG, 0);
+   }
++  mutt_set_flag (Context, h, M_APPENDED, 1);
+   
+   return 0;
+ }
+diff -pruN -x'*.orig' mutt-1.5.20/curs_main.c mutt-1.5.20-trash/curs_main.c
+--- mutt-1.5.20/curs_main.c	2009-06-13 22:48:36.000000000 -0400
++++ mutt-1.5.20-trash/curs_main.c	2009-07-23 09:44:40.000000000 -0400
+@@ -1803,6 +1803,7 @@ int mutt_index_menu (void)
+ 	MAYBE_REDRAW (menu->redraw);
+ 	break;
+ 
++      case OP_PURGE_MESSAGE:
+       case OP_DELETE:
+ 
+ 	CHECK_MSGCOUNT;
+@@ -1813,6 +1814,7 @@ int mutt_index_menu (void)
+ 	if (tag)
+ 	{
+ 	  mutt_tag_set_flag (M_DELETE, 1);
++	  mutt_tag_set_flag (M_PURGED, (op != OP_PURGE_MESSAGE) ? 0 : 1);
+ 	  if (option (OPTDELETEUNTAG))
+ 	    mutt_tag_set_flag (M_TAG, 0);
+ 	  menu->redraw = REDRAW_INDEX;
+@@ -1820,6 +1822,8 @@ int mutt_index_menu (void)
+ 	else
+ 	{
+ 	  mutt_set_flag (Context, CURHDR, M_DELETE, 1);
++	  mutt_set_flag (Context, CURHDR, M_PURGED,
++			 (op != OP_PURGE_MESSAGE) ? 0 : 1);
+ 	  if (option (OPTDELETEUNTAG))
+ 	    mutt_set_flag (Context, CURHDR, M_TAG, 0);
+ 	  if (option (OPTRESOLVE))
+@@ -2116,11 +2120,13 @@ int mutt_index_menu (void)
+ 	if (tag)
+ 	{
+ 	  mutt_tag_set_flag (M_DELETE, 0);
++	  mutt_tag_set_flag (M_PURGED, 0);
+ 	  menu->redraw = REDRAW_INDEX;
+ 	}
+ 	else
+ 	{
+ 	  mutt_set_flag (Context, CURHDR, M_DELETE, 0);
++	  mutt_set_flag (Context, CURHDR, M_PURGED, 0);
+ 	  if (option (OPTRESOLVE) && menu->current < Context->vcount - 1)
+ 	  {
+ 	    menu->current++;
+@@ -2141,9 +2147,11 @@ int mutt_index_menu (void)
+ 	CHECK_ACL(M_ACL_DELETE, _("undelete message(s)"));
+ 
+ 	rc = mutt_thread_set_flag (CURHDR, M_DELETE, 0,
+-				   op == OP_UNDELETE_THREAD ? 0 : 1);
++				   op == OP_UNDELETE_THREAD ? 0 : 1)
++	  + mutt_thread_set_flag (CURHDR, M_PURGED, 0,
++				  op == OP_UNDELETE_THREAD ? 0 : 1);
+ 
+-	if (rc != -1)
++	if (rc > -1)
+ 	{
+ 	  if (option (OPTRESOLVE))
+ 	  {
+diff -pruN -x'*.orig' mutt-1.5.20/flags.c mutt-1.5.20-trash/flags.c
+--- mutt-1.5.20/flags.c	2008-12-16 22:50:09.000000000 -0500
++++ mutt-1.5.20-trash/flags.c	2009-07-23 09:44:40.000000000 -0400
+@@ -65,7 +65,13 @@ void _mutt_set_flag (CONTEXT *ctx, HEADE
+       {
+ 	h->deleted = 0;
+         update = 1;
+-	if (upd_ctx) ctx->deleted--;
++        if (upd_ctx)
++        {
++          ctx->deleted--;
++          if (h->appended)
++            ctx->appended--;
++        }
++        h->appended = 0; /* when undeleting, also reset the appended flag */
+ #ifdef USE_IMAP
+         /* see my comment above */
+ 	if (ctx->magic == M_IMAP) 
+@@ -87,6 +93,27 @@ void _mutt_set_flag (CONTEXT *ctx, HEADE
+       }
+       break;
+ 
++    case M_APPENDED:
++      if (bf)
++      {
++       if (!h->appended)
++       {
++         h->appended = 1;
++         if (upd_ctx) ctx->appended++;
++       }
++      }
++      break;
++
++    case M_PURGED:
++      if (bf)
++      {
++	if (!h->purged)
++	  h->purged = 1;
++      }
++      else if (h->purged)
++	h->purged = 0;
++      break;
++
+     case M_NEW:
+ 
+       if (!mutt_bit_isset(ctx->rights,M_ACL_SEEN))
+diff -pruN -x'*.orig' mutt-1.5.20/functions.h mutt-1.5.20-trash/functions.h
+--- mutt-1.5.20/functions.h	2009-04-30 01:36:17.000000000 -0400
++++ mutt-1.5.20-trash/functions.h	2009-07-23 09:44:40.000000000 -0400
+@@ -120,6 +120,7 @@ struct binding_t OpMain[] = { /* map: in
+   { "toggle-write",		OP_TOGGLE_WRITE,		"%" },
+   { "next-thread",		OP_MAIN_NEXT_THREAD,		"\016" },
+   { "next-subthread",		OP_MAIN_NEXT_SUBTHREAD,		"\033n" },
++  { "purge-message",		OP_PURGE_MESSAGE,		NULL },
+   { "query",			OP_QUERY,			"Q" },
+   { "quit",			OP_QUIT,			"q" },
+   { "reply",			OP_REPLY,			"r" },
+@@ -209,6 +210,7 @@ struct binding_t OpPager[] = { /* map: p
+   { "print-message",	OP_PRINT,			"p" },
+   { "previous-thread",	OP_MAIN_PREV_THREAD,		"\020" },
+   { "previous-subthread",OP_MAIN_PREV_SUBTHREAD,	"\033p" },
++  { "purge-message",	OP_PURGE_MESSAGE,		NULL },
+   { "quit",		OP_QUIT,			"Q" },
+   { "exit",		OP_EXIT,			"q" },
+   { "reply",		OP_REPLY,			"r" },
+diff -pruN -x'*.orig' mutt-1.5.20/globals.h mutt-1.5.20-trash/globals.h
+--- mutt-1.5.20/globals.h	2009-06-03 16:48:31.000000000 -0400
++++ mutt-1.5.20-trash/globals.h	2009-07-23 09:44:40.000000000 -0400
+@@ -139,6 +139,7 @@ WHERE char *StChars;
+ WHERE char *Status;
+ WHERE char *Tempdir;
+ WHERE char *Tochars;
++WHERE char *TrashPath;
+ WHERE char *Username;
+ WHERE char *Visual;
+ 
+diff -pruN -x'*.orig' mutt-1.5.20/imap/message.c mutt-1.5.20-trash/imap/message.c
+--- mutt-1.5.20/imap/message.c	2009-06-07 13:52:57.000000000 -0400
++++ mutt-1.5.20-trash/imap/message.c	2009-07-23 09:44:40.000000000 -0400
+@@ -867,6 +867,7 @@ int imap_copy_messages (CONTEXT* ctx, HE
+         if (ctx->hdrs[n]->tagged)
+         {
+           mutt_set_flag (ctx, ctx->hdrs[n], M_DELETE, 1);
++         mutt_set_flag (ctx, ctx->hdrs[n], M_APPENDED, 1);
+           if (option (OPTDELETEUNTAG))
+             mutt_set_flag (ctx, ctx->hdrs[n], M_TAG, 0);
+         }
+@@ -874,6 +875,7 @@ int imap_copy_messages (CONTEXT* ctx, HE
+     else
+     {
+       mutt_set_flag (ctx, h, M_DELETE, 1);
++      mutt_set_flag (ctx, h, M_APPENDED, 1);
+       if (option (OPTDELETEUNTAG))
+         mutt_set_flag (ctx, h, M_TAG, 0);
+     }
+diff -pruN -x'*.orig' mutt-1.5.20/init.h mutt-1.5.20-trash/init.h
+--- mutt-1.5.20/init.h	2009-06-13 17:35:21.000000000 -0400
++++ mutt-1.5.20-trash/init.h	2009-07-23 09:44:40.000000000 -0400
+@@ -3180,6 +3180,16 @@ struct option_t MuttVars[] = {
+   ** by \fIyou\fP.  The sixth character is used to indicate when a mail
+   ** was sent to a mailing-list you subscribe to.
+   */
++  { "trash",           DT_PATH, R_NONE, UL &TrashPath, 0 },
++  /*
++  ** .pp
++  ** If set, this variable specifies the path of the trash folder where the
++  ** mails marked for deletion will be moved, instead of being irremediably
++  ** purged.
++  ** .pp
++  ** NOTE: When you delete a message in the trash folder, it is really
++  ** deleted, so that you have a way to clean the trash.
++  */
+ #ifdef USE_SOCKET
+   { "tunnel",            DT_STR, R_NONE, UL &Tunnel, UL 0 },
+   /*
+diff -pruN -x'*.orig' mutt-1.5.20/mutt.h mutt-1.5.20-trash/mutt.h
+--- mutt-1.5.20/mutt.h	2009-06-12 18:15:42.000000000 -0400
++++ mutt-1.5.20-trash/mutt.h	2009-07-23 09:44:40.000000000 -0400
+@@ -187,6 +187,8 @@ enum
+   M_DELETE,
+   M_UNDELETE,
+   M_DELETED,
++  M_APPENDED,
++  M_PURGED,
+   M_FLAG,
+   M_TAG,
+   M_UNTAG,
+@@ -701,6 +703,8 @@ typedef struct header
+   unsigned int mime : 1;    		/* has a MIME-Version header? */
+   unsigned int flagged : 1; 		/* marked important? */
+   unsigned int tagged : 1;
++  unsigned int appended : 1; /* has been saved */
++  unsigned int purged : 1;   /* bypassing the trash folder */
+   unsigned int deleted : 1;
+   unsigned int changed : 1;
+   unsigned int attach_del : 1; 		/* has an attachment marked for deletion */
+@@ -873,6 +877,7 @@ typedef struct _context
+   int new;			/* how many new messages? */
+   int unread;			/* how many unread messages? */
+   int deleted;			/* how many deleted messages */
++  int appended;                 /* how many saved messages? */
+   int flagged;			/* how many flagged messages */
+   int msgnotreadyet;		/* which msg "new" in pager, -1 if none */
+ 
+diff -pruN -x'*.orig' mutt-1.5.20/muttlib.c mutt-1.5.20-trash/muttlib.c
+--- mutt-1.5.20/muttlib.c	2009-05-18 20:11:35.000000000 -0400
++++ mutt-1.5.20-trash/muttlib.c	2009-07-23 09:44:40.000000000 -0400
+@@ -1460,7 +1460,9 @@ int mutt_save_confirm (const char *s, st
+ 
+   if (magic > 0 && !mx_access (s, W_OK))
+   {
+-    if (option (OPTCONFIRMAPPEND))
++    if (option (OPTCONFIRMAPPEND) &&
++       (!TrashPath || (mutt_strcmp (s, TrashPath) != 0)))
++      /* if we're appending to the trash, there's no point in asking */
+     {
+       snprintf (tmp, sizeof (tmp), _("Append messages to %s?"), s);
+       if ((rc = mutt_yesorno (tmp, M_YES)) == M_NO)
+diff -pruN -x'*.orig' mutt-1.5.20/mx.c mutt-1.5.20-trash/mx.c
+--- mutt-1.5.20/mx.c	2009-06-11 00:29:41.000000000 -0400
++++ mutt-1.5.20-trash/mx.c	2009-07-23 09:44:40.000000000 -0400
+@@ -773,6 +773,54 @@ static int sync_mailbox (CONTEXT *ctx, i
+   return rc;
+ }
+ 
++/* move deleted mails to the trash folder */
++static int trash_append (CONTEXT *ctx)
++{
++    CONTEXT *ctx_trash;
++    int i = 0;
++    struct stat st, stc;
++
++    if (!TrashPath || !ctx->deleted ||
++       (ctx->magic == M_MAILDIR && option (OPTMAILDIRTRASH)))
++      return 0;
++
++    for (;i < ctx->msgcount && (!ctx->hdrs[i]->deleted ||
++                               ctx->hdrs[i]->appended); i++);
++    if (i == ctx->msgcount)
++      return 0; /* nothing to be done */
++
++    if (mutt_save_confirm (TrashPath, &st) != 0)
++    {
++      mutt_error _("message(s) not deleted");
++      return -1;
++    }
++
++    if (lstat (ctx->path, &stc) == 0 && stc.st_ino == st.st_ino
++       && stc.st_dev == st.st_dev && stc.st_rdev == st.st_rdev)
++      return 0;  /* we are in the trash folder: simple sync */
++
++    if ((ctx_trash = mx_open_mailbox (TrashPath, M_APPEND, NULL)) != NULL)
++    {
++      for (i = 0 ; i < ctx->msgcount ; i++)
++       if (ctx->hdrs[i]->deleted && !ctx->hdrs[i]->appended
++           && !ctx->hdrs[i]->purged
++           && mutt_append_message (ctx_trash, ctx, ctx->hdrs[i], 0, 0) == -1)
++         {
++           mx_close_mailbox (ctx_trash, NULL);
++           return -1;
++         }
++
++      mx_close_mailbox (ctx_trash, NULL);
++    }
++    else
++    {
++      mutt_error _("Can't open trash folder");
++      return -1;
++    }
++
++    return 0;
++}
++
+ /* save changes and close mailbox */
+ int mx_close_mailbox (CONTEXT *ctx, int *index_hint)
+ {
+@@ -909,6 +957,7 @@ int mx_close_mailbox (CONTEXT *ctx, int 
+ 	  if (mutt_append_message (&f, ctx, ctx->hdrs[i], 0, CH_UPDATE_LEN) == 0)
+ 	  {
+ 	    mutt_set_flag (ctx, ctx->hdrs[i], M_DELETE, 1);
++            mutt_set_flag (ctx, ctx->hdrs[i], M_APPENDED, 1);
+ 	  }
+ 	  else
+ 	  {
+@@ -931,6 +980,14 @@ int mx_close_mailbox (CONTEXT *ctx, int 
+     return 0;
+   }
+   
++  /* copy mails to the trash before expunging */
++  if (purge && ctx->deleted)
++    if (trash_append (ctx) != 0)
++    {
++      ctx->closing = 0;
++      return -1;
++    }
++
+ #ifdef USE_IMAP
+   /* allow IMAP to preserve the deleted flag across sessions */
+   if (ctx->magic == M_IMAP)
+@@ -1130,6 +1187,12 @@ int mx_sync_mailbox (CONTEXT *ctx, int *
+   msgcount = ctx->msgcount;
+   deleted = ctx->deleted;
+ 
++  if (purge && ctx->deleted)
++  {
++    if (trash_append (ctx) == -1)
++      return -1;
++  } 
++
+ #ifdef USE_IMAP
+   if (ctx->magic == M_IMAP)
+     rc = imap_sync_mailbox (ctx, purge, index_hint);
+diff -pruN -x'*.orig' mutt-1.5.20/pager.c mutt-1.5.20-trash/pager.c
+--- mutt-1.5.20/pager.c	2009-06-03 16:48:31.000000000 -0400
++++ mutt-1.5.20-trash/pager.c	2009-07-23 09:44:40.000000000 -0400
+@@ -2309,12 +2309,15 @@ search_next:
+ 	MAYBE_REDRAW (redraw);
+ 	break;
+ 
++      case OP_PURGE_MESSAGE:
+       case OP_DELETE:
+ 	CHECK_MODE(IsHeader (extra));
+ 	CHECK_READONLY;
+ 	CHECK_ACL(M_ACL_DELETE, _("delete message"));
+ 
+ 	mutt_set_flag (Context, extra->hdr, M_DELETE, 1);
++	mutt_set_flag (Context, extra->hdr, M_PURGED,
++		       ch != OP_PURGE_MESSAGE ? 0 : 1);
+         if (option (OPTDELETEUNTAG))
+ 	  mutt_set_flag (Context, extra->hdr, M_TAG, 0);
+ 	redraw = REDRAW_STATUS | REDRAW_INDEX;
+@@ -2641,6 +2644,7 @@ search_next:
+ 	CHECK_ACL(M_ACL_DELETE, _("undelete message"));
+ 
+ 	mutt_set_flag (Context, extra->hdr, M_DELETE, 0);
++	mutt_set_flag (Context, extra->hdr, M_PURGED, 0);
+ 	redraw = REDRAW_STATUS | REDRAW_INDEX;
+ 	if (option (OPTRESOLVE))
+ 	{
+@@ -2656,9 +2660,11 @@ search_next:
+ 	CHECK_ACL(M_ACL_DELETE, _("undelete message(s)"));
+ 
+ 	r = mutt_thread_set_flag (extra->hdr, M_DELETE, 0,
++				  ch == OP_UNDELETE_THREAD ? 0 : 1)
++	  + mutt_thread_set_flag (extra->hdr, M_PURGED, 0,
+ 				  ch == OP_UNDELETE_THREAD ? 0 : 1);
+ 
+-	if (r != -1)
++	if (r > -1)
+ 	{
+ 	  if (option (OPTRESOLVE))
+ 	  {
+diff -pruN -x'*.orig' mutt-1.5.20/pattern.c mutt-1.5.20-trash/pattern.c
+--- mutt-1.5.20/pattern.c	2009-06-03 16:48:31.000000000 -0400
++++ mutt-1.5.20-trash/pattern.c	2009-07-23 09:44:40.000000000 -0400
+@@ -1347,8 +1347,10 @@ int mutt_pattern_func (int op, char *pro
+       {
+ 	switch (op)
+ 	{
+-	  case M_DELETE:
+ 	  case M_UNDELETE:
++	    mutt_set_flag (Context, Context->hdrs[Context->v2r[i]], M_PURGED,
++			   0);
++	  case M_DELETE:
+ 	    mutt_set_flag (Context, Context->hdrs[Context->v2r[i]], M_DELETE, 
+ 			  (op == M_DELETE));
+ 	    break;
+diff -pruN -x'*.orig' mutt-1.5.20/postpone.c mutt-1.5.20-trash/postpone.c
+--- mutt-1.5.20/postpone.c	2009-06-13 17:28:37.000000000 -0400
++++ mutt-1.5.20-trash/postpone.c	2009-07-23 09:44:40.000000000 -0400
+@@ -276,6 +276,9 @@ int mutt_get_postponed (CONTEXT *ctx, HE
+   /* finished with this message, so delete it. */
+   mutt_set_flag (PostContext, h, M_DELETE, 1);
+ 
++  /* and consider it saved, so that it won't be moved to the trash folder */
++  mutt_set_flag (PostContext, h, M_APPENDED, 1);
++
+   /* update the count for the status display */
+   PostCount = PostContext->msgcount - PostContext->deleted;
+ 
diff -urN mutt-devel/files/patch-02 mutt-devel-1.5.21-ja.2/files/patch-02
--- mutt-devel/files/patch-02	2012-07-14 22:54:48.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/patch-02	2013-01-02 23:57:27.000000000 +0900
@@ -9,3 +9,24 @@
  
  install-data-local: makedoc-all instdoc
  	$(top_srcdir)/mkinstalldirs $(DESTDIR)$(mandir)/man1
+@@ -70,9 +70,6 @@
+ 		$(INSTALL) -m 644 $(srcdir)/$$f $(DESTDIR)$(docdir) ; \
+ 	done
+ 	-$(INSTALL) -m 644 manual.txt $(DESTDIR)$(docdir)
+-	-for f in $(HTML_DOCFILES) ; do \
+-		$(INSTALL) -m 644 $$f $(DESTDIR)$(docdir) ; \
+-	done
+ 	$(INSTALL) -m 644 Muttrc $(DESTDIR)$(sysconfdir)/Muttrc.dist
+ 	-if [ -f $(DESTDIR)$(pkgdatadir)/Muttrc ] ; then \
+ 		mv $(DESTDIR)$(pkgdatadir)/Muttrc* $(DESTDIR)$(sysconfdir) ; \
+@@ -103,9 +100,7 @@
+ 
+ check:
+ manual.txt: manual.html
+-	-LC_ALL=C lynx -dump -nolist -with_backspaces -display_charset=us-ascii manual.html > $@ || \
+-	LC_ALL=C w3m -dump manual.html > $@ || \
+-	LC_ALL=C elinks -dump -no-numbering -no-references manual.html | sed -e 's,\\001, ,g' > $@
++	-LC_ALL=C lynx -dump -nolist -with_backspaces -display_charset=us-ascii manual.html > $@
+ 
+ Muttrc: stamp-doc-rc
+ 
diff -urN mutt-devel/files/patch-05 mutt-devel-1.5.21-ja.2/files/patch-05
--- mutt-devel/files/patch-05	1970-01-01 09:00:00.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/patch-05	2013-01-02 23:57:27.000000000 +0900
@@ -0,0 +1,43 @@
+--- curs_lib.c.old	Wed Sep  1 19:39:20 1999
++++ curs_lib.c	Sun Sep 26 23:47:03 1999
+@@ -156,6 +156,16 @@
+       def = 0;
+       break;
+     }
++    else if (tolower(ch.ch) == 'y')
++    {
++      def = 1;
++      break;
++    }
++    else if (tolower(ch.ch) == 'n')
++    {
++      def = 0;
++      break;
++    }
+     else
+     {
+       BEEP();
+@@ -413,8 +423,9 @@
+ {
+   event_t ch;
+   int choice;
+-  char *p;
++  char *p, *nletters;
+ 
++  nletters = _(letters);
+   mvaddstr (LINES - 1, 0, prompt);
+   clrtoeol ();
+   FOREVER
+@@ -428,6 +439,12 @@
+     }
+     else
+     {
++      p = strchr (nletters, ch.ch);
++      if (p)
++      {
++	choice = p - nletters + 1;
++	break;
++      }
+       p = strchr (letters, ch.ch);
+       if (p)
+       {
diff -urN mutt-devel/files/patch-08 mutt-devel-1.5.21-ja.2/files/patch-08
--- mutt-devel/files/patch-08	1970-01-01 09:00:00.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/patch-08	2013-01-02 23:57:27.000000000 +0900
@@ -0,0 +1,10 @@
+--- doc/Muttrc.orig	Sat May 13 08:30:44 2000
++++ doc/Muttrc	Sat May 13 08:32:05 2000
+@@ -629,6 +629,7 @@
+ # Type: boolean
+ # Default: yes
+ # 
++set followup_to=no
+ # 
+ # Controls whether or not the Mail-Followup-To header field is
+ # generated when sending mail.  When set, Mutt will generate this
diff -urN mutt-devel/files/patch-Makefile.am mutt-devel-1.5.21-ja.2/files/patch-Makefile.am
--- mutt-devel/files/patch-Makefile.am	1970-01-01 09:00:00.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/patch-Makefile.am	2012-07-22 18:15:04.000000000 +0900
@@ -0,0 +1,13 @@
+--- Makefile.am.orig	2008-05-19 19:00:44.000000000 +0200
++++ Makefile.am	2008-05-19 19:03:20.000000000 +0200
+@@ -136,10 +136,6 @@
+ 
+ install-data-local:
+ 	$(srcdir)/mkinstalldirs $(DESTDIR)$(sysconfdir)
+-	$(INSTALL) -m 644 $(srcdir)/mime.types $(DESTDIR)$(sysconfdir)/mime.types.dist
+-	-if [ ! -f $(DESTDIR)$(sysconfdir)/mime.types ]; then \
+-		$(INSTALL) -m 644 $(srcdir)/mime.types $(DESTDIR)$(sysconfdir); \
+-	fi
+ 
+ uninstall-local:
+ 	for i in mime.types ; do \
diff -urN mutt-devel/files/patch-bdb mutt-devel-1.5.21-ja.2/files/patch-bdb
--- mutt-devel/files/patch-bdb	1970-01-01 09:00:00.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/patch-bdb	2012-07-22 18:15:04.000000000 +0900
@@ -0,0 +1,11 @@
+--- configure.ac.orig	2009-06-09 08:50:33.000000000 +0200
++++ configure.ac	2010-01-27 18:15:31.000000000 +0100
+@@ -976,7 +976,7 @@
+                 bdbpfx="$bdbpfx $d/$v"
+             done
+         done
+-        BDB_VERSIONS="db-4 db4 db-4.6 db4.6 db46 db-4.5 db4.5 db45 db-4.4 db4.4 db44 db-4.3 db4.3 db43 db-4.2 db4.2 db42 db-4.1 db4.1 db41 db ''"
++        BDB_VERSIONS="db-4 db4 db-5 db5 db-5.2 db5.2 db52 db-5.1 db5.1 db51 db-5.0 db5.0 db50 db-4.8 db4.8 db48 db-4.7 db4.7 db47 db-4.6 db4.6 db46 db-4.5 db4.5 db45 db-4.4 db4.4 db44 db-4.3 db4.3 db43 db-4.2 db4.2 db42 db-4.1 db4.1 db41 db ''"
+         AC_MSG_CHECKING([for BerkeleyDB > 4.0])
+         for d in $bdbpfx; do
+             BDB_INCLUDE_DIR=""
diff -urN mutt-devel/files/patch-color-eol mutt-devel-1.5.21-ja.2/files/patch-color-eol
--- mutt-devel/files/patch-color-eol	1970-01-01 09:00:00.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/patch-color-eol	2012-07-22 18:15:04.000000000 +0900
@@ -0,0 +1,62 @@
+--- mutt.h.orig	Fri Jun  4 13:35:59 2004
++++ mutt.h	Fri Jun  4 13:49:26 2004
+@@ -350,6 +350,7 @@
+   OPTBEEPNEW,
+   OPTBOUNCEDELIVERED,
+   OPTCHECKNEW,
++  OPTCOLORAFTEREOL,
+   OPTCOLLAPSEUNREAD,
+   OPTCONFIRMAPPEND,
+   OPTCONFIRMCREATE,
+--- init.h.orig	Fri Jun  4 13:35:56 2004
++++ init.h	Fri Jun  4 13:45:43 2004
+@@ -315,6 +315,12 @@
+   ** \fIcheck_new\fP is \fIunset\fP, no check for new mail is performed
+   ** while the mailbox is open.
+   */
++  { "color_after_eol",	DT_BOOL, R_NONE, OPTCOLORAFTEREOL, 1 },
++  /*
++  ** .pp
++  ** When \fIset\fP, Mutt will color a line after the last character extending
++  ** to the end of the window.
++  */
+   { "collapse_unread",	DT_BOOL, R_NONE, OPTCOLLAPSEUNREAD, 1 },
+   /*
+   ** .pp
+--- pager.c.orig	Sat Jun  5 09:13:33 2004
++++ pager.c	Sat Jun  5 09:12:31 2004
+@@ -1392,7 +1392,7 @@
+    * ncurses does an implicit clrtoeol() when you do addch('\n') so we have
+    * to make sure to reset the color *after* that
+    */
+-  if (flags & M_SHOWCOLOR)
++  if (option (OPTCOLORAFTEREOL) && (flags & M_SHOWCOLOR))
+   {
+     m = ((*lineInfo)[n].continuation) ? ((*lineInfo)[n].syntax)[0].first : n;
+     if ((*lineInfo)[m].type == MT_COLOR_HEADER)
+@@ -1406,6 +1406,16 @@
+ #endif
+   }
+ 
++  /*
++   * reset the color back to normal.  This *must* come before the
++   * addch('\n') for the color not to be filled to the right margin.
++   */
++  if (!option (OPTCOLORAFTEREOL) && (flags & M_SHOWCOLOR))
++  {
++    SETCOLOR(MT_COLOR_NORMAL);
++    BKGDSET(MT_COLOR_NORMAL);
++  }
++
+   /* ncurses always wraps lines when you get to the right side of the
+    * screen, but S-Lang seems to only wrap if the next character is *not*
+    * a newline (grr!).
+@@ -1420,7 +1430,7 @@
+    * addch('\n'), otherwise the color for this line will not be
+    * filled to the right margin.
+    */
+-  if (flags & M_SHOWCOLOR)
++  if (option (OPTCOLORAFTEREOL) && (flags & M_SHOWCOLOR))
+   {
+     SETCOLOR(MT_COLOR_NORMAL);
+     BKGDSET(MT_COLOR_NORMAL);
diff -urN mutt-devel/files/patch-configure.ac mutt-devel-1.5.21-ja.2/files/patch-configure.ac
--- mutt-devel/files/patch-configure.ac	2012-07-14 22:54:48.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/patch-configure.ac	2012-07-22 18:15:04.000000000 +0900
@@ -1,5 +1,5 @@
 --- configure.ac.orig	2010-08-24 09:34:21.000000000 -0700
-+++ configure.ac	2012-05-03 18:35:26.000000000 -0700
++++ configure.ac	2012-05-03 18:14:34.000000000 -0700
 @@ -29,6 +29,2 @@
  AC_ISC_POSIX
 -AM_C_PROTOTYPES
diff -urN mutt-devel/files/patch-contrib-Makefile.am mutt-devel-1.5.21-ja.2/files/patch-contrib-Makefile.am
--- mutt-devel/files/patch-contrib-Makefile.am	1970-01-01 09:00:00.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/patch-contrib-Makefile.am	2012-07-22 18:15:04.000000000 +0900
@@ -0,0 +1,11 @@
+--- contrib/Makefile.am.orig	Tue Jul 18 20:04:14 2006
++++ contrib/Makefile.am	Wed Aug 30 16:15:04 2006
+@@ -2,7 +2,7 @@
+ 
+ subdir = contrib
+ 
+-SAMPLES = Mush.rc Pine.rc gpg.rc pgp2.rc pgp5.rc pgp6.rc Tin.rc \
++SAMPLES = Mush.rc Pine.rc gpg.rc pgp2.rc pgp6.rc Tin.rc \
+ 	sample.muttrc  sample.mailcap sample.muttrc-tlr \
+ 	colors.default colors.linux smime.rc \
+ 	ca-bundle.crt smime_keys_test.pl
diff -urN mutt-devel/files/patch-crypt-gpgme.c mutt-devel-1.5.21-ja.2/files/patch-crypt-gpgme.c
--- mutt-devel/files/patch-crypt-gpgme.c	1970-01-01 09:00:00.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/patch-crypt-gpgme.c	2012-07-22 18:15:04.000000000 +0900
@@ -0,0 +1,10 @@
+--- ./crypt-gpgme.c.orig	2009-07-01 21:28:51.000000000 -0400
++++ ./crypt-gpgme.c	2009-07-01 21:31:52.000000000 -0400
+@@ -342,6 +342,7 @@
+   gpgme_error_t err;
+   gpgme_ctx_t ctx;
+ 
++  gpgme_check_version (NULL);
+   if (!GpgmeLocaleSet)
+   {
+     gpgme_set_locale (NULL, LC_CTYPE, setlocale (LC_CTYPE, NULL));
diff -urN mutt-devel/files/patch-date-conditional mutt-devel-1.5.21-ja.2/files/patch-date-conditional
--- mutt-devel/files/patch-date-conditional	1970-01-01 09:00:00.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/patch-date-conditional	2012-07-22 18:15:04.000000000 +0900
@@ -0,0 +1,147 @@
+--- PATCHES~	never
++++ PATCHES	Thu Jun 13 16:25:05 CDT 2002
+@@ -0,0 +1 @@
++dgc.deepif.1
+diff -Pur mutt-1.5.1-base/muttlib.c mutt-1.5.1/muttlib.c
+--- muttlib.c	Tue Mar 26 16:47:06 2002
++++ muttlib.c	Thu Jun 13 15:28:20 2002
+@@ -978,6 +978,12 @@
+ 	count = 0;
+         while (count < sizeof (ifstring) && *src && *src != '?' && *src != '&')
+ 	{
++	  if (*src == '\\')
++	  {
++	    src++;
++	    if (!*src)
++	      break;
++	  }
+           *cp++ = *src++;
+ 	  count++;
+ 	}
+@@ -990,7 +996,13 @@
+ 	count = 0;
+ 	while (count < sizeof (elsestring) && *src && *src != '?')
+ 	{
+-	  *cp++ = *src++;
++	  if (*src == '\\')
++	  {
++	    src++;
++	    if (!*src)
++	      break;
++	  }
++          *cp++ = *src++;
+ 	  count++;
+ 	}
+ 	*cp = 0;
+Index: PATCHES
+===================================================================
+--- PATCHES	(revision 22)
++++ PATCHES	(revision 22)
+@@ -0,0 +1 @@
++patch-1.5.0.ats.date_conditional.1
+Index: muttlib.c
+===================================================================
+--- muttlib.c	(revision 22)
++++ muttlib.c	(revision 22)
+@@ -944,7 +944,16 @@
+       if (*src == '?')
+       {
+ 	flags |= M_FORMAT_OPTIONAL;
+-	src++;
++	ch = *(++src); /* save the character to switch on */
++	cp = prefix;
++	++src;
++	count = 0;
++	while (count < sizeof (prefix) && *src != '?')
++	{
++	  *cp++ = *src++;
++	  count++;
++	}
++	*cp = 0;
+       }
+       else
+       {
+@@ -960,12 +969,12 @@
+ 	  count++;
+ 	}
+ 	*cp = 0;
+-      }
+ 
+-      if (!*src)
+-	break; /* bad format */
++	if (!*src)
++	  break; /* bad format */
+ 
+-      ch = *src++; /* save the character to switch on */
++	ch = *src++; /* save the character to switch on */
++      }
+ 
+       if (flags & M_FORMAT_OPTIONAL)
+       {
+--- hdrline.c.orig	Tue Jun 29 15:01:28 2004
++++ hdrline.c	Tue Jun 29 15:02:59 2004
+@@ -316,6 +316,64 @@
+ 	const char *cp;
+ 	struct tm *tm; 
+ 	time_t T;
++	int i = 0, invert = 0;
++
++	if (optional && (op == '[' || op == '(')) {
++	  char *is;
++          int d;
++	  T = time(NULL);
++	  tm = localtime(&T);
++	  d = (T + tm->tm_gmtoff) % 86400;
++	  T -= (op == '(') ? hdr->received : hdr->date_sent;
++
++	  is = (char *)prefix;
++	  if( *is == '>' ) {
++	    invert = 1;
++	    ++is;
++	  }
++
++	  while( *is && *is != '?' ) {
++	    int t = strtol (is, &is, 10);
++	    switch (*(is++)) {
++	      case '?':
++		break;
++	      case 'y':
++		t *= 365 * 24 * 60 * 60;
++		break;
++	      case 'M':
++		t *= 30 * 24 * 60 * 60;
++		break;
++	      case 'w':
++		t *= 7 * 24 * 60 * 60;
++		break;
++	      case 'd':
++		t *= 24 * 60 * 60;
++		break;
++	      case 't':
++		if (t > 1) {
++		  t = (t-1) * 24 * 60 * 60;
++		} else {
++		  t = 0;
++		}
++		t += d;
++		break;
++	      case 'h':
++		t *= 60 * 60;
++		break;
++	      case 'm':
++		t *= 60;
++		break;
++	    }
++	    i += t;
++	  }
++
++	  if (i < 0)
++	    i *= -1;
++
++	  if( (T > i || T < -1*i) ^ invert )
++	    optional = 0;
++	  break;
++	}
+ 
+ 	p = dest;
+ 
diff -urN mutt-devel/files/patch-doc-manual.xml.head mutt-devel-1.5.21-ja.2/files/patch-doc-manual.xml.head
--- mutt-devel/files/patch-doc-manual.xml.head	1970-01-01 09:00:00.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/patch-doc-manual.xml.head	2012-07-22 18:15:04.000000000 +0900
@@ -0,0 +1,10 @@
+--- doc/manual.xml.head.orig	2009-06-22 08:35:06.000000000 +0200
++++ doc/manual.xml.head	2009-06-22 08:37:31.000000000 +0200
+@@ -1,6 +1,6 @@
+ <?xml version="1.0" standalone="no"?>
+ <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
+-  "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">;
++  "/usr/local/share/xml/docbook/4.2/docbookx.dtd">
+ <book>
+ 
+ <bookinfo>
diff -urN mutt-devel/files/patch-examples mutt-devel-1.5.21-ja.2/files/patch-examples
--- mutt-devel/files/patch-examples	1970-01-01 09:00:00.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/patch-examples	2013-01-02 23:57:27.000000000 +0900
@@ -0,0 +1,109 @@
+--- contrib/Makefile.am.orig	Tue Jul 18 20:04:14 2006
++++ contrib/Makefile.am	Wed Aug 30 16:05:33 2006
+@@ -1,6 +1,7 @@
+ # $Id: Makefile.am,v 3.1 2006/07/18 18:04:14 brendan Exp $
+ 
+ subdir = contrib
++samplesdir = @samplesdir@
+ 
+ SAMPLES = Mush.rc Pine.rc gpg.rc pgp2.rc pgp5.rc pgp6.rc Tin.rc \
+ 	sample.muttrc  sample.mailcap sample.muttrc-tlr \
+@@ -14,12 +15,12 @@
+ 	iconv/make.sh
+ 
+ install-data-local:
+-	$(top_srcdir)/mkinstalldirs $(DESTDIR)$(docdir)/samples $(DESTDIR)$(docdir)/samples/iconv
++	$(top_srcdir)/mkinstalldirs $(DESTDIR)$(samplesdir) $(DESTDIR)$(samplesdir)/iconv
+ 	for f in $(SAMPLES) ; do \
+-		$(INSTALL) -m 644 $(srcdir)/$$f $(DESTDIR)$(docdir)/samples ;	\
++		$(INSTALL) -m 644 $(srcdir)/$$f $(DESTDIR)$(samplesdir) ;	\
+ 	done
+ 	for f in $(srcdir)/iconv/*.rc ; do					\
+-		$(INSTALL) -m 644 $$f $(DESTDIR)$(docdir)/samples/iconv	  ;	\
++		$(INSTALL) -m 644 $$f $(DESTDIR)$(samplesdir)/iconv  ;	\
+ 	done
+ 
+ uninstall-local:
+--- init.h.orig	2009-02-06 13:27:52.000000000 +0100
++++ init.h	2009-02-06 13:34:09.000000000 +0100
+@@ -1808,9 +1808,8 @@
+   ** .pp
+   ** For examples on how to configure these formats for the various versions
+   ** of PGP which are floating around, see the pgp and gpg sample configuration files in
+-  ** the \fCsamples/\fP subdirectory which has been installed on your system
+-  ** alongside the documentation.
+-  ** (PGP only)
++  ** the \fCshare/examples/mutt/\fP subdirectory which has been installed on
++  **  your system. (PGP only)
+   */
+   { "pgp_getkeys_command",	DT_STR, R_NONE, UL &PgpGetkeysCommand, 0},
+   /*
+@@ -2017,9 +2016,8 @@
+   ** .de
+   ** .pp
+   ** For examples on how to configure these formats, see the \fCsmime.rc\fP in
+-  ** the \fCsamples/\fP subdirectory which has been installed on your system
+-  ** alongside the documentation.
+-  ** (S/MIME only)
++  ** the \fCshare/examples/mutt/\fP subdirectory which has been installed on
++  ** your system. (S/MIME only)
+   */
+   { "smime_verify_command", 	DT_STR, R_NONE, UL &SmimeVerifyCommand, 0},
+   /*
+--- INSTALL.orig	Mon Nov 25 15:16:46 2002
++++ INSTALL	Wed Mar 26 15:59:57 2003
+@@ -225,13 +225,13 @@
+ need to tell mutt about implementation-defined names for some
+ character sets.  Sample configuration files for various systems can
+ be found in the directory contrib/iconv/ in this source
+-distribution, and will be installed in the samples/iconv directory
++distribution, and will be installed in the share/examples/mutt/iconv directory
+ as part of mutt's documentation.
+ 
+ In order to use these sample configuration files, just put a line
+ like
+ 
+-     source /usr/local/doc/mutt/samples/iconv/iconv.osf1-4.0d.rc
++     source /usr/local/share/examples/mutt/iconv/iconv.osf1-4.0d.rc
+ 
+ into your system's global Muttrc, which normally resides in /etc or
+ /usr/local/etc.
+--- doc/manual.txt.orig	2009-06-14 20:54:56.000000000 +0200
++++ doc/manual.txt	2009-06-22 15:11:26.000000000 +0200
+@@ -3225,9 +3225,9 @@
+ shows that arguments can be quoted: the script will receive the expanded string
+ between the single quotes as the only argument.
+ 
+-A practical example is the mutt_xtitle script installed in the samples
+-subdirectory of the Mutt documentation: it can be used as filter for
+-$status_format to set the current terminal's title, if supported.
++A practical example is the mutt_xtitle script installed in the
++share/examples/mutt/ subdirectory of the Mutt documentation: it can be used as
++filter for $status_format to set the current terminal's title, if supported.
+ 
+ 29.4. Padding
+ 
+@@ -7740,8 +7740,8 @@
+ 
+ For examples on how to configure these formats for the various versions of PGP
+ which are floating around, see the pgp and gpg sample configuration files in
+-the samples/ subdirectory which has been installed on your system alongside the
+-documentation. (PGP only)
++the share/examples/mutt/ subdirectory which has been installed on your system.
++(PGP only)
+ 
+ 3.158. pgp_decrypt_command
+ 
+@@ -8751,9 +8751,9 @@
+ |  |$smime_ca_location?.                                                      |
+ +-----------------------------------------------------------------------------+
+ 
+-For examples on how to configure these formats, see the smime.rc in the samples
+-/ subdirectory which has been installed on your system alongside the
+-documentation. (S/MIME only)
++For examples on how to configure these formats, see the smime.rc in the 
++share/examples/mutt/ subdirectory which has been installed on your system.
++(S/MIME only)
+ 
+ 3.244. smime_decrypt_use_default_key
+ 
diff -urN mutt-devel/files/patch-gnutls-CN-validation mutt-devel-1.5.21-ja.2/files/patch-gnutls-CN-validation
--- mutt-devel/files/patch-gnutls-CN-validation	1970-01-01 09:00:00.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/patch-gnutls-CN-validation	2012-07-22 18:15:04.000000000 +0900
@@ -0,0 +1,29 @@
+--- mutt_ssl_gnutls.c.orig
++++ mutt_ssl_gnutls.c
+@@ -999,6 +999,7 @@
+   unsigned int cert_list_size = 0;
+   gnutls_certificate_status certstat;
+   int certerr, i, preauthrc, savedcert, rc = 0;
++  int rcpeer;
+ 
+   if (gnutls_auth_get_type (state) != GNUTLS_CRD_CERTIFICATE)
+   {
+@@ -1024,6 +1025,9 @@
+   for (i = 0; i < cert_list_size; i++) {
+     rc = tls_check_preauth(&cert_list[i], certstat, conn->account.host, i,
+                            &certerr, &savedcert);
++    if (i == 0)
++      rcpeer = rc;
++
+     preauthrc += rc;
+ 
+     if (savedcert)
+@@ -1049,7 +1053,7 @@
+         dprint (1, (debugfile, "error trusting certificate %d: %d\n", i, rc));
+ 
+       certstat = tls_verify_peers (state);
+-      if (!certstat)
++      if (!certstat && !rcpeer)
+         return 1;
+     }
+   }
diff -urN mutt-devel/files/patch-imap-message.c mutt-devel-1.5.21-ja.2/files/patch-imap-message.c
--- mutt-devel/files/patch-imap-message.c	1970-01-01 09:00:00.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/patch-imap-message.c	2012-07-22 18:15:04.000000000 +0900
@@ -0,0 +1,15 @@
+This patch fixes a segfault that happens when the IMAP server sends some
+additional flags for the same message ID, see upstream bug
+http://bugs.mutt.org/3288
+
+--- imap/message.c
++++ imap/message.c
+@@ -288,7 +288,7 @@
+         continue;
+       }
+       /* May receive FLAGS updates in a separate untagged response (#2935) */
+-      if (idx < ctx->msgcount)
++      if (ctx->hdrs[idx] != NULL)
+       {
+ 	dprint (2, (debugfile, "imap_read_headers: message %d is not new\n",
+ 		    h.sid));
diff -urN mutt-devel/files/patch-init.c mutt-devel-1.5.21-ja.2/files/patch-init.c
--- mutt-devel/files/patch-init.c	1970-01-01 09:00:00.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/patch-init.c	2003-05-03 16:44:15.000000000 +0900
@@ -0,0 +1,39 @@
+--- init.c.orig	Wed Jul 24 10:41:29 2002
++++ init.c	Sat May  3 08:46:29 2003
+@@ -1707,7 +1707,11 @@
+ void mutt_init (int skip_sys_rc, LIST *commands)
+ {
+   struct passwd *pw;
++#if __FreeBSD_version < 500000
++  char nodename[STRING];
++#else
+   struct utsname utsname;
++#endif
+   char *p, buffer[STRING], error[STRING];
+   int i, default_rc = 0, need_pause = 0;
+   BUFFER err;
+@@ -1765,16 +1769,21 @@
+ #endif
+ 
+   /* And about the host... */
++#if __FreeBSD_version < 500000
++  gethostname(nodename, sizeof (nodename));
++#else
+   uname (&utsname);
++  strfcpy (nodename, utsname.nodename, sizeof (nodename));
++#endif
+   /* some systems report the FQDN instead of just the hostname */
+-  if ((p = strchr (utsname.nodename, '.')))
++  if ((p = strchr (nodename, '.')))
+   {
+-    Hostname = mutt_substrdup (utsname.nodename, p);
++    Hostname = mutt_substrdup (nodename, p);
+     p++;
+     strfcpy (buffer, p, sizeof (buffer)); /* save the domain for below */
+   }
+   else
+-    Hostname = safe_strdup (utsname.nodename);
++    Hostname = safe_strdup (nodename);
+ 
+ #ifndef DOMAIN
+ #define DOMAIN buffer
diff -urN mutt-devel/files/patch-mktemp mutt-devel-1.5.21-ja.2/files/patch-mktemp
--- mutt-devel/files/patch-mktemp	1970-01-01 09:00:00.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/patch-mktemp	2013-01-02 23:57:27.000000000 +0900
@@ -0,0 +1,23 @@
+--- muttlib.c.orig	2010-09-19 09:58:24.000000000 +0200
++++ muttlib.c	2010-09-19 10:36:26.000000000 +0200
+@@ -788,14 +788,15 @@
+ 
+ void _mutt_mktemp (char *s, size_t slen, const char *src, int line)
+ {
+-  size_t n = snprintf (s, slen, "%s/mutt-%s-%d-%d-%ld%ld", NONULL (Tempdir), NONULL (Hostname),
+-      (int) getuid (), (int) getpid (), random (), random ());
++  size_t n = snprintf (s, slen, "%s/mutt-%s-XXXXXXXX", NONULL (Tempdir), NONULL (Hostname));
+   if (n >= slen)
+     dprint (1, (debugfile, "%s:%d: ERROR: insufficient buffer space to hold temporary filename! slen=%zu but need %zu\n",
+ 	    src, line, slen, n));
+-  dprint (3, (debugfile, "%s:%d: mutt_mktemp returns \"%s\".\n", src, line, s));
+-  if (unlink (s) && errno != ENOENT)
+-    dprint (1, (debugfile, "%s:%d: ERROR: unlink(\"%s\"): %s (errno %d)\n", src, line, s, strerror (errno), errno));
++  if (mktemp (s)) { 
++    dprint (3, (debugfile, "%s:%d: mutt_mktemp returns \"%s\".\n", src, line, s));
++  } else {
++    dprint (1, (debugfile, "%s:%d: ERROR: mktemp(\"%s\"): %s (errno %d)\n", src, line, s, strerror (errno), errno));
++  }
+ }
+ 
+ void mutt_free_alias (ALIAS **p)
diff -urN mutt-devel/files/patch-nbsp mutt-devel-1.5.21-ja.2/files/patch-nbsp
--- mutt-devel/files/patch-nbsp	1970-01-01 09:00:00.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/patch-nbsp	2012-07-22 18:15:04.000000000 +0900
@@ -0,0 +1,22 @@
+diff --git a/pager.c b/pager.c
+--- pager.c
++++ pager.c
+@@ -1187,10 +1187,17 @@
+       last_special = special;
+     }
+ 
+-    if (IsWPrint (wc))
++    if (IsWPrint (wc) || (Charset_is_utf8 && wc == 0x00A0))
+     {
+       if (wc == ' ')
+ 	space = ch;
++      else if (Charset_is_utf8 && wc == 0x00A0)
++      {
++	/* Convert non-breaking space to normal space. The local variable
++	 * `space' is not set here so that the caller of this function won't
++	 * attempt to wrap at this character. */
++	wc = ' ';
++      }
+       t = wcwidth (wc);
+       if (col + t > wrap_cols)
+ 	break;
diff -urN mutt-devel/files/patch-pgp mutt-devel-1.5.21-ja.2/files/patch-pgp
--- mutt-devel/files/patch-pgp	1970-01-01 09:00:00.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/patch-pgp	2012-07-22 18:15:04.000000000 +0900
@@ -0,0 +1,134 @@
+--- crypt-gpgme.c~	2010-09-10 07:41:33.584316201 +1000
++++ crypt-gpgme.c	2010-09-10 08:22:32.948976728 +1000
+@@ -2003,12 +2003,14 @@
+   {
+     if (!mutt_strncmp ("-----BEGIN PGP ", buf, 15))
+     {
+-      if (!mutt_strcmp ("MESSAGE-----\n", buf + 15))
++      if (!mutt_strcmp ("MESSAGE-----\n", buf + 15) ||
++	  !mutt_strcmp ("MESSAGE-----\r\n", buf + 15))
+       {
+ 	enc = 1;
+ 	break;
+       }
+-      else if (!mutt_strcmp ("SIGNED MESSAGE-----\n", buf + 15))
++      else if (!mutt_strcmp ("SIGNED MESSAGE-----\n", buf + 15) ||
++	       !mutt_strcmp ("SIGNED MESSAGE-----\r\n", buf + 15))
+       {
+ 	sgn = 1;
+ 	break;
+@@ -2128,7 +2130,8 @@
+       continue;
+     }
+ 
+-    if (!mutt_strcmp (buf, "-----BEGIN PGP SIGNATURE-----\n"))
++    if (!mutt_strcmp (buf, "-----BEGIN PGP SIGNATURE-----\n") ||
++	!mutt_strcmp (buf, "-----BEGIN PGP SIGNATURE-----\r\n"))
+       break;
+     
+     if (armor_header)
+@@ -2196,14 +2199,17 @@
+           clearsign = 0;
+           start_pos = last_pos;
+           
+-          if (!mutt_strcmp ("MESSAGE-----\n", buf + 15))
++          if (!mutt_strcmp ("MESSAGE-----\n", buf + 15) ||
++	      !mutt_strcmp ("MESSAGE-----\r\n", buf + 15))
+             needpass = 1;
+-          else if (!mutt_strcmp ("SIGNED MESSAGE-----\n", buf + 15))
++          else if (!mutt_strcmp ("SIGNED MESSAGE-----\n", buf + 15) ||
++		   !mutt_strcmp ("SIGNED MESSAGE-----\r\n", buf + 15))
+             {
+               clearsign = 1;
+               needpass = 0;
+             }
+-          else if (!mutt_strcmp ("PUBLIC KEY BLOCK-----\n", buf + 15))
++          else if (!mutt_strcmp ("PUBLIC KEY BLOCK-----\n", buf + 15) ||
++		   !mutt_strcmp ("PUBLIC KEY BLOCK-----\r\n", buf + 15))
+           {
+             needpass = 0;
+             pgp_keyblock = 1;
+--- pgp.c~	2009-05-31 03:20:08.000000000 +1000
++++ pgp.c	2010-09-10 08:27:40.317064142 +1000
+@@ -219,7 +219,8 @@
+       continue;
+     }
+ 
+-    if (mutt_strcmp (buf, "-----BEGIN PGP SIGNATURE-----\n") == 0)
++    if (mutt_strcmp (buf, "-----BEGIN PGP SIGNATURE-----\n") == 0 ||
++	mutt_strcmp (buf, "-----BEGIN PGP SIGNATURE-----\r\n") == 0)
+       break;
+     
+     if (armor_header)
+@@ -287,14 +288,17 @@
+       clearsign = 0;
+       start_pos = last_pos;
+ 
+-      if (mutt_strcmp ("MESSAGE-----\n", buf + 15) == 0)
++      if (mutt_strcmp ("MESSAGE-----\n", buf + 15) == 0 ||
++	  mutt_strcmp ("MESSAGE-----\r\n", buf + 15) == 0)
+         needpass = 1;
+-      else if (mutt_strcmp ("SIGNED MESSAGE-----\n", buf + 15) == 0)
++      else if (mutt_strcmp ("SIGNED MESSAGE-----\n", buf + 15) == 0 ||
++	       mutt_strcmp ("SIGNED MESSAGE-----\r\n", buf + 15) == 0)
+       {
+ 	clearsign = 1;
+         needpass = 0;
+       }
+-      else if (!mutt_strcmp ("PUBLIC KEY BLOCK-----\n", buf + 15))
++      else if (!mutt_strcmp ("PUBLIC KEY BLOCK-----\n", buf + 15) ||
++	       !mutt_strcmp ("PUBLIC KEY BLOCK-----\r\n", buf + 15))
+       {
+         needpass = 0;
+         pgp_keyblock = 1;
+@@ -327,10 +331,14 @@
+ 	
+ 	fputs (buf, tmpfp);
+ 
+-	if ((needpass && mutt_strcmp ("-----END PGP MESSAGE-----\n", buf) == 0) ||
+-	    (!needpass 
+-             && (mutt_strcmp ("-----END PGP SIGNATURE-----\n", buf) == 0
+-                 || mutt_strcmp ("-----END PGP PUBLIC KEY BLOCK-----\n",buf) == 0)))
++	if ((needpass &&
++	     (mutt_strcmp ("-----END PGP MESSAGE-----\n", buf) == 0 ||
++	      mutt_strcmp ("-----END PGP MESSAGE-----\r\n", buf) == 0)) ||
++	    (!needpass &&
++	     (mutt_strcmp ("-----END PGP SIGNATURE-----\n", buf) == 0 ||
++	      mutt_strcmp ("-----END PGP SIGNATURE-----\r\n", buf) == 0 ||
++	      mutt_strcmp ("-----END PGP PUBLIC KEY BLOCK-----\n",buf) == 0 ||
++	      mutt_strcmp ("-----END PGP PUBLIC KEY BLOCK-----\r\n",buf) == 0)))
+ 	  break;
+ 	/* remember optional Charset: armor header as defined by RfC4880 */
+ 	if (mutt_strncmp ("Charset: ", buf, 9) == 0)
+@@ -554,11 +562,14 @@
+   {
+     if (mutt_strncmp ("-----BEGIN PGP ", buf, 15) == 0)
+     {
+-      if (mutt_strcmp ("MESSAGE-----\n", buf + 15) == 0)
++      if (mutt_strcmp ("MESSAGE-----\n", buf + 15) == 0 ||
++	  mutt_strcmp ("MESSAGE-----\r\n", buf + 15) == 0)
+ 	enc = 1;
+-      else if (mutt_strcmp ("SIGNED MESSAGE-----\n", buf + 15) == 0)
++      else if (mutt_strcmp ("SIGNED MESSAGE-----\n", buf + 15) == 0 ||
++	       mutt_strcmp ("SIGNED MESSAGE-----\r\n", buf + 15) == 0)
+ 	sgn = 1;
+-      else if (mutt_strcmp ("PUBLIC KEY BLOCK-----\n", buf + 15) == 0)
++      else if (mutt_strcmp ("PUBLIC KEY BLOCK-----\n", buf + 15) == 0 ||
++	       mutt_strcmp ("PUBLIC KEY BLOCK-----\r\n", buf + 15) == 0)
+ 	key = 1;
+     }
+   }
+@@ -1067,9 +1078,11 @@
+    */
+   while (fgets (buffer, sizeof (buffer) - 1, pgpout) != NULL)
+   {
+-    if (mutt_strcmp ("-----BEGIN PGP MESSAGE-----\n", buffer) == 0)
++    if (mutt_strcmp ("-----BEGIN PGP MESSAGE-----\n", buffer) == 0 ||
++	mutt_strcmp ("-----BEGIN PGP MESSAGE-----\r\n", buffer) == 0)
+       fputs ("-----BEGIN PGP SIGNATURE-----\n", fp);
+-    else if (mutt_strcmp("-----END PGP MESSAGE-----\n", buffer) == 0)
++    else if (mutt_strcmp("-----END PGP MESSAGE-----\n", buffer) == 0 ||
++	     mutt_strcmp("-----END PGP MESSAGE-----\r\n", buffer) == 0)
+       fputs ("-----END PGP SIGNATURE-----\n", fp);
+     else
+       fputs (buffer, fp);
diff -urN mutt-devel/files/patch-smime-self mutt-devel-1.5.21-ja.2/files/patch-smime-self
--- mutt-devel/files/patch-smime-self	1970-01-01 09:00:00.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/patch-smime-self	2012-07-22 18:15:04.000000000 +0900
@@ -0,0 +1,66 @@
+Base: http://descolada.dartmouth.edu/mutt/patch-1.5.4+-ow.smime-encrypt-self.2
+--- crypt.c	7 Mar 2003 08:23:27 -0000	3.17
++++ crypt.c	7 May 2003 14:57:00 -0000
+@@ -246,8 +246,18 @@
+     if ((WithCrypto & APPLICATION_SMIME)
+         && (msg->security & APPLICATION_SMIME))
+     {
+-      if (!(tmp_pbody = crypt_smime_build_smime_entity (tmp_smime_pbody,
+-                                                        keylist)))
++	   char *new_keylist = keylist;
++
++		 if (SmimeDefaultKey && query_quadoption(OPT_SMIMEENCRYPTSELF, _("Encrypt message to S/MIME Default Key also?")) == M_YES)
++		 {
++			int size = mutt_strlen(keylist) + mutt_strlen (SmimeDefaultKey) + 2; /* +1 for NULL, +1 for \n */
++			new_keylist = safe_malloc(size);
++			snprintf(new_keylist, size, "%s%s\n", keylist, SmimeDefaultKey);
++	   }
++		 
++	  tmp_pbody = crypt_smime_build_smime_entity (tmp_smime_pbody, new_keylist);
++	  safe_free((void **)&new_keylist);
++	  if (!tmp_pbody)
+       {
+ 	/* signed ? free it! */
+ 	return (-1);
+--- init.h.orig	2009-02-06 13:43:14.000000000 +0100
++++ init.h	2009-02-06 13:46:53.000000000 +0100
+@@ -1957,6 +1957,11 @@
+   ** not used.
+   ** (S/MIME only)
+   */
++  { "smime_encrypt_self",	DT_QUAD,	 R_NONE, OPT_SMIMEENCRYPTSELF, 1 },
++  /*
++  ** .pp
++  ** Encrypt the message to smime_default_key too.
++  */
+   { "smime_encrypt_with",	DT_STR,	 R_NONE, UL &SmimeCryptAlg, 0 },
+   /*
+   ** .pp
+diff -u -d -b -B -r3.18 mutt.h
+--- mutt.h.orig	Thu Nov  6 08:15:51 2003
++++ mutt.h	Thu Nov  6 08:16:43 2003
+@@ -275,6 +275,7 @@
+   OPT_DELETE,
+   OPT_FORWEDIT,
+   OPT_INCLUDE,
++  OPT_SMIMEENCRYPTSELF,
+   OPT_MFUPTO,
+   OPT_MIMEFWD,
+   OPT_MIMEFWDREST,
+--- contrib/smime.rc.orig	Sat Mar  2 13:11:35 2002
++++ contrib/smime.rc	Sat Oct 25 17:56:28 2003
+@@ -23,9 +23,12 @@
+ 
+ # The (default) keyfile for signing/decrypting.  Uncomment the following
+ # line and replace the keyid with your own.
+-set smime_default_key="12345678.0"
++# set smime_default_key="12345678.0"
++# Uncomment the following line in addition to the one above, if you want that
++# all encrypted messages are also encrypted with your default key.
++# set smime_encrypt_self = yes
+ 
+-# Uncommen to make mutt ask what key to use when trying to decrypt a message.
++# Uncomment to make mutt ask what key to use when trying to decrypt a message.
+ # It will use the default key above (if that was set) else.
+ # unset smime_decrypt_use_default_key
+ 
diff -urN mutt-devel/files/patch-smime-sender mutt-devel-1.5.21-ja.2/files/patch-smime-sender
--- mutt-devel/files/patch-smime-sender	1970-01-01 09:00:00.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/patch-smime-sender	2012-07-22 18:15:04.000000000 +0900
@@ -0,0 +1,54 @@
+--- commands.c.orig	Thu Mar 20 20:37:21 2003
++++ commands.c	Thu Mar 20 20:40:29 2003
+@@ -178,7 +178,7 @@
+     {
+       if (cur->security & GOODSIGN)
+       {
+-	if (!crypt_smime_verify_sender(cur))
++	if (option(OPTSMIMENOSENDER) || !crypt_smime_verify_sender(cur))
+ 	  mutt_message ( _("S/MIME signature successfully verified."));
+ 	else
+ 	  mutt_error ( _("S/MIME certificate owner does not match sender."));
+--- init.h.orig2	Fri May 31 10:14:05 2002
++++ init.h	Fri May 31 10:54:55 2002
+@@ -1435,6 +1435,15 @@
+   ** This flag controls wether you want to be asked to enter a label for a certificate
+   ** about to be added to the database or not. It is set by default.
+   */
++  { "smime_dont_check_sender",	DT_BOOL, R_NONE, OPTSMIMENOSENDER, 0 },
++  /*
++  ** .pp
++  ** This flag controls wether you want the skip the check for the sender's
++  ** email address against the email address stored in the certificate. 
++  ** This can be useful if most of your email senders use SMIMEv3 which no
++  ** longer needs email-addresses as part of the certificates.
++  ** It is not set by default.
++  */
+   { "smime_decrypt_use_default_key",	DT_BOOL, R_NONE, OPTSDEFAULTDECRYPTKEY, 1 },
+   /*
+   ** .pp
+--- mutt.h.orig2	Fri May 31 10:14:06 2002
++++ mutt.h	Fri May 31 10:24:03 2002
+@@ -453,6 +453,7 @@
+ #ifdef HAVE_SMIME
+   OPTSMIMEISDEFAULT,
+   OPTASKCERTLABEL,
++  OPTSMIMENOSENDER,
+   OPTSDEFAULTDECRYPTKEY,
+ #endif
+ #ifdef HAVE_PGP
+--- contrib/smime.rc.orig	Sat Oct 25 17:57:35 2003
++++ contrib/smime.rc	Sat Oct 25 17:57:35 2003
+@@ -6,8 +6,11 @@
+ # will be the default method unless the following option is set
+ set smime_is_default
+ 
+-# Uncoment this if you don't want to set labels for certificates you add.
++# Uncomment this if you don't want to set labels for certificates you add.
+ # unset smime_ask_cert_label
++
++# Uncomment this if you don't want to check for sender's email address
++# set smime_dont_check_sender = yes
+ 
+ # Passphrase expiration
+ set smime_timeout=300
diff -urN mutt-devel/files/patch-threadcomplete mutt-devel-1.5.21-ja.2/files/patch-threadcomplete
--- mutt-devel/files/patch-threadcomplete	1970-01-01 09:00:00.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/files/patch-threadcomplete	2013-01-02 23:57:28.000000000 +0900
@@ -0,0 +1,37 @@
+--- mutt.h.orig2	Mon Sep  6 09:24:17 2004
++++ mutt.h	Mon Sep  6 09:27:04 2004
+@@ -212,6 +212,7 @@
+   M_LIMIT,
+   M_EXPIRED,
+   M_SUPERSEDED,
++  M_THREADCOMPLETE,
+ 
+   /* actions for mutt_pattern_comp/mutt_pattern_exec */
+   M_AND,
+--- pattern.c.orig2	Sun Sep 18 15:17:46 2005
++++ pattern.c	Sun Sep 18 15:19:48 2005
+@@ -54,6 +54,7 @@
+ }
+ Flags[] =
+ {
++  { 'a', M_THREADCOMPLETE,	0,		NULL },
+   { 'A', M_ALL,			0,		NULL },
+   { 'b', M_BODY,		M_FULL_MSG,	eat_regexp },
+   { 'B', M_WHOLE_MSG,		M_FULL_MSG,	eat_regexp },
+@@ -1139,6 +1140,16 @@
+                                              2, h->env->to, h->env->cc));
+     case M_LIST:	/* known list, subscribed or not */
+       return (pat->not ^ mutt_is_list_cc (pat->alladdr, h->env->to, h->env->cc));
++    case M_THREADCOMPLETE:
++      { static pattern_t tmp;
++        static short pattern_set = 0;
++        if(! pattern_set) {
++          memset (&tmp, 0, sizeof (tmp));
++          tmp.op = M_TAG;
++          pattern_set = 1;
++        }
++        return (pat->not ^ (h->env && match_threadcomplete(&tmp, flags, ctx, h->thread, 1, 1, 1, 1)));
++      } 
+     case M_SUBSCRIBED_LIST:
+       return (pat->not ^ mutt_is_list_recipient (pat->alladdr, h->env->to, h->env->cc));
+     case M_PERSONAL_RECIP:
diff -urN mutt-devel/pkg-descr mutt-devel-1.5.21-ja.2/pkg-descr
--- mutt-devel/pkg-descr	2012-07-14 22:54:48.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/pkg-descr	2012-11-27 10:54:06.000000000 +0900
@@ -1,9 +1,16 @@
-Mutt is a small but very powerful text-based MIME mail client.  Mutt
-is highly configurable, and is well suited to the mail power user with
-advanced features like key bindings, keyboard macros, mail threading,
-regular expression searches and a powerful pattern matching language
-for selecting groups of messages.
+Mutt -- "The Mongrel of Mail User Agents" (part Elm, part Pine, part mh,
+part slrn, part everything else) is an interactive screen-oriented mailer
+program that supersedes Elm, Pine, mail and mailx.
 
+Features include color support, message threading, MIME support (including
+RFC1522 support for encoded headers), customizable key bindings, POP3,
+Delivery Status Notification (DSN) support, and PGP/MIME.
+
+WWW: http://www.mutt.org/
+Mutt User Information:	http://www.math.fu-berlin.de/~guckes/mutt/
+
+	-- David	(obrien@cs.ucdavis.edu)
+-----------------------------------------------------------------------
 This is japanized development version.
 see /usr/local/share/doc/mutt/README.JA-PATCH
 
diff -urN mutt-devel/pkg-plist mutt-devel-1.5.21-ja.2/pkg-plist
--- mutt-devel/pkg-plist	2012-07-14 22:54:48.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/pkg-plist	1970-01-01 09:00:00.000000000 +0900
@@ -1,118 +0,0 @@
-bin/flea
-bin/mutt
-bin/mutt_dotlock
-bin/muttbug
-bin/pgpewrap
-bin/pgpring
-bin/smime_keys
-@unexec if cmp -s %D/etc/Muttrc.dist %D/etc/Muttrc; then rm -f %D/etc/Muttrc; fi
-etc/Muttrc.dist
-etc/mime.types.dist
-%%PORTDOCS%%%%DOCSDIR%%/COPYRIGHT
-%%PORTDOCS%%%%DOCSDIR%%/ChangeLog
-%%PORTDOCS%%%%DOCSDIR%%/GPL
-%%PORTDOCS%%%%DOCSDIR%%/INSTALL
-%%PORTDOCS%%%%DOCSDIR%%/INSTALL.JA-PATCH.ja
-%%PORTDOCS%%%%DOCSDIR%%/NEWS
-%%PORTDOCS%%%%DOCSDIR%%/PGP-Notes.txt
-%%PORTDOCS%%%%DOCSDIR%%/README
-%%PORTDOCS%%%%DOCSDIR%%/README.JA-PATCH.ja
-%%PORTDOCS%%%%DOCSDIR%%/README.SECURITY
-%%PORTDOCS%%%%DOCSDIR%%/README.SSL
-%%PORTDOCS%%%%DOCSDIR%%/TODO
-%%PORTDOCS%%%%DOCSDIR%%/applying-patches.txt
-%%PORTDOCS%%%%DOCSDIR%%/devel-notes.txt
-%%PORTDOCS%%%%DOCSDIR%%/manual-ja-patch.ja.txt
-%%PORTDOCS%%%%DOCSDIR%%/usage-japanese.ja.txt
-%%PORTDOCS%%%%DOCSDIR%%/INSTALL.JA-PATCH.ja.html
-%%PORTDOCS%%%%DOCSDIR%%/README.JA-PATCH.ja.html
-%%PORTDOCS%%%%DOCSDIR%%/advancedusage.html
-%%PORTDOCS%%%%DOCSDIR%%/configuration.html
-%%PORTDOCS%%%%DOCSDIR%%/gettingstarted.html
-%%PORTDOCS%%%%DOCSDIR%%/index.html
-%%PORTDOCS%%%%DOCSDIR%%/intro.html
-%%PORTDOCS%%%%DOCSDIR%%/manual.html
-%%PORTDOCS%%%%DOCSDIR%%/mimesupport.html
-%%PORTDOCS%%%%DOCSDIR%%/miscellany.html
-%%PORTDOCS%%%%DOCSDIR%%/reference.html
-%%PORTDOCS%%%%DOCSDIR%%/manual-ja-patch.ja.html
-%%PORTDOCS%%%%DOCSDIR%%/usage-japanese.ja.html
-%%PORTDOCS%%%%DOCSDIR%%/manual.txt
-%%PORTDOCS%%%%DOCSDIR%%/manual_ja.html
-%%PORTDOCS%%%%DOCSDIR%%/manual_ja.sgml
-%%PORTDOCS%%%%DOCSDIR%%/manual_ja.tex
-%%PORTDOCS%%%%DOCSDIR%%/manual_ja.txt
-%%PORTDOCS%%%%DOCSDIR%%/manual.ja.html
-%%PORTDOCS%%%%DOCSDIR%%/manual.ja.sgml
-%%PORTDOCS%%%%DOCSDIR%%/manual.ja.txt
-%%PORTDOCS%%%%DOCSDIR%%/optionalfeatures.html
-%%PORTDOCS%%%%DOCSDIR%%/patch-notes.txt
-%%PORTDOCS%%%%DOCSDIR%%/samples/Mush.rc
-%%PORTDOCS%%%%DOCSDIR%%/samples/Pine.rc
-%%PORTDOCS%%%%DOCSDIR%%/samples/Tin.rc
-%%PORTDOCS%%%%DOCSDIR%%/samples/ca-bundle.crt
-%%PORTDOCS%%%%DOCSDIR%%/samples/gpg.rc
-%%PORTDOCS%%%%DOCSDIR%%/samples/iconv/iconv.aix-3.2.5.rc
-%%PORTDOCS%%%%DOCSDIR%%/samples/iconv/iconv.aix-4.1.5.rc
-%%PORTDOCS%%%%DOCSDIR%%/samples/iconv/iconv.aix-4.2.0.rc
-%%PORTDOCS%%%%DOCSDIR%%/samples/iconv/iconv.aix-4.3.2.rc
-%%PORTDOCS%%%%DOCSDIR%%/samples/iconv/iconv.freebsd-3.3.rc
-%%PORTDOCS%%%%DOCSDIR%%/samples/iconv/iconv.glibc-2.1.3.rc
-%%PORTDOCS%%%%DOCSDIR%%/samples/iconv/iconv.glibc-2.1.90.rc
-%%PORTDOCS%%%%DOCSDIR%%/samples/iconv/iconv.hpux-10.01.rc
-%%PORTDOCS%%%%DOCSDIR%%/samples/iconv/iconv.hpux-10.20.rc
-%%PORTDOCS%%%%DOCSDIR%%/samples/iconv/iconv.hpux-11.00.rc
-%%PORTDOCS%%%%DOCSDIR%%/samples/iconv/iconv.irix-6.5.rc
-%%PORTDOCS%%%%DOCSDIR%%/samples/iconv/iconv.osf1-4.0a.rc
-%%PORTDOCS%%%%DOCSDIR%%/samples/iconv/iconv.osf1-4.0d.rc
-%%PORTDOCS%%%%DOCSDIR%%/samples/iconv/iconv.solaris-2.4.rc
-%%PORTDOCS%%%%DOCSDIR%%/samples/iconv/iconv.solaris-2.5.1.rc
-%%PORTDOCS%%%%DOCSDIR%%/samples/iconv/iconv.solaris-2.6-cjk.rc
-%%PORTDOCS%%%%DOCSDIR%%/samples/iconv/iconv.solaris-2.6.rc
-%%PORTDOCS%%%%DOCSDIR%%/samples/iconv/iconv.solaris-2.7.rc
-%%PORTDOCS%%%%DOCSDIR%%/samples/pgp2.rc
-%%PORTDOCS%%%%DOCSDIR%%/samples/pgp5.rc
-%%PORTDOCS%%%%DOCSDIR%%/samples/pgp6.rc
-%%PORTDOCS%%%%DOCSDIR%%/samples/sample.mailcap
-%%PORTDOCS%%%%DOCSDIR%%/samples/sample.muttrc
-%%PORTDOCS%%%%DOCSDIR%%/samples/sample.muttrc-tlr
-%%PORTDOCS%%%%DOCSDIR%%/samples/smime.rc
-%%PORTDOCS%%%%DOCSDIR%%/samples/smime_keys_test.pl
-%%PORTDOCS%%%%DOCSDIR%%/samples/colors.default
-%%PORTDOCS%%%%DOCSDIR%%/samples/colors.linux
-%%PORTDOCS%%%%DOCSDIR%%/samples/mutt_xtitle
-%%PORTDOCS%%%%DOCSDIR%%/security.html
-%%PORTDOCS%%%%DOCSDIR%%/smime-notes.txt
-%%PORTDOCS%%%%DOCSDIR%%/tuning.html
-%%NLS%%share/locale/bg/LC_MESSAGES/mutt.mo
-%%NLS%%share/locale/ca/LC_MESSAGES/mutt.mo
-%%NLS%%share/locale/cs/LC_MESSAGES/mutt.mo
-%%NLS%%share/locale/da/LC_MESSAGES/mutt.mo
-%%NLS%%share/locale/de/LC_MESSAGES/mutt.mo
-%%NLS%%share/locale/el/LC_MESSAGES/mutt.mo
-%%NLS%%share/locale/eo/LC_MESSAGES/mutt.mo
-%%NLS%%share/locale/es/LC_MESSAGES/mutt.mo
-%%NLS%%share/locale/et/LC_MESSAGES/mutt.mo
-%%NLS%%share/locale/eu/LC_MESSAGES/mutt.mo
-%%NLS%%share/locale/fr/LC_MESSAGES/mutt.mo
-%%NLS%%share/locale/ga/LC_MESSAGES/mutt.mo
-%%NLS%%share/locale/gl/LC_MESSAGES/mutt.mo
-%%NLS%%share/locale/hu/LC_MESSAGES/mutt.mo
-%%NLS%%share/locale/id/LC_MESSAGES/mutt.mo
-%%NLS%%share/locale/it/LC_MESSAGES/mutt.mo
-%%NLS%%share/locale/ja/LC_MESSAGES/mutt.mo
-%%NLS%%share/locale/ko/LC_MESSAGES/mutt.mo
-%%NLS%%share/locale/lt/LC_MESSAGES/mutt.mo
-%%NLS%%share/locale/nl/LC_MESSAGES/mutt.mo
-%%NLS%%share/locale/pl/LC_MESSAGES/mutt.mo
-%%NLS%%share/locale/pt_BR/LC_MESSAGES/mutt.mo
-%%NLS%%share/locale/ru/LC_MESSAGES/mutt.mo
-%%NLS%%share/locale/sk/LC_MESSAGES/mutt.mo
-%%NLS%%share/locale/sv/LC_MESSAGES/mutt.mo
-%%NLS%%share/locale/tr/LC_MESSAGES/mutt.mo
-%%NLS%%share/locale/uk/LC_MESSAGES/mutt.mo
-%%NLS%%share/locale/zh_CN/LC_MESSAGES/mutt.mo
-%%NLS%%share/locale/zh_TW/LC_MESSAGES/mutt.mo
-%%PORTDOCS%%@dirrm %%DOCSDIR%%/samples/iconv
-%%PORTDOCS%%@dirrm %%DOCSDIR%%/samples
-%%PORTDOCS%%@dirrm %%DOCSDIR%%
diff -urN mutt-devel/scripts/generate-plist mutt-devel-1.5.21-ja.2/scripts/generate-plist
--- mutt-devel/scripts/generate-plist	1970-01-01 09:00:00.000000000 +0900
+++ mutt-devel-1.5.21-ja.2/scripts/generate-plist	2013-04-08 00:29:11.000000000 +0900
@@ -0,0 +1,189 @@
+#!/bin/sh
+#
+# $FreeBSD: ports/mail/mutt/scripts/generate-plist,v 1.2 2012/11/17 05:59:06 svnexp Exp $
+#
+# set -x
+
+trap ' cleanup ' 0
+trap ' echo_signal; exit 1' 1 2 3 15
+
+tmp_first=$(mktemp ${WRKDIR:=/tmp}/.plist-first.XXXXXXXXXX)
+tmp_last=$(mktemp ${WRKDIR}/.plist-last.XXXXXXXXXX)
+
+cleanup() {
+  rm -f $tmp_first $tmp_last
+}
+
+echo_signal() {
+  echo "Got Signal -- aborting `basename $0`"
+}
+
+PATH=/bin:/usr/bin
+
+cat > $tmp_first <<EOF
+bin/flea
+bin/mutt
+bin/muttbug
+bin/mutt_dotlock
+bin/pgpewrap
+bin/pgpring
+bin/smime_keys
+EOF
+
+if [ "$MUTT_NLS" = "yes" ]; then
+  cat >> $tmp_first <<EOF
+share/locale/bg/LC_MESSAGES/mutt.mo
+share/locale/ca/LC_MESSAGES/mutt.mo
+share/locale/cs/LC_MESSAGES/mutt.mo
+share/locale/da/LC_MESSAGES/mutt.mo
+share/locale/de/LC_MESSAGES/mutt.mo
+share/locale/el/LC_MESSAGES/mutt.mo
+share/locale/eo/LC_MESSAGES/mutt.mo
+share/locale/es/LC_MESSAGES/mutt.mo
+share/locale/et/LC_MESSAGES/mutt.mo
+share/locale/eu/LC_MESSAGES/mutt.mo
+share/locale/fr/LC_MESSAGES/mutt.mo
+share/locale/ga/LC_MESSAGES/mutt.mo
+share/locale/gl/LC_MESSAGES/mutt.mo
+share/locale/hu/LC_MESSAGES/mutt.mo
+share/locale/id/LC_MESSAGES/mutt.mo
+share/locale/it/LC_MESSAGES/mutt.mo
+share/locale/ja/LC_MESSAGES/mutt.mo
+share/locale/ko/LC_MESSAGES/mutt.mo
+share/locale/lt/LC_MESSAGES/mutt.mo
+share/locale/nl/LC_MESSAGES/mutt.mo
+share/locale/pl/LC_MESSAGES/mutt.mo
+share/locale/pt_BR/LC_MESSAGES/mutt.mo
+share/locale/ru/LC_MESSAGES/mutt.mo
+share/locale/sk/LC_MESSAGES/mutt.mo
+share/locale/sv/LC_MESSAGES/mutt.mo
+share/locale/tr/LC_MESSAGES/mutt.mo
+share/locale/uk/LC_MESSAGES/mutt.mo
+share/locale/zh_CN/LC_MESSAGES/mutt.mo
+share/locale/zh_TW/LC_MESSAGES/mutt.mo
+EOF
+fi
+
+if [ "$MUTT_PORTDOCS" = "yes" ]; then
+  cat >> $tmp_first <<EOF
+%%DOCSDIR%%/ABOUT-NLS
+%%DOCSDIR%%/COPYRIGHT
+%%DOCSDIR%%/ChangeLog
+%%DOCSDIR%%/GPL
+%%DOCSDIR%%/INSTALL
+%%DOCSDIR%%/NEWS
+%%DOCSDIR%%/PGP-Notes.txt
+%%DOCSDIR%%/README
+%%DOCSDIR%%/README.SECURITY
+%%DOCSDIR%%/README.SSL
+%%DOCSDIR%%/TODO
+%%DOCSDIR%%/applying-patches.txt
+%%DOCSDIR%%/devel-notes.txt
+%%DOCSDIR%%/language.txt
+%%DOCSDIR%%/language50.txt
+%%DOCSDIR%%/manual.txt
+%%DOCSDIR%%/patch-notes.txt
+%%DOCSDIR%%/smime-notes.txt
+%%DOCSDIR%%/INSTALL.JA-PATCH.ja
+%%DOCSDIR%%/README.JA-PATCH.ja
+%%DOCSDIR%%/manual-ja-patch.ja.txt
+%%DOCSDIR%%/manual.ja.sgml
+%%DOCSDIR%%/manual.ja.txt
+%%DOCSDIR%%/manual_ja.sgml
+%%DOCSDIR%%/manual_ja.tex
+%%DOCSDIR%%/manual_ja.txt
+%%DOCSDIR%%/usage-japanese.ja.txt
+%%EXAMPLESDIR%%/Mush.rc
+%%EXAMPLESDIR%%/Pine.rc
+%%EXAMPLESDIR%%/Tin.rc
+%%EXAMPLESDIR%%/colors.default
+%%EXAMPLESDIR%%/colors.linux
+%%EXAMPLESDIR%%/gpg.rc
+%%EXAMPLESDIR%%/mutt_xtitle
+%%EXAMPLESDIR%%/pgp2.rc
+%%EXAMPLESDIR%%/pgp6.rc
+%%EXAMPLESDIR%%/sample.mailcap
+%%EXAMPLESDIR%%/sample.muttrc
+%%EXAMPLESDIR%%/sample.muttrc-tlr
+%%EXAMPLESDIR%%/smime.rc
+%%EXAMPLESDIR%%/smime_keys_test.pl
+%%EXAMPLESDIR%%/UTF-8-CJK
+%%EXAMPLESDIR%%/UTF-8.cent62.patch
+%%EXAMPLESDIR%%/UTF-9.src
+%%EXAMPLESDIR%%/makesample.pl
+%%EXAMPLESDIR%%/mutt-en.rc
+%%EXAMPLESDIR%%/mutt-ja.rc
+%%EXAMPLESDIR%%/mutt1521-centos62.spec
+%%EXAMPLESDIR%%/mutt1521-centos63.spec
+%%EXAMPLESDIR%%/sample.muttrc-tt
+%%EXAMPLESDIR%%/translate_ambiguous.sh
+%%EXAMPLESDIR%%/unicodedata.txt
+%%EXAMPLESDIR%%/utf9test.c
+%%EXAMPLESDIR%%/iconv/iconv.aix-3.2.5.rc
+%%EXAMPLESDIR%%/iconv/iconv.aix-4.1.5.rc
+%%EXAMPLESDIR%%/iconv/iconv.aix-4.2.0.rc
+%%EXAMPLESDIR%%/iconv/iconv.aix-4.3.2.rc
+%%EXAMPLESDIR%%/iconv/iconv.freebsd-3.3.rc
+%%EXAMPLESDIR%%/iconv/iconv.glibc-2.1.3.rc
+%%EXAMPLESDIR%%/iconv/iconv.glibc-2.1.90.rc
+%%EXAMPLESDIR%%/iconv/iconv.hpux-10.01.rc
+%%EXAMPLESDIR%%/iconv/iconv.hpux-10.20.rc
+%%EXAMPLESDIR%%/iconv/iconv.hpux-11.00.rc
+%%EXAMPLESDIR%%/iconv/iconv.irix-6.5.rc
+%%EXAMPLESDIR%%/iconv/iconv.osf1-4.0a.rc
+%%EXAMPLESDIR%%/iconv/iconv.osf1-4.0d.rc
+%%EXAMPLESDIR%%/iconv/iconv.solaris-2.4.rc
+%%EXAMPLESDIR%%/iconv/iconv.solaris-2.5.1.rc
+%%EXAMPLESDIR%%/iconv/iconv.solaris-2.6-cjk.rc
+%%EXAMPLESDIR%%/iconv/iconv.solaris-2.6.rc
+%%EXAMPLESDIR%%/iconv/iconv.solaris-2.7.rc
+EOF
+
+  if [ "$MUTT_NNTP" = "yes" ]; then
+    echo "%%DOCSDIR%%/ChangeLog.nntp" >> $tmp_first
+  fi
+
+  if [ "$MUTT_HTML" = "yes" ]; then
+    echo "%%DOCSDIR%%/html/advancedusage.html" >> $tmp_first
+    echo "%%DOCSDIR%%/html/configuration.html" >> $tmp_first
+    echo "%%DOCSDIR%%/html/gettingstarted.html" >> $tmp_first
+    echo "%%DOCSDIR%%/html/index.html" >> $tmp_first
+    echo "%%DOCSDIR%%/html/intro.html" >> $tmp_first
+    echo "%%DOCSDIR%%/html/manual.html" >> $tmp_first
+    echo "%%DOCSDIR%%/html/mimesupport.html" >> $tmp_first
+    echo "%%DOCSDIR%%/html/miscellany.html" >> $tmp_first
+    echo "%%DOCSDIR%%/html/optionalfeatures.html" >> $tmp_first
+    echo "%%DOCSDIR%%/html/reference.html" >> $tmp_first
+    echo "%%DOCSDIR%%/html/security.html" >> $tmp_first
+    echo "%%DOCSDIR%%/html/tuning.html" >> $tmp_first
+    echo "%%DOCSDIR%%/html/INSTALL.JA-PATCH.ja.html" >> $tmp_first
+    echo "%%DOCSDIR%%/html/README.JA-PATCH.ja.html" >> $tmp_first
+    echo "%%DOCSDIR%%/html/INSTALL.JA-PATCH.ja.html" >> $tmp_first
+    echo "%%DOCSDIR%%/html/README.JA-PATCH.ja.html" >> $tmp_first
+    echo "%%DOCSDIR%%/html/manual-ja-patch.ja.html" >> $tmp_first
+    echo "%%DOCSDIR%%/html/manual.ja.html" >> $tmp_first
+    echo "%%DOCSDIR%%/html/manual_ja.html" >> $tmp_first
+    echo "%%DOCSDIR%%/html/usage-japanese.ja.html" >> $tmp_first
+    echo "%%DOCSDIR%%/html/manual-ja-patch.ja.html" >> $tmp_first
+    echo "%%DOCSDIR%%/html/usage-japanese.ja.html" >> $tmp_first
+    if [ "$MUTT_COMPRESSED_FOLDERS" = "yes" ]; then
+      echo "%%DOCSDIR%%/html/compressed-folders.html" >> $tmp_first
+    fi
+    echo "@dirrm %%DOCSDIR%%/html" >> $tmp_last
+  fi
+  cat >> $tmp_last <<EOF
+@dirrm %%EXAMPLESDIR%%/iconv
+@dirrm %%EXAMPLESDIR%%
+@dirrm %%DOCSDIR%%
+EOF
+fi
+
+sort -u $tmp_first
+
+cat<<EOF
+@unexec if cmp -s %D/etc/Muttrc.dist %D/etc/Muttrc; then rm -f %D/etc/Muttrc; fi
+etc/Muttrc.dist
+@exec if [ ! -f %D/etc/Muttrc ]; then install -m 644 %D/etc/Muttrc.dist %D/etc/Muttrc; fi
+EOF
+
+cat $tmp_last
>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130512111120.56021110666>