My usual mutt config contains uses some features that are only found in
patched versions of mutt.  Attempting to use them with a mutt that
doesn't have the relevant patches can have results varying from ugly to
potentially destructive.  In spite of this, I occasionally want to test
things out with an unpatched mutt, so I came up with this scheme of
having my mutt config vary based on what patches have been applied to
the current mutt.

In my .muttrc I have this line:

  source "dynamic_muttrc |"

And here's my dynamic_muttrc script:

#!/bin/sh

MUTT="/proc/${PPID}/exe"

if $MUTT -F /dev/null -v | grep date_optional > /dev/null 2>&1
then
  echo 'set index_format="%4C %Z %?[?%[%H:%M]&%[%m/%d]? %-15.15L (%5l) %s"'
else
  echo 'set index_format="%4C %Z %[%m/%d] %-15.15L (%5l) %s"'
fi

if $MUTT -F /dev/null -v | grep mark_old > /dev/null 2>&1
then
  echo 'set see_old'
else
  echo 'set mark_old read_only'
fi



The exact implementation (running mutt from /proc) is pretty much
specific to Linux, but other OSes may provide a different way to find
the copy of mutt that's currently reading the config; lsof may be useful
for this.  One nice thing about this method is that it seems to work
even if the currently running mutt was deleted after being started,
which may be useful if bits of the config are sourced long after
starting (possibly from some kind of hook or macro).

-- 
Aaron Schrab     [EMAIL PROTECTED]      http://www.execpc.com/~aarons/
 Standards are crucial.  And the best thing about standards is:
    there are so _many_ to choose from!

Reply via email to