imh

Check-in [326f23bc93]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add a forw command, leverage comp
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256:326f23bc9302700ef2b9fddddff4c119c3cd6fd4b437f37b5d85b0e37d5662d8
User & Date: ajv-899-334-8894@vsta.org 2016-11-19 23:08:29
Context
2016-11-19
23:08
Add forw command link check-in: e9235c9be2 user: ajv-899-334-8894@vsta.org tags: master, trunk
23:08
Add a forw command, leverage comp check-in: 326f23bc93 user: ajv-899-334-8894@vsta.org tags: master, trunk
2016-11-17
16:52
When we have new messages, switch to our inbox check-in: 2292653bdf user: ajv-899-334-8894@vsta.org tags: master, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to comp.py.

74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
..
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
                idx = int(l)
                dest.append(cands[idx])
            except:
                continue

    # Fetch textual representation of this message,
    #  turn into our starting point for the composition
    def comp(self):

        # To:, with completion
        addrsto,addrscc = self.completions()

        # Write out a template
        cfg = self.cfg
        fn = "%s/%s-%d" % (
................................................................................
        f = open(fn, "w")
        f.write("From: %s <%s>\n" %
         (cfg.get("name", os.getenv("NAME")),
          cfg.get("address", os.getenv("USER"))) )
        f.write("To: %s\n" % (", ".join(addrsto),))
        if addrscc:
            f.write("Cc: %s\n" % (", ".join(addrscc),))
        f.write("Subject: \n")
        f.write("\n\n")
        f.close()
        return fn

    def run(self):

        # For completion







|







 







|







74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
..
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
                idx = int(l)
                dest.append(cands[idx])
            except:
                continue

    # Fetch textual representation of this message,
    #  turn into our starting point for the composition
    def comp(self, subj=""):

        # To:, with completion
        addrsto,addrscc = self.completions()

        # Write out a template
        cfg = self.cfg
        fn = "%s/%s-%d" % (
................................................................................
        f = open(fn, "w")
        f.write("From: %s <%s>\n" %
         (cfg.get("name", os.getenv("NAME")),
          cfg.get("address", os.getenv("USER"))) )
        f.write("To: %s\n" % (", ".join(addrsto),))
        if addrscc:
            f.write("Cc: %s\n" % (", ".join(addrscc),))
        f.write("Subject: %s\n" % (subj,))
        f.write("\n\n")
        f.close()
        return fn

    def run(self):

        # For completion

Added forw.py.

























































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/python
# forw.py
#       Send a message onward
#
import os, sys
import comp

class Forw(comp.Comp):

    # Unlike Comp, we need the server so we can get
    #  a copy of the message(s) to forward
    def need_server(self):
        return True

    def run(self):

        # Argument, message(s) to forward
        msgs = self.arg_msgs()

        # If no messages, nothing to do
        if not msgs:
            return

        # Completion, destionations
        self.load_abook()

        # Make default subject line based on first message's
        #  subject line.
        tup = self.server.fetch(msgs[0],
         '(FLAGS BODY[HEADER.FIELDS (SUBJECT)])')
        if tup[0] != "OK":
            raise Exception, "Failed to get header of %d" % (m,)
        fields = self.field_dict(tup[1][0][1])
        subj = fields.get("Subject", "(no subject)")

        # Build our forwarded message header
        fn = self.comp("Fwd: " + subj)

        # Now tack on quoted bodies
        f = open(fn, "a")
        for m in msgs:
            self.select_msg(m)

            # Get sender for attribution
            tup = self.server.fetch(msgs[0],
             '(FLAGS BODY[HEADER.FIELDS (FROM)])')
            if tup[0] != "OK":
                raise Exception, "Failed to get sender of %d" % (m,)
            fields = self.field_dict(tup[1][0][1])
            sender = fields.get("From")

            # Message body
            t = self.mime_text()
            if t is None:
                t = self.mime_html()
            if t is None:
                sys.stderr.write("%d: no message body\n")
                continue

            # Quote it into the body
            f.write("[%s writes:]\n" % (sender,))
            for l in t.split('\n'):
                if l:
                    f.write("> %s\n" % (l,))
                else:
                    f.write(">\n")
            f.write("\n")

        f.close()

        # Hand it to whatnow, starting in edit mode
        os.system("whatnow -e %s" % (fn,))

if __name__ == "__main__":
    i = Forw()
    i.main()