Trying to do hooks generically is way too complicated and unreliable and

confusing, particularly trying to automatically figure out what target
hooks should be using. So simplify it:

- drop before hooks entirely, they don't seem to be very useful;

- commands with special requirements now fire their own after hook (for
  example, if they change session or window, or if they have -t and -s
  and need to choose which one the hook uses as current target);

- commands with no special requirements can have the CMD_AFTERHOOK flag
  added and they will use the -t state.

At the moment new-session, new-window, split-window fire their own hook,
and display-message uses the flag. The remaining commands still need to
be looked at.
This commit is contained in:
nicm
2016-10-13 22:48:51 +00:00
parent 7a1a01feef
commit 4289a1ebfa
13 changed files with 58 additions and 114 deletions

View File

@ -66,6 +66,7 @@ cmd_split_window_exec(struct cmd *self, struct cmd_q *cmdq)
struct layout_cell *lc;
struct format_tree *ft;
struct environ_entry *envent;
struct cmd_find_state fs;
server_unzoom_window(w);
@ -178,15 +179,17 @@ cmd_split_window_exec(struct cmd *self, struct cmd_q *cmdq)
}
notify_window_layout_changed(w);
cmd_find_clear_state(&cmdq->current, NULL, 0);
cmdq->current.s = s;
cmdq->current.wl = wl;
cmdq->current.w = wl->window;
cmdq->current.wp = new_wp;
cmd_find_log_state(__func__, &cmdq->current);
if (to_free != NULL)
free((void *)to_free);
cmd_find_clear_state(&fs, NULL, 0);
fs.s = s;
fs.wl = wl;
fs.w = w;
fs.wp = new_wp;
cmd_find_log_state(__func__, &fs);
if (hooks_wait(s->hooks, cmdq, &fs, "after-split-window") == 0)
return (CMD_RETURN_WAIT);
return (CMD_RETURN_NORMAL);
error: