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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
.. _config.hooks:
Hooks
=====
Hooks are python callables that live in a module specified by `hooksfile` in the
config. Per default this points to :file:`~/.config/alot/hooks.py`.
When a hook gets called it receives a reference to the :class:`main user interface <alot.ui.UI>` and the
:class:`database manager <alot.db.DBManager>`.
For every :ref:`COMMAND <commands>` in mode :ref:`MODE <modes>`, the callables :func:`pre_MODE_COMMAND` and :func:`post_MODE_COMMAND`
-- if defined -- will be called before and after the command is applied respectively. The signature for the
pre-`send` hook in envelope mode for example looks like this:
.. py:function:: pre_envelope_send(ui=None, dbm=None)
:param ui: the main user interface
:type ui: :class:`alot.ui.UI`
:param dbm: a database manager
:type dbm: :class:`alot.db.DBManager`
Consider this pre-hook for the exit command, that logs a personalized goodbye message::
import logging
from alot.settings import settings
def pre_global_exit(ui, dbm):
accounts = settings.get_accounts()
if accounts:
logging.info('goodbye, %s!' % accounts[0].realname)
else:
logging.info('goodbye!')
Apart from command pre- and posthooks, the following hooks will be interpreted:
.. py:function:: reply_prefix(realname, address, timestamp[, ui= None, dbm=None])
Is used to reformat the first indented line in a reply message.
This defaults to 'Quoting %s (%s)\n' % (realname, timestamp)' unless this hook is defined
:param realname: name or the original sender
:type realname: str
:param address: address of the sender
:type address: str
:param timestamp: value of the Date header of the replied message
:type timestamp: :obj:`datetime.datetime`
:rtype: string
.. py:function:: forward_prefix(realname, address, timestamp[, ui= None, dbm=None])
Is used to reformat the first indented line in a inline forwarded message.
This defaults to 'Forwarded message from %s (%s)\n' % (realname, timestamp)' if this hook is undefined
:param realname: name or the original sender
:type realname: str
:param address: address of the sender
:type address: str
:param timestamp: value of the Date header of the replied message
:type timestamp: :obj:`datetime.datetime`
:rtype: string
.. py:function:: pre_edit_translate(bodytext[, ui= None, dbm=None])
used to manipulate a messages bodytext *before* the editor is called.
:param bodytext: text representation of mail body as displayed in the interface and as sent to the editor
:type bodytext: str
:rtype: str
.. py:function:: post_edit_translate(bodytext[, ui= None, dbm=None])
used to manipulate a messages bodytext *after* the editor is called
:param bodytext: text representation of mail body as displayed in the interface and as sent to the editor
:type bodytext: str
:rtype: str
.. py:function:: text_quote(message)
used to transform a message into a quoted one
:param message: message to be quoted
:type message: str
:rtype: str
.. py:function:: timestamp_format(timestamp)
represents given timestamp as string
:param bodytext: timestamp to represent
:type timestamp: `datetime`
:rtype: str
.. py:function:: touch_external_cmdlist(cmd, shell=shell, spawn=spawn, thread=thread)
used to change external commands according to given flags shortly
before they are called.
:param cmd: command to be called
:type cmd: list of str
:param shell: is this to be interpreted by the shell?
:type shell: bool
:param spawn: should be spawned in new terminal/environment
:type spawn: bool
:param threads: should be called in new thread
:type thread: bool
:returns: triple of amended command list, shell and thread flags
:rtype: list of str, bool, bool
.. py:function:: reply_subject(subject)
used to reformat the subject header on reply
:param subject: subject to reformat
:type subject: str
:rtype: str
.. py:function:: forward_subject(subject)
used to reformat the subject header on forward
:param subject: subject to reformat
:type subject: str
:rtype: str
|