MH to Mutt Configuration Integration
It's convenient to be able to use multiple mail readers and be able to switch back and forth at will. The main difficulty with this idea, however, lies in keeping configurations synchronized.
Since my transition was from MH to mutt, my approach was to leave as much configuration as possible in MH format and rely on mutt's powerful configuration commands to make the necessary transformations whenever it is run.
These code samples assume that your shell is a Bourne-compatible shell that supports the $PPID variable
Synchronizing aliases
You will find the following in my ~/.muttrc configuration file:
set alias_file="~/.muttrc.aliases"
source ~/.muttrc.aliases
set query_command=ali
# This macro will allow you to edit your MH aliases and have mutt automatically read them in
macro index ,a '<shell-escape>${VISUAL} `mhpath +`/`mhparam aliasfile`<enter>:source ~/.muttrc.aliases<enter>' "Edit MH aliases and read them back in"
You will find the following in my ~/.muttrc.aliases file:
# Share aliases with MH.
# NOTE: We have to put in parentheses in order to run multiple commands,
# and we have to echo something so that mutt doesn't complain.
# TODO: we need to fix those aliases that span multiple lines with a
# backslash at the end.
`(file=$(mhpath +)/$(mhparam aliasfile); \
if [ -r "$file" ]; then \
sed -n 's/^[[:blank:]]*\([^#:]\+\):[[:blank:]]*\(.*\)/alias \1 \2/p' \ < "$file" > ${TMP-/tmp}/.mutt-alias-$PPID; \
echo source ${TMP-/tmp}/.mutt-alias-$PPID; \
else \
echo unalias dummy; \
fi)`
`(rm -f ${TMP-/tmp}/.mutt-alias-$PPID; echo unalias dummy)`
Synchronizing Ignored Headers
You will find the following in my ~/.muttrc configuration file:
`(file=$(mhpath +)/mhl.headers; \
if [ -r "$file" ]; then \
sed -n '/^[[:blank:]]*ignores=/,/^[[:blank:]]*;/{\
s/^[[:blank:]]*ignores=//;\
s/,[[:blank:]]*\\[[:blank:]]*$//;\
s/,/ /g;\
s/^/ignore /;\
/^ignore[[:blank:]]*[[:blank:]][^;]/p;\
}' < "$file" > ${TMP-/tmp}/.mutt-ignore-$PPID; \
echo source ${TMP-/tmp}/.mutt-ignore-$PPID; \
else \
echo unalias dummy; \
fi)`
`(rm -f ${TMP-/tmp}/.mutt-ignore-$PPID; echo unalias dummy)`
Synchronizing Alternate Mailboxes
You will find the following in my ~/.muttrc configuration file:
# Share list of alternates with MH.
# NOTE: We have to put in parentheses in order to run multiple commands,
# and we have to echo something so that mutt doesn't complain.
`(file=~/.mh_profile; \
if [ -r "$file" ]; then \
sed -n '/^Alternate-Mailboxes:/{\
:a;\
s/\([.+]\)/\\\1/g;\
y/,?/|./;\
s/[*]/.*/g;\
s/[[:space:]]//g;\
s/^Alternate-Mailboxes:/set alternates="/;\
H;\
n;\
/^[^[:blank:]]/{\
s/.*/"/;\
H;\
x;\
p;\
q;\
};\
b a;\
}' < "$file" | tr -d '\012' > ${TMP-/tmp}/.mutt-alternates-$PPID; \
echo source ${TMP-/tmp}/.mutt-alternates-$PPID; \
else \
echo unalias dummy; \
fi)`
`(rm -f ${TMP-/tmp}/.mutt-alternates-$PPID; echo unalias dummy)`
Posted by juliob at November 06, 2003 05:16 PM