diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2011-12-15 10:12:00 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2011-12-15 10:12:00 +0100 |
commit | 1a9b8c92c8a173e6f86b1e4dc385e308d67e01f9 (patch) | |
tree | 4491ec7c40071b4391a6fe9d33e2df098c02e090 | |
parent | 16bd6071427509191fed46a74f9d3512687ddd04 (diff) | |
download | weechat-1a9b8c92c8a173e6f86b1e4dc385e308d67e01f9.zip |
core: display error about main buffer in command "/buffer close N" (or N1-N2) only if main buffer is the only buffer matching number(s)
-rw-r--r-- | src/core/wee-command.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c index 8035f2125..8c3f586d3 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -511,7 +511,7 @@ COMMAND_CALLBACK(buffer) struct t_gui_buffer *ptr_buffer, *weechat_buffer; long number, number1, number2; char *error, *value, *pos, *str_number1, *pos_number2; - int i, target_buffer; + int i, target_buffer, error_main_buffer, num_buffers; /* make C compiler happy */ (void) data; @@ -744,6 +744,8 @@ COMMAND_CALLBACK(buffer) } if ((number1 >= 1) && (number2 >= 1) && (number2 >= number1)) { + error_main_buffer = 0; + num_buffers = 0; for (i = number2; i >= number1; i--) { for (ptr_buffer = last_gui_buffer; ptr_buffer; @@ -751,12 +753,10 @@ COMMAND_CALLBACK(buffer) { if (ptr_buffer->number == i) { + num_buffers++; if (ptr_buffer == weechat_buffer) { - gui_chat_printf (NULL, - _("%sError: WeeChat main " - "buffer can't be closed"), - gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]); + error_main_buffer = 1; } else { @@ -765,6 +765,17 @@ COMMAND_CALLBACK(buffer) } } } + /* + * display error for main buffer if it was the only + * buffer to close with matching number + */ + if (error_main_buffer && (num_buffers <= 1)) + { + gui_chat_printf (NULL, + _("%sError: WeeChat main " + "buffer can't be closed"), + gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]); + } } } else |