procmail
[Top] [All Lists]

Re: procmail to Maildir as read?

2000-10-21 02:28:38
MaD dUCK <madduck(_at_)madduck(_dot_)net> writes:
hey all,
on a related note to the recent Maildir discussion, while it is simple to mark
messages in mbox format read using procmail (formail -I"Status: R"), does
anyone know of a way to make Maildir messages read?

The approach quoted earlier:

DEFAULT=/home/vpopmail/domains/domain/user/Maildir/new

does not really work if i stored in /cur (despite the MH folder delivery),
mutt will still make the messages show up at 'O', meaning that they have the
New bit set.

Any ideas?

It probably depends on the client (mutt, in this case), but it would
appear from <URL:http://cr.yp.to/proto/maildir.html> that appending the
proper suffix to the filename when you move it from "new" to "cur" would
be enough.  So, for example, the following should work, though I myself
use neither maildir nor mutt, so I can't test it:


        folder = /home/vpopmail/domains/domain/user/Maildir

        # Deliver the message to the maildir's new subdir
        :0 c
        $folder/

        # Extract the filename from LASTFOLDER
        :0 ai
        * LASTFOLDER ?? ()\/[^/]+^^
        |mv "$LASTFOLDER" "$folder/cur/$MATCH:2,S"

You could extract the folder path from LASTFOLDER if you didn't want to
have to set the folder variable.


Alternatively, you could pull it off with a really ugly TRAP
assignment.  Hmm.  If you have a full POSIX shell to work with (ksh on
many systems) the following _might_ work:

SHELL = /usr/bin/ksh            # /bin/sh should work on newish OSes
TRAP = '
case "$EXITCODE:$LASTFOLDER" in
0:*/new/*)
    curfolder="${LASTFOLDER%/new/*}/cur" ;
    if [ -d "$folder" ]; then
        exec mv "$LASTFOLDER" "$folder/${LASTFOLDER##*/new/}:2,S" 2>/dev/null;
    fi
    ;;
esac
'

That takes advantage of the POSIX shell's delete-longest-prefix and
delete-shortest-suffix substitutions (${variable##pattern} and
${variable%pattern}, respectively) to avoid having to invoke any program
except "mv".  The case and if conditionals are there to limit this
mv'ing to maildir folders that were successfully delivered to.


Philip Guenther

_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>