Merge branch 'master' of github.com:tmux/tmux

This commit is contained in:
Nicholas Marriott 2016-05-13 08:32:46 +01:00
commit 2377092a70
6 changed files with 46 additions and 37 deletions

View File

@ -163,16 +163,16 @@ alerts_queue(struct window *w, int flags)
if (!event_initialized(&w->alerts_timer)) if (!event_initialized(&w->alerts_timer))
evtimer_set(&w->alerts_timer, alerts_timer, w); evtimer_set(&w->alerts_timer, alerts_timer, w);
if (!alerts_fired) { if ((w->flags & flags) != flags) {
w->flags |= flags; w->flags |= flags;
log_debug("@%u alerts flags added %#x", w->id, flags); log_debug("@%u alerts flags added %#x", w->id, flags);
}
if (alerts_enabled(w, flags)) { if (!alerts_fired && alerts_enabled(w, flags)) {
log_debug("alerts check queued (by @%u)", w->id); log_debug("alerts check queued (by @%u)", w->id);
event_once(-1, EV_TIMEOUT, alerts_callback, NULL, NULL); event_once(-1, EV_TIMEOUT, alerts_callback, NULL, NULL);
alerts_fired = 1; alerts_fired = 1;
} }
}
} }
int int

24
cfg.c
View File

@ -47,8 +47,8 @@ set_cfg_file(const char *path)
void void
start_cfg(void) start_cfg(void)
{ {
char *cause = NULL;
const char *home; const char *home;
int quiet = 0;
cfg_cmd_q = cmdq_new(NULL); cfg_cmd_q = cmdq_new(NULL);
cfg_cmd_q->emptyfn = cfg_default_done; cfg_cmd_q->emptyfn = cfg_default_done;
@ -60,28 +60,20 @@ start_cfg(void)
if (cfg_client != NULL) if (cfg_client != NULL)
cfg_client->references++; cfg_client->references++;
if (access(TMUX_CONF, R_OK) == 0) { load_cfg(TMUX_CONF, cfg_cmd_q, 1);
if (load_cfg(TMUX_CONF, cfg_cmd_q, &cause) == -1)
cfg_add_cause("%s: %s", TMUX_CONF, cause);
} else if (errno != ENOENT)
cfg_add_cause("%s: %s", TMUX_CONF, strerror(errno));
if (cfg_file == NULL && (home = find_home()) != NULL) { if (cfg_file == NULL && (home = find_home()) != NULL) {
xasprintf(&cfg_file, "%s/.tmux.conf", home); xasprintf(&cfg_file, "%s/.tmux.conf", home);
if (access(cfg_file, R_OK) != 0 && errno == ENOENT) { quiet = 1;
free(cfg_file);
cfg_file = NULL;
} }
} if (cfg_file != NULL)
if (cfg_file != NULL && load_cfg(cfg_file, cfg_cmd_q, &cause) == -1) load_cfg(cfg_file, cfg_cmd_q, quiet);
cfg_add_cause("%s: %s", cfg_file, cause);
free(cause);
cmdq_continue(cfg_cmd_q); cmdq_continue(cfg_cmd_q);
} }
int int
load_cfg(const char *path, struct cmd_q *cmdq, char **cause) load_cfg(const char *path, struct cmd_q *cmdq, int quiet)
{ {
FILE *f; FILE *f;
char delim[3] = { '\\', '\\', '\0' }; char delim[3] = { '\\', '\\', '\0' };
@ -92,7 +84,9 @@ load_cfg(const char *path, struct cmd_q *cmdq, char **cause)
log_debug("loading %s", path); log_debug("loading %s", path);
if ((f = fopen(path, "rb")) == NULL) { if ((f = fopen(path, "rb")) == NULL) {
xasprintf(cause, "%s: %s", path, strerror(errno)); if (errno == ENOENT && quiet)
return (0);
cfg_add_cause("%s: %s", path, strerror(errno));
return (-1); return (-1);
} }

View File

@ -36,7 +36,7 @@ const struct cmd_entry cmd_set_hook_entry = {
.args = { "gt:u", 1, 2 }, .args = { "gt:u", 1, 2 },
.usage = "[-gu] " CMD_TARGET_SESSION_USAGE " hook-name [command]", .usage = "[-gu] " CMD_TARGET_SESSION_USAGE " hook-name [command]",
.tflag = CMD_SESSION, .tflag = CMD_SESSION_CANFAIL,
.flags = 0, .flags = 0,
.exec = cmd_set_hook_exec .exec = cmd_set_hook_exec
@ -63,12 +63,21 @@ cmd_set_hook_exec(struct cmd *self, struct cmd_q *cmdq)
struct hooks *hooks; struct hooks *hooks;
struct hook *hook; struct hook *hook;
char *cause, *tmp; char *cause, *tmp;
const char *name, *cmd; const char *name, *cmd, *target;
if (args_has(args, 'g')) if (args_has(args, 'g'))
hooks = global_hooks; hooks = global_hooks;
else {
if (cmdq->state.tflag.s == NULL) {
target = args_get(args, 't');
if (target != NULL)
cmdq_error(cmdq, "no such session: %s", target);
else else
cmdq_error(cmdq, "no current session");
return (CMD_RETURN_ERROR);
}
hooks = cmdq->state.tflag.s->hooks; hooks = cmdq->state.tflag.s->hooks;
}
if (self->entry == &cmd_show_hooks_entry) { if (self->entry == &cmd_show_hooks_entry) {
hook = hooks_first(hooks); hook = hooks_first(hooks);

View File

@ -34,8 +34,8 @@ const struct cmd_entry cmd_source_file_entry = {
.name = "source-file", .name = "source-file",
.alias = "source", .alias = "source",
.args = { "", 1, 1 }, .args = { "q", 1, 1 },
.usage = "path", .usage = "[-q] path",
.flags = 0, .flags = 0,
.exec = cmd_source_file_exec .exec = cmd_source_file_exec
@ -46,28 +46,26 @@ cmd_source_file_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;
struct cmd_q *cmdq1; struct cmd_q *cmdq1;
char *cause; int quiet;
cmdq1 = cmdq_new(cmdq->client); cmdq1 = cmdq_new(cmdq->client);
cmdq1->flags |= cmdq->flags & CMD_Q_NOHOOKS; cmdq1->flags |= cmdq->flags & CMD_Q_NOHOOKS;
cmdq1->emptyfn = cmd_source_file_done; cmdq1->emptyfn = cmd_source_file_done;
cmdq1->data = cmdq; cmdq1->data = cmdq;
switch (load_cfg(args->argv[0], cmdq1, &cause)) { quiet = args_has(args, 'q');
switch (load_cfg(args->argv[0], cmdq1, quiet)) {
case -1: case -1:
if (cfg_references == 0) {
cmdq_free(cmdq1); cmdq_free(cmdq1);
cmdq_error(cmdq, "%s", cause); if (cfg_references == 0) {
free(cause); cfg_print_causes(cmdq);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
cfg_add_cause("%s", cause); return (CMD_RETURN_NORMAL);
free(cause);
/* FALLTHROUGH */
case 0: case 0:
cmdq_free(cmdq1);
if (cfg_references == 0) if (cfg_references == 0)
cfg_print_causes(cmdq); cfg_print_causes(cmdq);
cmdq_free(cmdq1);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }

10
tmux.1
View File

@ -917,10 +917,18 @@ display the log for
and and
.Fl T .Fl T
show debugging information about jobs and terminals. show debugging information about jobs and terminals.
.It Ic source-file Ar path .It Xo Ic source-file
.Op Fl q
.Ar path
.Xc
.D1 (alias: Ic source ) .D1 (alias: Ic source )
Execute commands from Execute commands from
.Ar path . .Ar path .
If
.Fl q
is given, no error will be returned if
.Ar path
does not exist.
.It Ic start-server .It Ic start-server
.D1 (alias: Ic start ) .D1 (alias: Ic start )
Start the Start the

2
tmux.h
View File

@ -1557,7 +1557,7 @@ extern int cfg_finished;
extern int cfg_references; extern int cfg_references;
extern struct client *cfg_client; extern struct client *cfg_client;
void start_cfg(void); void start_cfg(void);
int load_cfg(const char *, struct cmd_q *, char **); int load_cfg(const char *, struct cmd_q *, int);
void set_cfg_file(const char *); void set_cfg_file(const char *);
void printflike(1, 2) cfg_add_cause(const char *, ...); void printflike(1, 2) cfg_add_cause(const char *, ...);
void cfg_print_causes(struct cmd_q *); void cfg_print_causes(struct cmd_q *);