I've implemented an extension of bare=append for my own use, and
thought I'd share it to see if others think it's worthwhile for
inclusion.

I use "X-TMDA: bare=append" for most outgoing mail, and periodically
reorganize my BARE_APPEND file, sorting addresses into categories
(family, friends, etc), so that I can keep track of why I have certain
email addresses in there.  Most addresses are familiar and I can
categorize them by sight, but some aren't, and I end up scanning my
email archive to figure out who the addresses belong to.  If I had a
better idea of when they were added, and/or why I added them, I could
avoid having to do that in most cases.

So I looked at the code and noted that TMDA only uses the first 'word'
on each line as the email address, leaving me free to add comments
after the address to help me remember.  And since I don't want to
constantly reedit my BARE_APPEND file to add comments, I decided to
patch tmda-inject to allow me to add comments by changing the X-TMDA
line.

Assuming you're sending to [EMAIL PROTECTED], and that user isn't in
your BARE_APPEND file, "X-TMDA: bare=append" will do the same thing it
always did.  

The patch extends bare=append to add three new behaviors:
"X-TMDA: bare=append-date":             "[EMAIL PROTECTED] # 20030528"
"X-TMDA: bare=append-keyword-foo":      "[EMAIL PROTECTED] # foo"
"X-TMDA: bare=append-date-keyword-foo": "[EMAIL PROTECTED] # 20030528 foo"

The patch still needs a little work, since "X-TMDA:
bare=append-keyword-foo-date" will append "[EMAIL PROTECTED] # date",
but I wanted to post and see what people thought before I went to the
trouble to fix that.

Patch attached below.

Ed
--- bin/tmda-inject.orig        Wed May 28 13:29:58 2003
+++ bin/tmda-inject     Wed May 28 14:15:01 2003
@@ -65,6 +65,7 @@
 import getopt
 import os
 import sys
+import time
 
 try:
     import paths
@@ -161,9 +162,17 @@
        # Use an untagged address.
        field = from_address
        # Optionally append the recipient address to a file.
-       if (cookie_option and string.lower(cookie_option) == 'append'
+       if (cookie_option and string.lower(cookie_option).find('append') == 0
            and Defaults.BARE_APPEND):
-           Util.append_to_file(to_address, Defaults.BARE_APPEND)
+           append = ''
+           if cookie_option.find('-date') > 0:
+             append = append + ' ' + time.strftime("%Y%m%d")
+           if cookie_option.find('-keyword-') > 0:
+             keyword = cookie_option.split('-')[-1]
+             append = append + ' ' + keyword
+           if append:              # something was added, add '\t#' before it
+             append = "\t#" + append
+           Util.append_to_file(to_address + append, Defaults.BARE_APPEND)
     elif cookie_type == 'dated':
        # Send a message with a tagged (dated) address.
        if cookie_option:               # check for timeout override

Reply via email to