summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2011-09-18 12:55:25 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2011-09-18 12:55:25 +0100
commit74758720dbe210b33fcdd085d63f708827d9f077 (patch)
tree69cff6e238d960df2fc9f644fe5d9868bd7fd5ff
parent90a04bdfeb91404f4d629f682c55e4b259da20ae (diff)
hooks docu
-rw-r--r--USAGE.md (renamed from USAGE)31
1 files changed, 20 insertions, 11 deletions
diff --git a/USAGE b/USAGE.md
index 2439554c..29017198 100644
--- a/USAGE
+++ b/USAGE.md
@@ -132,17 +132,17 @@ You can tune this using the `abook_regexp` option (beware Commandparsers escapin
Hooks
-----
-Before and after every command execution, alot calls this commands pre/post hook:
-Hooks are python callables with arity 4 that live in a module specified by
-`hooksfile` in the `[global]` section of your config. Per default this points to `~/.alot.py`
+Hooks are python callables that live in a module specified by
+`hooksfile` in the `[global]` section of your config. Per default this points to `~/.alot.py`.
For every command X, the callable 'pre_X' will be called before X and 'post_X' afterwards.
When a hook gets called, it receives instances of
-1. `alot.ui.UI`, the main user interface object that can prompt etc.
-2. `alot.db.DBManager`, the applications database manager
-3. `alot.account.AccountManager`, can be used to look up account info
-4. `alot.settings.config`, a configparser to access the users config
+ * ui: `alot.ui.UI`, the main user interface object that can prompt etc.
+ * dbm: `alot.db.DBManager`, the applications database manager
+ * aman: `alot.account.AccountManager`, can be used to look up account info
+ * log: `logging.Logger`, to write to logfile
+ * config: `alot.settings.config`, a configparser to access the users config
An autogenerated API doc for these can be found at http://pazz.github.com/alot/ ,
the sphinx sources live in the `docs` folder.
@@ -150,14 +150,23 @@ As an example, consider this pre-hook for the exit command,
that logs a personalized goodby message:
```python
-def pre_exit(ui, dbman, accountman, config):
- accounts = accountman.get_accounts()
+def pre_exit(aman=None, log=None, **rest):
+ accounts = aman.get_accounts()
if accounts:
- ui.logger.info('goodbye, %s!' % accounts[0].realname)
+ log.info('goodbye, %s!' % accounts[0].realname)
else:
- ui.logger.info('goodbye!')
+ log.info('goodbye!')
```
+Apart from command pre and posthooks, the following hooks will be interpreted:
+ * `reply_prefix(realname, address, timestamp, **kwargs)`
+ Is used to reformat the first indented line in a reply message.
+ Should return a string and defaults to 'Quoting %s (%s)\n' % (realname, timestamp)
+
+ * `forward_prefix(realname, address, timestamp, **kwargs)`
+ Is used to reformat the first indented line in a inline forwarded message.
+ Returns a string and defaults to 'Forwarded message from %s (%s)\n' % (realname, timestamp)
+
Theming
-------