Monday, October 15, 2012

A display_filter for mutt to (among other things) localize dates

I'm neurotic about my email.  It's probably clinically significant.

Recently, I was looking for a way to have mutt display dates in my local timezone. I happened upon this stackexchange thread, which suggests the use of a display_filter.

I'm already using the excellent t-prot filter, to decrease my genocidal urges.  So, I'll need to chain that onto the end of whatever new display_filter I use. Furthermore, I'm not terribly thrilled that the stackexchange example relies on formail (because I'd rather avoid using the unmaintaned procmail).  I'd also rather avoid creating tempfiles, if I can.

So, here's what I came up with.  (gdate is GNU date from the coreutils package).

open (FH, "|-",
   "t-prot -acelmtkwS -Mmutt -L ~/dot/mutt/mlfooters -A ~/dot/mutt/adfooters")
  or die "Can't run $!";


  if ($found_date==0 && /^Date: (.*)$/) {
    print FH "Date: ".`gdate -R -d "$1"` ;
    $found_date = 1;
  } else {
    print FH;