summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2021-04-07 16:01:21 +0100
committerThomas Adam <thomas@xteddy.org>2021-04-07 16:01:21 +0100
commit3cd63cc9e0f8f1a4fb4e9da7f39de77ed58d61fb (patch)
treebc2b0c9e555b94eb2eadb8771fd6f1f2fd221394
parent998a6b0aea560a3c43c23b38b039e9f77d067fe3 (diff)
parent71fc9f3ee8753a2bb163c85c784936a8d6d3e0ac (diff)
Merge branch 'obsd-master' into master
-rw-r--r--cfg.c20
-rw-r--r--cmd-display-message.c12
-rw-r--r--cmd-queue.c2
-rw-r--r--tmux.11
4 files changed, 29 insertions, 6 deletions
diff --git a/cfg.c b/cfg.c
index 3ef46e66..8ec5a95b 100644
--- a/cfg.c
+++ b/cfg.c
@@ -102,6 +102,7 @@ load_cfg(const char *path, struct client *c, struct cmdq_item *item, int flags,
struct cmd_parse_input pi;
struct cmd_parse_result *pr;
struct cmdq_item *new_item0;
+ struct cmdq_state *state;
if (new_item != NULL)
*new_item = NULL;
@@ -135,12 +136,19 @@ load_cfg(const char *path, struct client *c, struct cmdq_item *item, int flags,
return (0);
}
- new_item0 = cmdq_get_command(pr->cmdlist, NULL);
+ if (item != NULL)
+ state = cmdq_copy_state(cmdq_get_state(item));
+ else
+ state = cmdq_new_state(NULL, NULL, 0);
+ cmdq_add_format(state, "current_file", "%s", pi.file);
+
+ new_item0 = cmdq_get_command(pr->cmdlist, state);
if (item != NULL)
new_item0 = cmdq_insert_after(item, new_item0);
else
new_item0 = cmdq_append(NULL, new_item0);
cmd_list_free(pr->cmdlist);
+ cmdq_free_state(state);
if (new_item != NULL)
*new_item = new_item0;
@@ -155,6 +163,7 @@ load_cfg_from_buffer(const void *buf, size_t len, const char *path,
struct cmd_parse_input pi;
struct cmd_parse_result *pr;
struct cmdq_item *new_item0;
+ struct cmdq_state *state;
if (new_item != NULL)
*new_item = NULL;
@@ -181,12 +190,19 @@ load_cfg_from_buffer(const void *buf, size_t len, const char *path,
return (0);
}
- new_item0 = cmdq_get_command(pr->cmdlist, NULL);
+ if (item != NULL)
+ state = cmdq_copy_state(cmdq_get_state(item));
+ else
+ state = cmdq_new_state(NULL, NULL, 0);
+ cmdq_add_format(state, "current_file", "%s", pi.file);
+
+ new_item0 = cmdq_get_command(pr->cmdlist, state);
if (item != NULL)
new_item0 = cmdq_insert_after(item, new_item0);
else
new_item0 = cmdq_append(NULL, new_item0);
cmd_list_free(pr->cmdlist);
+ cmdq_free_state(state);
if (new_item != NULL)
*new_item = new_item0;
diff --git a/cmd-display-message.c b/cmd-display-message.c
index fc9c4851..301c1a5e 100644
--- a/cmd-display-message.c
+++ b/cmd-display-message.c
@@ -43,7 +43,7 @@ const struct cmd_entry cmd_display_message_entry = {
.usage = "[-aIpv] [-c target-client] [-d delay] [-F format] "
CMD_TARGET_PANE_USAGE " [message]",
- .target = { 't', CMD_FIND_PANE, 0 },
+ .target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL },
.flags = CMD_AFTERHOOK|CMD_CLIENT_CFLAG|CMD_CLIENT_CANFAIL,
.exec = cmd_display_message_exec
@@ -73,6 +73,8 @@ cmd_display_message_exec(struct cmd *self, struct cmdq_item *item)
int flags;
if (args_has(args, 'I')) {
+ if (wp == NULL)
+ return (CMD_RETURN_NORMAL);
if (window_pane_start_input(wp, item, &cause) != 0) {
cmdq_error(item, "%s", cause);
free(cause);
@@ -109,8 +111,10 @@ cmd_display_message_exec(struct cmd *self, struct cmdq_item *item)
*/
if (tc != NULL && tc->session == s)
c = tc;
- else
+ else if (s != NULL)
c = cmd_find_best_client(s);
+ else
+ c = NULL;
if (args_has(args, 'v'))
flags = FORMAT_VERBOSE;
else
@@ -124,7 +128,9 @@ cmd_display_message_exec(struct cmd *self, struct cmdq_item *item)
}
msg = format_expand_time(ft, template);
- if (args_has(args, 'p'))
+ if (cmdq_get_client(item) == NULL)
+ cmdq_error(item, "%s", msg);
+ else if (args_has(args, 'p'))
cmdq_print(item, "%s", msg);
else if (tc != NULL)
status_message_set(tc, delay, 0, "%s", msg);
diff --git a/cmd-queue.c b/cmd-queue.c
index 05f439f5..a0d80c34 100644
--- a/cmd-queue.c
+++ b/cmd-queue.c
@@ -276,7 +276,7 @@ cmdq_merge_formats(struct cmdq_item *item, struct format_tree *ft)
const struct cmd_entry *entry;
if (item->cmd != NULL) {
- entry = cmd_get_entry (item->cmd);
+ entry = cmd_get_entry(item->cmd);
format_add(ft, "command", "%s", entry->name);
}
if (item->state->formats != NULL)
diff --git a/tmux.1 b/tmux.1
index 83cecded..1a0739ff 100644
--- a/tmux.1
+++ b/tmux.1
@@ -4859,6 +4859,7 @@ The following variables are available, where appropriate:
.It Li "copy_cursor_word" Ta "" Ta "Word under cursor in copy mode"
.It Li "copy_cursor_x" Ta "" Ta "Cursor X position in copy mode"
.It Li "copy_cursor_y" Ta "" Ta "Cursor Y position in copy mode"
+.It Li "current_file" Ta "" Ta "Current configuration file"
.It Li "cursor_character" Ta "" Ta "Character at cursor in pane"
.It Li "cursor_flag" Ta "" Ta "Pane cursor flag"
.It Li "cursor_x" Ta "" Ta "Cursor X position in pane"