commit 6f59b5e2a7f70b07492562fa5b543625bde9dcfb
parent f36635d0e291997b4c2396f3b088acd018c9957a
Author: Jaromil <jaromil@dyne.org>
Date: Thu, 23 Mar 2017 12:54:07 +0100
mutt config generation moved from update to runtime
all mutt configs are regenerated by x_mutt() on each call
Diffstat:
M | src/jaro | | | 1 | - |
M | src/zlibs/filters | | | 148 | ------------------------------------------------------------------------------- |
M | src/zlibs/mutt | | | 157 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------- |
3 files changed, 140 insertions(+), 166 deletions(-)
diff --git a/src/jaro b/src/jaro
@@ -625,7 +625,6 @@ main() {
}
init_inbox
update_filters
- update_mutt
update_sieve
update_notmuch
notice "Initialization completed in $MAILDIRS"
diff --git a/src/zlibs/filters b/src/zlibs/filters
@@ -477,154 +477,6 @@ filter_maildir() {
return 0
}
-######
-# MUTT
-
-update_mutt() {
- fn update_mutt
- req=(MAILDIRS)
- ckreq
-
- act "updating Mutt settings"
- func "Mutt directory: $MAILDIRS/.mutt"
-
- ${=mkdir} "$MAILDIRS/.mutt"
- ${=mkdir} "$MAILDIRS/.mutt"/cache
- rm -f "$MAILDIRS/.mutt"/rc
-
- gpgkey=""
- [[ -f $MAILDIRS/.pass/.gpg-id ]] || {
- # detect the default gpg key to always encrypt also to self
- # update: do not re-encrypt if already done
- [[ -r $HOME/.gnupg/gpg.conf ]] && {
- gpgkey=`awk '/^default-key/ { print $2 }' $HOME/.gnupg/gpg.conf`
- act "default GPG key configured: $gpgkey"
- }
- }
- cat<<EOF > "$MAILDIRS/.mutt"/rc
-#### Mutt config automatically generated by Jaro Mail
-### do not edit: this file is overwritten by jaro update
-### put your customizations in \$MAILDIRS/Identity.txt
-
-unset use_domain
-set folder = '$MAILDIRS'
-set spoolfile = '$MAILDIRS/known/'
-set record = '$MAILDIRS/sent/'
-set postponed= '$MAILDIRS/postponed/'
-set tmpdir = '$MAILDIRS/.mutt/cache'
-set sendmail = "$WORKDIR/bin/jaro -q queue"
-set header_cache= '$MAILDIRS/.mutt/cache'
-set maildir_header_cache_verify=no
-set editor = "$WORKDIR/bin/jaro -q edit"
-set mailcap_path = "$MAILDIRS/.mutt/mailcap:$MAILDIRS/mailcap:$HOME/.mailcap:/etc/mailcap:/etc/mailcap:/usr/etc/mailcap:/usr/local/etc/mailcap"
-
-# Little Brother Database
-set query_command = "$WORKDIR/bin/jaro -q complete '%s'"
-macro index,pager a "<pipe-message>$WORKDIR/bin/jaro -l whitelist -q learn sender<enter>" "add to whitelist everyone in the message"
-macro index,pager A "<pipe-message>$WORKDIR/bin/jaro -l whitelist -q learn all<enter>" "add all addresses in whitelist"
-macro index,pager z "<pipe-message>$WORKDIR/bin/jaro -l blacklist -q learn sender<enter>" "add sender to blacklist"
-
-
-# specific configuration files
-source '$WORKDIR/.mutt/gpg'
-source '$WORKDIR/.mutt/crypto'
-source '$WORKDIR/.mutt/general'
-source '$WORKDIR/.mutt/formats'
-source '$WORKDIR/.mutt/keybindings'
-source '$WORKDIR/.mutt/colors'
-source '$MAILDIRS/Identity.txt'
-
-# pointer to password tempfile and dynamic settings
-# must be before mboxes to set folder on imap peek
-source '$MAILDIRS/.mutt/muttpass'
-
-# mailboxes in order of priority
-source '$MAILDIRS/.mutt/mboxes'
-
-# extra settings for mutt-kz (notmuch enabled)
-source '$MAILDIRS/.mutt/notmuch'
-
-# opmsg support
-source '$MAILDIRS/.mutt/opmsg'
-EOF
-
-
- [[ "$gpgkey" = "" ]] || {
- # gpg special settings
-
- cat <<EOF >> "$MAILDIRS/.mutt"/rc
-## GnuPG specific settings
-# create a pgp/mime encrypted attachment
-set pgp_encrypt_only_command="gpgewrap gpg --batch --quiet --no-verbose --output - --encrypt --textmode --armor --always-trust --encrypt-to $gpgkey -- -r %r -- '%f'"
-
-# create a pgp/mime encrypted and signed attachment
-set pgp_encrypt_sign_command="gpgewrap gpg %?p?--passphrase-fd 0? --batch --quiet --no-verbose --textmode --output - --encrypt --sign %?a?-u %a? --armor --always-trust --encrypt-to $gpgkey -- -r %r -- '%f'"
-
-## end of Jaro Mail generated muttrc
-####################################
-EOF
- }
-
- # MUTT MAILCAP
-
- # charset conversion
- cat <<EOF > $MAILDIRS/.mutt/mailcap
-text/plain; iconv -f iso-8859-1 -t utf-8; test=charset=%{charset} \
- && test x`echo \"$charset\" | tr a-z A-Z` = xISO-8859-1; copiousoutput
-text/plain; cat %s
-EOF
-
- # HTML conversion
- wwwtext=w3m
- if command -v elinks > /dev/null; then
- cat <<EOF >> $MAILDIRS/.mutt/mailcap
-text/html; elinks -dump -dump-charset %{charset} %s; nametemplate=%s.html; copiousoutput
-EOF
- elif command -v w3m > /dev/null; then
- cat <<EOF >> $MAILDIRS/.mutt/mailcap
-text/html; w3m -I %{charset} -T text/html %s; nametemplate=%s.html; copiousoutput
-EOF
- elif command -v lynx > /dev/null; then
- cat <<EOF >> $MAILDIRS/.mutt/mailcap
-text/html; lynx -dump -assume_charset=%{charset} %s; nametemplate=%s.html; copiousoutput
-EOF
- fi
-
- command -v vcal > /dev/null && {
- # VCAL conversion
- cat <<EOF >> $MAILDIRS/.mutt/mailcap
-text/calendar; vcal --all %s; nametemplate=%s.vcal; copiousoutput
-EOF
- }
-
- { test -r "${MAILDIRS}/Applications.txt" } && {
-
- # here is the tweak to open attachments
- # with Mutt without blocking it (fork)
-
- apptypes=`cat "${MAILDIRS}/Applications.txt"`
- for t in ${(f)apptypes}; do
- eval `print $t | awk '
- { print "_type=" $1 "; _app=" $2 ";" }'`
- cat <<EOF >> $MAILDIRS/.mutt/mailcap
-${_type}; a="${MAILDIRS}/tmp" && f=\`basename %s\` && rm -f "\$a"/"\$f" && cp %s "\$a"/"\$f" && ${_app} "\$a"/"\$f"
-EOF
- done
- cat <<EOF >> $MAILDIRS/.mutt/mailcap
-application/*; a="${MAILDIRS}/tmp" && f=\`basename %s\` && rm -f "\$a"/"\$f" && cp %s "\$a"/"\$f" && jaro preview "\$a"/"\$f"
-EOF
- } # Applications.txt
-
- # this one is empty and sources files in temp when necessary
- rm -f "$MAILDIRS/.mutt/muttpass"
- touch "$MAILDIRS/.mutt/muttpass"
- rm -f "$MAILDIRS/.mutt/notmuch"
- touch "$MAILDIRS/.mutt/notmuch"
-
-
-
-}
-
# sieve_filter() gets an array of patterns to match and builds a long rule
# for which if they match the conditional directive they all go in one folder
diff --git a/src/zlibs/mutt b/src/zlibs/mutt
@@ -52,17 +52,78 @@ x_mutt() {
req=(MAILDIRS WORKDIR)
ckreq || return 1
- [[ -r $MAILDIRS/.mutt/rc ]] || {
- error "Jaro Mail is not yet configured."
- error "To configure, edit the files in $MAILDIRS/Accounts"
- error "Then run 'jaro update' at least once."
- return 1
- }
-
- rm -f "$MAILDIRS/.mutt/opmsg"
- touch "$MAILDIRS/.mutt/opmsg"
- opmux_path="$(command -v opmux)" && {
- cat <<EOF > "$MAILDIRS/.mutt/opmsg"
+ # main conf
+ ${=mkdir} "$MAILDIRS/.mutt"
+ ${=mkdir} "$MAILDIRS/.mutt"/cache
+ rm -f "$MAILDIRS/.mutt"/rc
+
+
+ gpgkey=""
+ [[ -f $MAILDIRS/.pass/.gpg-id ]] || {
+ # detect the default gpg key to always encrypt also to self
+ # update: do not re-encrypt if already done
+ [[ -r $HOME/.gnupg/gpg.conf ]] && {
+ gpgkey=`awk '/^default-key/ { print $2 }' $HOME/.gnupg/gpg.conf`
+ act "default GPG key configured: $gpgkey"
+ }
+ }
+
+ cat<<EOF > "$MAILDIRS/.mutt"/rc
+#### Mutt config automatically generated by Jaro Mail
+### do not edit: this file is overwritten by jaro update
+### put your customizations in \$MAILDIRS/Identity.txt
+
+unset use_domain
+set folder = '$MAILDIRS'
+set spoolfile = '$MAILDIRS/known/'
+set record = '$MAILDIRS/sent/'
+set postponed= '$MAILDIRS/postponed/'
+set tmpdir = '$MAILDIRS/.mutt/cache'
+set sendmail = "$WORKDIR/bin/jaro -q queue"
+set header_cache= '$MAILDIRS/.mutt/cache'
+set maildir_header_cache_verify=no
+set editor = "$WORKDIR/bin/jaro -q edit"
+set mailcap_path = "$MAILDIRS/.mutt/mailcap:$MAILDIRS/mailcap:$HOME/.mailcap:/etc/mailcap:/etc/mailcap:/usr/etc/mailcap:/usr/local/etc/mailcap"
+
+# Little Brother Database
+set query_command = "$WORKDIR/bin/jaro -q complete '%s'"
+macro index,pager a "<pipe-message>$WORKDIR/bin/jaro -l whitelist -q learn sender<enter>" "add to whitelist everyone in the message"
+macro index,pager A "<pipe-message>$WORKDIR/bin/jaro -l whitelist -q learn all<enter>" "add all addresses in whitelist"
+macro index,pager z "<pipe-message>$WORKDIR/bin/jaro -l blacklist -q learn sender<enter>" "add sender to blacklist"
+
+
+# specific configuration files
+source '$WORKDIR/.mutt/gpg'
+source '$WORKDIR/.mutt/crypto'
+source '$WORKDIR/.mutt/general'
+source '$WORKDIR/.mutt/formats'
+source '$WORKDIR/.mutt/keybindings'
+source '$WORKDIR/.mutt/colors'
+source '$MAILDIRS/Identity.txt'
+
+# pointer to password tempfile and dynamic settings
+# must be before mboxes to set folder on imap peek
+source '$MAILDIRS/.mutt/muttpass'
+
+# mailboxes in order of priority
+source '$MAILDIRS/.mutt/mboxes'
+
+# extra settings for mutt-kz (notmuch enabled)
+source '$MAILDIRS/.mutt/notmuch'
+
+# crypto support
+source '$MAILDIRS/.mutt/crypto'
+EOF
+
+ rm -f "$MAILDIRS/.mutt/crypto"
+ touch "$MAILDIRS/.mutt/crypto"
+ # support opmux or fallback to gpgewrap
+ cryptowrap=${$(command -v opmux):-gpgewrap}
+
+ case $cryptowrap in
+ *opmux)
+ cat <<EOF > "$MAILDIRS/.mutt/crypto"
+# Generated by JaroMail at every execution
set pgp_long_ids
set pgp_decode_command="OPMUX_MUA=mutt ${opmux_path} --passphrase-fd 0 \
@@ -81,10 +142,72 @@ set pgp_encrypt_sign_command="${opmux_path} --passphrase-fd 0 --batch \
set pgp_list_pubring_command="${opmux_path} --batch --quiet --with-colons \
--list-keys %r"
-set pgp_decryption_okay="^opmux: SUCCESS\.$"
+# set pgp_decryption_okay="^opmux: SUCCESS\.$"
+EOF
+ ;;
+ gpgewrap)
+ cat <<EOF > "$MAILDIRS/.mutt/crypto"
+# Generated by JaroMail at every execution
+# create a pgp/mime encrypted attachment
+set pgp_encrypt_only_command="gpgewrap gpg --batch --quiet --no-verbose --output - --encrypt --textmode --armor --always-trust --encrypt-to $gpgkey -- -r %r -- '%f'"
+set pgp_encrypt_sign_command="gpgewrap gpg %?p?--passphrase-fd 0? --batch --quiet --no-verbose --textmode --output - --encrypt --sign %?a?-u %a? --armor --always-trust --encrypt-to $gpgkey -- -r %r -- '%f'"
+EOF
+ ;;
+ esac
+
+ unset cryptowrap
+
+ # MUTT MAILCAP
+
+ # charset conversion
+ cat <<EOF > $MAILDIRS/.mutt/mailcap
+text/plain; iconv -f iso-8859-1 -t utf-8; test=charset=%{charset} \
+ && test x`echo \"$charset\" | tr a-z A-Z` = xISO-8859-1; copiousoutput
+text/plain; cat %s
+EOF
+
+ # HTML conversion
+ wwwtext=w3m
+ if command -v elinks > /dev/null; then
+ cat <<EOF >> $MAILDIRS/.mutt/mailcap
+text/html; elinks -dump -dump-charset %{charset} %s; nametemplate=%s.html; copiousoutput
+EOF
+ elif command -v w3m > /dev/null; then
+ cat <<EOF >> $MAILDIRS/.mutt/mailcap
+text/html; w3m -I %{charset} -T text/html %s; nametemplate=%s.html; copiousoutput
+EOF
+ elif command -v lynx > /dev/null; then
+ cat <<EOF >> $MAILDIRS/.mutt/mailcap
+text/html; lynx -dump -assume_charset=%{charset} %s; nametemplate=%s.html; copiousoutput
+EOF
+ fi
+
+ command -v vcal > /dev/null && {
+ # VCAL conversion
+ cat <<EOF >> $MAILDIRS/.mutt/mailcap
+text/calendar; vcal --all %s; nametemplate=%s.vcal; copiousoutput
EOF
}
- unset opmux_path
+
+ { test -r "${MAILDIRS}/Applications.txt" } && {
+
+ # here is the tweak to open attachments
+ # with Mutt without blocking it (fork)
+
+ apptypes=`cat "${MAILDIRS}/Applications.txt"`
+ for t in ${(f)apptypes}; do
+ eval `print $t | awk '
+ { print "_type=" $1 "; _app=" $2 ";" }'`
+ cat <<EOF >> $MAILDIRS/.mutt/mailcap
+${_type}; a="${MAILDIRS}/tmp" && f=\`basename %s\` && rm -f "\$a"/"\$f" && cp %s "\$a"/"\$f" && ${_app} "\$a"/"\$f"
+EOF
+ done
+ cat <<EOF >> $MAILDIRS/.mutt/mailcap
+application/*; a="${MAILDIRS}/tmp" && f=\`basename %s\` && rm -f "\$a"/"\$f" && cp %s "\$a"/"\$f" && jaro preview "\$a"/"\$f"
+EOF
+ } # Applications.txt
+
+
rm -f "$MAILDIRS/.mutt/notmuch"
touch "$MAILDIRS/.mutt/notmuch"
@@ -141,12 +264,15 @@ EOF
ztmp
_mboxes=$ztmpfile
+
+ # this one is empty and sources files in temp when necessary
+ rm -f "$MAILDIRS/.mutt/muttpass"
+ touch "$MAILDIRS/.mutt/muttpass"
if [[ "$subcommand" = "peek" ]]; then
func "x_mutt peek"
# when peeking don't mark unread messages as Old
# and sort date received with no threading (latest up)
# also set the spoolfile name to INBOX (imap's default)
- rm -f "$MAILDIRS/.mutt/muttpass"
sysread -o 1 <<EOF > "$MAILDIRS/.mutt/muttpass"
set imap_pass = \`$WORKDIR/bin/jaro -a ${account} askpass\`
unset mark_old
@@ -158,11 +284,8 @@ EOF
print -n "mailboxes +INBOX +priv" > $_mboxes
else
print -n "mailboxes +known +priv" > $_mboxes
- rm -f $MUTTDIR/muttpass
fi
- touch $MUTTDIR/muttpass
-
# make the mailboxes according to filters and such
for f in `cat "$MAILDIRS/Filters.txt" | awk '