-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy path_fastmail.py
71 lines (61 loc) · 2.15 KB
/
_fastmail.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
from dragonfly import *
config = Config("Fastmail")
config.mailboxes = Section("Mailbox Mappings")
config.mailboxes.map = Item(
{
"inbox": "Inbox",
"archive": "Archive",
"drafts": "Drafts",
"sent": "Sent",
"spam": "Spam",
"trash": "Trash"
}
)
config.load()
class CommandRule(MappingRule):
mapping = {
# Composition.
"compose [new] (email|message)": Key("c"),
"discard (email|message)": Key("ctrl:down, shift:down, alt:down, backspace, alt:up, shift:up, ctrl:up"),
"send (email|message)": Key("c-enter"),
"reply to (email|message)": Key("r"),
"reply to all": Key("a"),
"forward (email|message)": Key("f"),
# Searching.
"search email <text>": Key("slash") + Text("%(text)s") + Key("enter"),
# Mailboxes.
"refresh mailbox": Key("u"),
"go to mailbox <text>": Key("escape, escape, g") + Text("%(text)s") + Key("enter"),
"go to <mailbox>": Key("escape, escape, g") + Text("%(mailbox)s") + Key("enter"),
# Message list.
"next (email|message)": Key("j"),
"previous (email|message)": Key("k"),
"open (email|message)": Key("o"),
"select (email|message)": Key("x"),
"delete (email|message|messages)": Key("d"),
"archive (email|message|messages)": Key("y"),
"(mark as spam|report spam)": Key("exclamation"),
"mark (email|message) read": Key("dot/10, r"),
"mark (email|message) unread": Key("dot/10, u"),
"pin (email|message)": Key("dot/10, p"),
"unpin (email|message)": Key("dot/10, n"),
"move (email|message|messages)": Key("m"),
"select all (email|messages)": Key("asterisk, a"),
"(deselect (email|messages)|unselect all)": Key("asterisk, n"),
# General.
"undo (action|archive|delete|move)": Key("z"),
}
extras = [
Dictation("text"),
Choice("mailbox", config.mailboxes.map)
]
global_context = None # Context is None, so grammar will be globally active.
grammar = Grammar("Fastmail commands", context=global_context)
grammar.add_rule(CommandRule())
grammar.load()
# Unload function which will be called at unload time.
def unload():
global grammar
if grammar:
grammar.unload()
grammar = None