{"action":"created","issue":{"url":"https://api.github.com/repos/pazz/alot/issues/797","labels_url":"https://api.github.com/repos/pazz/alot/issues/797/labels{/name}","comments_url":"https://api.github.com/repos/pazz/alot/issues/797/comments","events_url":"https://api.github.com/repos/pazz/alot/issues/797/events","html_url":"https://github.com/pazz/alot/issues/797","id":119885058,"number":797,"title":"Proposal: Catch all hooks","user":{"login":"lucc","id":1104419,"avatar_url":"https://avatars.githubusercontent.com/u/1104419?v=3","gravatar_id":"","url":"https://api.github.com/users/lucc","html_url":"https://github.com/lucc","followers_url":"https://api.github.com/users/lucc/followers","following_url":"https://api.github.com/users/lucc/following{/other_user}","gists_url":"https://api.github.com/users/lucc/gists{/gist_id}","starred_url":"https://api.github.com/users/lucc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucc/subscriptions","organizations_url":"https://api.github.com/users/lucc/orgs","repos_url":"https://api.github.com/users/lucc/repos","events_url":"https://api.github.com/users/lucc/events{/privacy}","received_events_url":"https://api.github.com/users/lucc/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-12-02T07:36:18Z","updated_at":"2015-12-03T18:55:39Z","closed_at":null,"body":"I try to update a awesome mail notification widget when I exit alot.\r\n\r\nMy first idea was to use some exit hook, but there is only a hook for the exit command and that is not triggered when I use the config option `quit_on_last_bclose`.\r\n\r\nAt the moment I have a working solution that installs a bclose hook for every mode:\r\n```python\r\nimport subprocess\r\n\r\ndef pre_search_bclose(ui, **kwargs): bclose_wrapper(ui)\r\ndef pre_thread_bclose(ui, **kwargs): bclose_wrapper(ui)\r\ndef pre_global_bclose(ui, **kwargs): bclose_wrapper(ui)\r\ndef pre_envelope_bclose(ui, **kwargs): bclose_wrapper(ui)\r\ndef pre_taglist_bclose(ui, **kwargs): bclose_wrapper(ui)\r\ndef pre_bufferlist_bclose(ui, **kwargs): bclose_wrapper(ui)\r\n\r\ndef bclose_wrapper(ui):\r\n    if len(ui.buffers) == 1:\r\n        update_awesome_mail_widget()\r\n\r\ndef update_awesome_mail_widget():\r\n    p = subprocess.Popen(['awesome-client'], stdin=subprocess.PIPE)\r\n    p.communicate(\r\n        'require(\"vicious\").force({require(\"widgets/notmuch\").widget})')\r\n```\r\nIn my opinion this is a unnecessary complication. So the question and proposal is this:\r\n\r\n1. Introduce some general exit hook that is agnostic of the reason of the exit. Maybe `pre_teardown`, `post_teardown`, `exit_cleanup`, `exit` or something similar. (I was expecting some hook like this to already exist because of the presence of the `quit_on_last_bclose` option.)\r\n2. Introduce mode agnostic hooks that are run for a special command, whichever mode it was fired from. They could be called `pre_any_COMMAND` and `post_any_COMMAND` or `pre_COMMAND` and `post_COMMAND`."},"comment":{"url":"https://api.github.com/repos/pazz/alot/issues/comments/161746585","html_url":"https://github.com/pazz/alot/issues/797#issuecomment-161746585","issue_url":"https://api.github.com/repos/pazz/alot/issues/797","id":161746585,"user":{"login":"lucc","id":1104419,"avatar_url":"https://avatars.githubusercontent.com/u/1104419?v=3","gravatar_id":"","url":"https://api.github.com/users/lucc","html_url":"https://github.com/lucc","followers_url":"https://api.github.com/users/lucc/followers","following_url":"https://api.github.com/users/lucc/following{/other_user}","gists_url":"https://api.github.com/users/lucc/gists{/gist_id}","starred_url":"https://api.github.com/users/lucc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucc/subscriptions","organizations_url":"https://api.github.com/users/lucc/orgs","repos_url":"https://api.github.com/users/lucc/repos","events_url":"https://api.github.com/users/lucc/events{/privacy}","received_events_url":"https://api.github.com/users/lucc/received_events","type":"User","site_admin":false},"created_at":"2015-12-03T18:55:39Z","updated_at":"2015-12-03T18:55:39Z","body":"I tried it but no change. I can call my hook manually with `:call hooks.exit_cleanup_test()`. I also tried to put some `logging.debug()` call before every `sys.exit()` call in the alot source. No result. It seems like the exit call is not made my alot directly but by some foreign module."}}