Thanks Ed.
In case someone else is interested in setting this up too, here is
where I am so far.

Having the messages in the maildir format on my side, I regularly
(upon new message arrival using Mutt's $new_mail_command, and also
once a day) scan the To-do folder with a script (here is a simplified
version; uses procmail and mblaze packages):

#!/bin/zsh
while IFS=$'\n' read -r mailfile; do
  _due=$(formail -c -f -z -x 'Subject' < "${mailfile}" \
           | grep --only-matching --max-count=1 --perl-regexp
--regexp="[0-9]{4}-[0-9]{2}-[0-9]{2}" \
           | tr --delete - \
        )
  if [[ -n $_due ]]; then
    due=$(date -d "$_due" +%s)
    now=$(date -d $(date +%Y-%m-%d) +%s)
    if [[ $now -ge $due ]]; then
      echo "$(formail -f -I 'X-TODO: OVERDUE' < ${mailfile} | cat )" >
"${mailfile}"
      mflag -F "${mailfile}" > /dev/null 2>&1
    fi
  fi
done < <(find ~/Mail/To-do -type f -print)

It adds a custom header X-TODO, based on which I mark respective
messages with color:

color index white red "~h '^X-TODO: OVERDUE$'"

To propagate changes to the far side, along with adding the header,
which is never syncing, I also add a flag, which does sync. Anyway,
Gmail’s web interface does not support sorting by subject, so at least
I can spot the starred messages of interest there.

Best,

--
Dmitry


On Thu, Jul 7, 2022 at 4:40 PM dm1...@gmail.com <dm1...@gmail.com> wrote:
>
> Hi all,
>
> I have some messages with a subject line containing the "due:[here
> goes some date]" text. I want mutt to color these messages differently
> and dynamically (at every opening or refreshing the mailbox) according
> to whether the date in the subject is in the past or the future
> compared with the current date.
> Is it possible to accomplish?
>
> It would be nice to enchance the "todo.txt" approach with the "to-do
> mailbox" advantages :-)
>
> Best,
>
> --
> Dmitry

Reply via email to