-c needs to be able for fail for display-message.

This commit is contained in:
nicm 2015-12-13 18:31:47 +00:00
parent 66d1193a00
commit 72948d9f1d
3 changed files with 12 additions and 6 deletions

View File

@ -39,7 +39,7 @@ const struct cmd_entry cmd_display_message_entry = {
"c:pt:F:", 0, 1, "c:pt:F:", 0, 1,
"[-p] [-c target-client] [-F format] " CMD_TARGET_PANE_USAGE "[-p] [-c target-client] [-F format] " CMD_TARGET_PANE_USAGE
" [message]", " [message]",
CMD_CLIENT_C|CMD_PANE_T, CMD_CLIENT_C|CMD_PANE_T|CMD_CLIENT_CANFAIL,
cmd_display_message_exec cmd_display_message_exec
}; };

15
cmd.c
View File

@ -585,7 +585,7 @@ cmd_prepare_state(struct cmd *cmd, struct cmd_q *cmdq)
struct cmd_state *state = &cmdq->state; struct cmd_state *state = &cmdq->state;
struct args *args = cmd->args; struct args *args = cmd->args;
char *tmp; char *tmp;
int error; int error, quiet;
tmp = cmd_print(cmd); tmp = cmd_print(cmd);
log_debug("preparing state for: %s (client %p)", tmp, cmdq->client); log_debug("preparing state for: %s (client %p)", tmp, cmdq->client);
@ -594,6 +594,11 @@ cmd_prepare_state(struct cmd *cmd, struct cmd_q *cmdq)
/* Start with an empty state. */ /* Start with an empty state. */
cmd_clear_state(state); cmd_clear_state(state);
/* No error messages if can fail. */
quiet = 0;
if (cmd->entry->flags & CMD_CLIENT_CANFAIL)
quiet = 1;
/* /*
* If the command wants a client and provides -c or -t, use it. If not, * If the command wants a client and provides -c or -t, use it. If not,
* try the base command instead via cmd_get_state_client. No client is * try the base command instead via cmd_get_state_client. No client is
@ -604,13 +609,13 @@ cmd_prepare_state(struct cmd *cmd, struct cmd_q *cmdq)
state->c = cmd_find_client(cmdq, NULL, 1); state->c = cmd_find_client(cmdq, NULL, 1);
break; break;
case CMD_CLIENT_C: case CMD_CLIENT_C:
state->c = cmd_find_client(cmdq, args_get(args, 'c'), 0); state->c = cmd_find_client(cmdq, args_get(args, 'c'), quiet);
if (state->c == NULL) if (!quiet && state->c == NULL)
return (-1); return (-1);
break; break;
case CMD_CLIENT_T: case CMD_CLIENT_T:
state->c = cmd_find_client(cmdq, args_get(args, 't'), 0); state->c = cmd_find_client(cmdq, args_get(args, 't'), quiet);
if (state->c == NULL) if (!quiet && state->c == NULL)
return (-1); return (-1);
break; break;
default: default:

1
tmux.h
View File

@ -1417,6 +1417,7 @@ struct cmd_entry {
#define CMD_PANE_MARKED_T 0x10000 #define CMD_PANE_MARKED_T 0x10000
#define CMD_WINDOW_MARKED_T 0x20000 #define CMD_WINDOW_MARKED_T 0x20000
#define CMD_WINDOW_MARKED_S 0x40000 #define CMD_WINDOW_MARKED_S 0x40000
#define CMD_CLIENT_CANFAIL 0x80000
int flags; int flags;
enum cmd_retval (*exec)(struct cmd *, struct cmd_q *); enum cmd_retval (*exec)(struct cmd *, struct cmd_q *);