diff --git a/cfg.c b/cfg.c index ddc112a2..933eda4e 100644 --- a/cfg.c +++ b/cfg.c @@ -184,9 +184,9 @@ load_cfg(const char *path, struct client *c, struct cmdq_item *item, int flags, new_item0 = cmdq_get_command(pr->cmdlist, NULL, NULL, 0); if (item != NULL) - cmdq_insert_after(item, new_item0); + new_item0 = cmdq_insert_after(item, new_item0); else - cmdq_append(NULL, new_item0); + new_item0 = cmdq_append(NULL, new_item0); cmd_list_free(pr->cmdlist); if (new_item != NULL) @@ -230,9 +230,9 @@ load_cfg_from_buffer(const void *buf, size_t len, const char *path, new_item0 = cmdq_get_command(pr->cmdlist, NULL, NULL, 0); if (item != NULL) - cmdq_insert_after(item, new_item0); + new_item0 = cmdq_insert_after(item, new_item0); else - cmdq_append(NULL, new_item0); + new_item0 = cmdq_append(NULL, new_item0); cmd_list_free(pr->cmdlist); if (new_item != NULL) diff --git a/cmd-queue.c b/cmd-queue.c index 69e4f6b2..75b5d8f9 100644 --- a/cmd-queue.c +++ b/cmd-queue.c @@ -53,12 +53,16 @@ cmdq_get(struct client *c) } /* Append an item. */ -void +struct cmdq_item * cmdq_append(struct client *c, struct cmdq_item *item) { struct cmdq_list *queue = cmdq_get(c); struct cmdq_item *next; + TAILQ_FOREACH(next, queue, entry) { + log_debug("%s %s: queue %s (%u)", __func__, cmdq_name(c), + next->name, next->group); + } do { next = item->next; item->next = NULL; @@ -73,16 +77,21 @@ cmdq_append(struct client *c, struct cmdq_item *item) item = next; } while (item != NULL); + return (TAILQ_LAST(queue, cmdq_list)); } /* Insert an item. */ -void +struct cmdq_item * cmdq_insert_after(struct cmdq_item *after, struct cmdq_item *item) { struct client *c = after->client; struct cmdq_list *queue = after->queue; struct cmdq_item *next; + TAILQ_FOREACH(next, queue, entry) { + log_debug("%s %s: queue %s (%u)", __func__, cmdq_name(c), + next->name, next->group); + } do { next = item->next; item->next = after->next; @@ -100,6 +109,7 @@ cmdq_insert_after(struct cmdq_item *after, struct cmdq_item *item) after = item; item = next; } while (item != NULL); + return (after); } /* Insert a hook. */ @@ -143,11 +153,10 @@ cmdq_insert_hook(struct session *s, struct cmdq_item *item, new_item = cmdq_get_command(cmdlist, fs, NULL, CMDQ_NOHOOKS); cmdq_format(new_item, "hook", "%s", name); - if (item != NULL) { - cmdq_insert_after(item, new_item); - item = new_item; - } else - cmdq_append(NULL, new_item); + if (item != NULL) + item = cmdq_insert_after(item, new_item); + else + item = cmdq_append(NULL, new_item); a = options_array_next(a); } diff --git a/cmd-source-file.c b/cmd-source-file.c index bdcdd222..dfe4a6aa 100644 --- a/cmd-source-file.c +++ b/cmd-source-file.c @@ -113,6 +113,7 @@ cmd_source_file_done(struct client *c, const char *path, int error, static void cmd_source_file_add(struct cmd_source_file_data *cdata, const char *path) { + log_debug("%s: %s", __func__, path); cdata->files = xreallocarray(cdata->files, cdata->nfiles + 1, sizeof *cdata->files); cdata->files[cdata->nfiles++] = xstrdup(path); diff --git a/key-bindings.c b/key-bindings.c index d4fada6a..7cd834a2 100644 --- a/key-bindings.c +++ b/key-bindings.c @@ -520,8 +520,8 @@ key_bindings_dispatch(struct key_binding *bd, struct cmdq_item *item, new_item->shared->flags |= CMDQ_SHARED_REPEAT; } if (item != NULL) - cmdq_insert_after(item, new_item); + new_item = cmdq_insert_after(item, new_item); else - cmdq_append(c, new_item); + new_item = cmdq_append(c, new_item); return (new_item); } diff --git a/notify.c b/notify.c index 8bd8f98f..200e23d6 100644 --- a/notify.c +++ b/notify.c @@ -89,9 +89,7 @@ notify_insert_hook(struct cmdq_item *item, struct notify_entry *ne) new_item = cmdq_get_command(cmdlist, &fs, NULL, CMDQ_NOHOOKS); cmdq_format(new_item, "hook", "%s", ne->name); notify_hook_formats(new_item, s, w, ne->pane); - - cmdq_insert_after(item, new_item); - item = new_item; + item = cmdq_insert_after(item, new_item); a = options_array_next(a); } diff --git a/tmux.h b/tmux.h index 96b4e397..37d3346c 100644 --- a/tmux.h +++ b/tmux.h @@ -2136,8 +2136,8 @@ struct cmdq_item *cmdq_get_command(struct cmd_list *, struct cmd_find_state *, #define cmdq_get_callback(cb, data) cmdq_get_callback1(#cb, cb, data) struct cmdq_item *cmdq_get_callback1(const char *, cmdq_cb, void *); struct cmdq_item *cmdq_get_error(const char *); -void cmdq_insert_after(struct cmdq_item *, struct cmdq_item *); -void cmdq_append(struct client *, struct cmdq_item *); +struct cmdq_item *cmdq_insert_after(struct cmdq_item *, struct cmdq_item *); +struct cmdq_item *cmdq_append(struct client *, struct cmdq_item *); void cmdq_insert_hook(struct session *, struct cmdq_item *, struct cmd_find_state *, const char *, ...); void cmdq_continue(struct cmdq_item *);