diff options
author | 2015-06-04 14:29:33 +0000 | |
---|---|---|
committer | 2015-06-04 14:29:33 +0000 | |
commit | d29a4ba187be967cbc2440d94aa3621915c0a474 (patch) | |
tree | 8392e0886a1cd24b13cec3973790a72cfe3e0c71 /usr.bin/tmux/cmd-set-option.c | |
parent | spacing, makes example fit on display. (diff) | |
download | wireguard-openbsd-d29a4ba187be967cbc2440d94aa3621915c0a474.tar.xz wireguard-openbsd-d29a4ba187be967cbc2440d94aa3621915c0a474.zip |
Make unsetting a global option restore it to the default. Diff lying
around for a while, I have forgotten who suggested it :-/.
Diffstat (limited to 'usr.bin/tmux/cmd-set-option.c')
-rw-r--r-- | usr.bin/tmux/cmd-set-option.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/usr.bin/tmux/cmd-set-option.c b/usr.bin/tmux/cmd-set-option.c index 33f2b675512..980c10edcfc 100644 --- a/usr.bin/tmux/cmd-set-option.c +++ b/usr.bin/tmux/cmd-set-option.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-set-option.c,v 1.74 2015/04/24 23:17:11 nicm Exp $ */ +/* $OpenBSD: cmd-set-option.c,v 1.75 2015/06/04 14:29:33 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -266,16 +266,25 @@ cmd_set_option_unset(struct cmd *self, struct cmd_q *cmdq, { struct args *args = self->args; - if (args_has(args, 'g')) { - cmdq_error(cmdq, "can't unset global option: %s", oe->name); - return (-1); - } if (value != NULL) { cmdq_error(cmdq, "value passed to unset option: %s", oe->name); return (-1); } - options_remove(oo, oe->name); + if (args_has(args, 'g') || oo == &global_options) { + switch (oe->type) { + case OPTIONS_TABLE_STRING: + options_set_string(oo, oe->name, "%s", oe->default_str); + break; + case OPTIONS_TABLE_STYLE: + options_set_style(oo, oe->name, oe->default_str, 0); + break; + default: + options_set_number(oo, oe->name, oe->default_num); + break; + } + } else + options_remove(oo, oe->name); return (0); } |