Hooks are python callables that live in a module specified by hooksfile in the config. Per default this points to ~/.config/alot/hooks.py.
Pre/Post Command Hooks
For every COMMAND in mode MODE, the callables pre_MODE_COMMAND() and 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:
Parameters: |
|
---|
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!')
Other Hooks
Apart from command pre- and posthooks, the following hooks will be interpreted:
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
Parameters: |
|
---|---|
Return type: | string |
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
Parameters: |
|
---|---|
Return type: | string |
used to manipulate a messages bodytext before the editor is called.
Parameters: | bodytext (str) – text representation of mail body as displayed in the interface and as sent to the editor |
---|---|
Return type: | str |
used to manipulate a messages bodytext after the editor is called
Parameters: | bodytext (str) – text representation of mail body as displayed in the interface and as sent to the editor |
---|---|
Return type: | str |
used to transform a message into a quoted one
Parameters: | message (str) – message to be quoted |
---|---|
Return type: | str |
represents given timestamp as string
Parameters: | bodytext – timestamp to represent |
---|---|
Return type: | str |
used to change external commands according to given flags shortly before they are called.
Parameters: | |
---|---|
Returns: | triple of amended command list, shell and thread flags |
Return type: | list of str, bool, bool |
used to reformat the subject header on reply
Parameters: | subject (str) – subject to reformat |
---|---|
Return type: | str |
used to reformat the subject header on forward
Parameters: | subject (str) – subject to reformat |
---|---|
Return type: | str |
run before a new buffer is opened
Parameters: | buf (alot.buffer.Buffer) – buffer to open |
---|
run after a new buffer is opened
Parameters: | buf (alot.buffer.Buffer) – buffer to open |
---|
run before a buffer is closed
Parameters: | buf (alot.buffer.Buffer) – buffer to open |
---|
run after a buffer is closed
Parameters: |
|
---|
run before a buffer is focused
Parameters: | buf (alot.buffer.Buffer) – buffer to open |
---|
run after a buffer is focused
Parameters: |
|
---|