On Fri, Jan 07, 2011 at 05:29 -0600, David Champion wrote: > * On 07 Jan 2011, du yang wrote: > > Hi, > > > > I improved the script to fulfill the author's the expectation(just display > > time for today's mails), > > only 'if condition' changed. > > ... > > if [ $(date -d "$(date '+%Y-%m-%d')" "+%s") -gt $epoch ]; then > > echo "%4C %Z %{%d.%m.%y} %-15.15F (%?l?%4l&%4c?) %?H?[%H]?%s%" > > It occurs to me that there is an optimization for this specific case. > Since the desired breaking point is simply "the beginning of today", > you can exploit the fact that %Y%m%d is a monotonic function when you > interpret it as an integer. (That is, it alpha-sorts and integer-sorts > in the same order as it date-sorts.) > > set index_format="./format_date.sh '%[%Y%m%d]' |" > > #!/bin/sh > > if [ $1 -eq `date +%Y%m%d` ]; then > echo "%4C %Z %{ %H:%M} %-15.15F (%?l?%4l&%4c?) %?H?[%H]?%s%" > else > echo "%4C %Z %{%d.%m.%y} %-15.15F (%?l?%4l&%4c?) %?H?[%H]?%s%" > fi > > I'm still not sure about performance though. I have a 58-row terminal > and do not want to run 116 processes for each page view in mutt. :) > > > > Aha, finally I have discovered a use for mutt's %<strftime> expando. > You can optimize this one step further. > > set index_format="./format_date.sh '%[%Y%m%d]' '%<%Y%m%d>' |" > > #!/bin/sh > > if [ $1 -eq $2 ]; then > echo "%4C %Z %{ %H:%M} %-15.15F (%?l?%4l&%4c?) %?H?[%H]?%s%" > else > echo "%4C %Z %{%d.%m.%y} %-15.15F (%?l?%4l&%4c?) %?H?[%H]?%s%" > fi > > A single exec per message now; that's as good as it gets without > patching mutt. > > I 'stole' %<strftime> for my nested_if patch because it looked > completely useless, so if you happen to be using nested_if, this latter > version won't work. Now that I see a purpose for %<...> I'll have to > revisit nested_if. (Unfortunately all the paired symbols are used > already.) >
Excellent! your improvement is helpful for some slow machines and machines during high load such as compiling. And mutt should be a single thread program, so it could just flush the terminal line by line, and would not fork many processes simultaneously. - du yang -- oooO::::::::: (..)::::::::: :\.(:::Oooo:: ::\_)::(..):: :::::::)./::: ::::::(_/::::