diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2012-09-09 16:48:01 +0200 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2012-09-09 16:48:01 +0200 |
commit | ffe570e77151e3ff6f230ecb0808adca757354b9 (patch) | |
tree | 54e3663951e6b8da6dda98597fa4286f83a1f991 /alot | |
parent | 6f6597c970eec104dc5b0decebf5ec31da45718f (diff) |
transfer global refs of ui and settings to hooks
... in CallCommand.
This makes it possible to use `call "hooks.myfunc()"`,
where my_func makes use of the UI instance (and settings)
by referencing to `ui` (and `settings`).
Diffstat (limited to 'alot')
-rw-r--r-- | alot/commands/globals.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/alot/commands/globals.py b/alot/commands/globals.py index aae752d5..3f57faa4 100644 --- a/alot/commands/globals.py +++ b/alot/commands/globals.py @@ -316,6 +316,12 @@ class CallCommand(Command): def apply(self, ui): try: + hooks = settings.hooks + env = {'ui': ui, 'settings': settings} + for k, v in env.items(): + if k not in hooks.__dict__: + hooks.__dict__[k] = v + exec self.command except Exception as e: logging.exception(e) |