mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 09:44:18 +00:00 
			
		
		
		
	Make unsetting a global option restore it to the default. Diff lying
around for a while, I have forgotten who suggested it :-/.
This commit is contained in:
		@@ -266,15 +266,24 @@ cmd_set_option_unset(struct cmd *self, struct cmd_q *cmdq,
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	struct args	*args = self->args;
 | 
						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) {
 | 
						if (value != NULL) {
 | 
				
			||||||
		cmdq_error(cmdq, "value passed to unset option: %s", oe->name);
 | 
							cmdq_error(cmdq, "value passed to unset option: %s", oe->name);
 | 
				
			||||||
		return (-1);
 | 
							return (-1);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						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);
 | 
							options_remove(oo, oe->name);
 | 
				
			||||||
	return (0);
 | 
						return (0);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										12
									
								
								tmux.1
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								tmux.1
									
									
									
									
									
								
							@@ -2273,21 +2273,19 @@ command),
 | 
				
			|||||||
a server option with
 | 
					a server option with
 | 
				
			||||||
.Fl s ,
 | 
					.Fl s ,
 | 
				
			||||||
otherwise a session option.
 | 
					otherwise a session option.
 | 
				
			||||||
.Pp
 | 
					 | 
				
			||||||
If
 | 
					If
 | 
				
			||||||
.Fl g
 | 
					.Fl g
 | 
				
			||||||
is specified, the global session or window option is set.
 | 
					is given, the global session or window option is set.
 | 
				
			||||||
The
 | 
					The
 | 
				
			||||||
.Fl u
 | 
					.Fl u
 | 
				
			||||||
flag unsets an option, so a session inherits the option from the global
 | 
					flag unsets an option, so a session inherits the option from the global
 | 
				
			||||||
options.
 | 
					options (or with
 | 
				
			||||||
It is not possible to unset a global option.
 | 
					.Fl g ,
 | 
				
			||||||
 | 
					restores a global option to the default).
 | 
				
			||||||
.Pp
 | 
					.Pp
 | 
				
			||||||
The
 | 
					The
 | 
				
			||||||
.Fl o
 | 
					.Fl o
 | 
				
			||||||
flag prevents setting an option that is already set.
 | 
					flag prevents setting an option that is already set and
 | 
				
			||||||
.Pp
 | 
					 | 
				
			||||||
The
 | 
					 | 
				
			||||||
.Fl q
 | 
					.Fl q
 | 
				
			||||||
flag suppresses errors about unknown options.
 | 
					flag suppresses errors about unknown options.
 | 
				
			||||||
.Pp
 | 
					.Pp
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user