]> git.madduck.net Git - code/mailplate.git/blobdiff - mailplate

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

fix encoding of manpage
[code/mailplate.git] / mailplate
index 439fc73449415edbd2d23fc8139308221d66bf6b..c7a02b98a603ca17dcb18d45e22de834239467a4 100755 (executable)
--- a/mailplate
+++ b/mailplate
@@ -86,6 +86,7 @@ HELPER_SLOT_TRAILER = ')'   # character ending a helper slot
 STD_HEADERS = ('From', 'To', 'Cc', 'Bcc', 'Subject', 'Reply-To', 'In-Reply-To')
 KEEP_HEADERS = { 'KEEP_FROM_HEADER' : STD_HEADERS[:1]
                , 'KEEP_STD_HEADERS' : STD_HEADERS[1:]
 STD_HEADERS = ('From', 'To', 'Cc', 'Bcc', 'Subject', 'Reply-To', 'In-Reply-To')
 KEEP_HEADERS = { 'KEEP_FROM_HEADER' : STD_HEADERS[:1]
                , 'KEEP_STD_HEADERS' : STD_HEADERS[1:]
+               , 'KEEP_ALL_HEADERS' : STD_HEADERS
                }
 
 SIG_DELIM='\n-- \n'
                }
 
 SIG_DELIM='\n-- \n'
@@ -235,6 +236,7 @@ helpers = { 'get_quote' : 'fortune -s' }
 
 if not os.path.exists(CONFFILE):
     # conffile does not exist, let's create it with defaults.
 
 if not os.path.exists(CONFFILE):
     # conffile does not exist, let's create it with defaults.
+    options.verbose = True
 
     if not os.path.isdir(MAILPLATEDIR):
         info('configuration directory not found, creating: ' + MAILPLATEDIR)
 
     if not os.path.isdir(MAILPLATEDIR):
         info('configuration directory not found, creating: ' + MAILPLATEDIR)
@@ -325,8 +327,11 @@ elif (options.auto or options.menu) and templname:
     sys.exit(posix.EX_USAGE)
 
 elif not templname and not (options.auto or options.menu):
     sys.exit(posix.EX_USAGE)
 
 elif not templname and not (options.auto or options.menu):
-    err('no template specified')
-    sys.exit(posix.EX_USAGE)
+    if default_templname is not None:
+        templname = default_templname
+    else:
+        err('no template specified')
+        sys.exit(posix.EX_USAGE)
 
 elif options.menu:
     err('--menu mode not yet implemented')
 
 elif options.menu:
     err('--menu mode not yet implemented')
@@ -410,10 +415,14 @@ for line in templ:
         l = line[:-1]
         if len(l) == 0:
             payload = '' # end of headers
         l = line[:-1]
         if len(l) == 0:
             payload = '' # end of headers
-        elif l[0] == KEEP_SLOT_LEADER and KEEP_HEADERS.has_key(l[1:]):
-            # found predefined header slot keyword
-            for header in KEEP_HEADERS[l[1:]]:
-                headers[header.lower()] = (header, _keep_header)
+        elif l[0] == KEEP_SLOT_LEADER:
+            if KEEP_HEADERS.has_key(l[1:]):
+                # found predefined header slot keyword
+                for header in KEEP_HEADERS[l[1:]]:
+                    headers[header.lower()] = (header, _keep_header)
+            else:
+                err('unknown header slot ' + l + ' found')
+                sys.exit(posix.EX_CONFIG)
         else:
             header, content = l.split(':', 1)
             content = content.strip()
         else:
             header, content = l.split(':', 1)
             content = content.strip()
@@ -491,3 +500,4 @@ if options.edit:
         sys.exit(posix.EX_USAGE)
 
     os.execlp('sensible-editor', 'sensible-editor', outfname)
         sys.exit(posix.EX_USAGE)
 
     os.execlp('sensible-editor', 'sensible-editor', outfname)
+