From bf21ca072d5250b1196e62db61f3ba675ee89b52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sat, 17 Aug 2019 08:57:40 +0200 Subject: [PATCH] buflist: use extra variables in option buflist.look.display_conditions (closes #1393) --- ChangeLog.adoc | 1 + src/plugins/buflist/buflist-bar-item.c | 46 ++++++++++++++------------ 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/ChangeLog.adoc b/ChangeLog.adoc index 0b14bd1c7..9e005a2f7 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -38,6 +38,7 @@ Bug fixes:: * core: replace newlines by spaces in argument "completion" of function hook_command (issue #538) * core: replace char "," by "~" in color codes to separate foreground from background (issue #1264) * alias: remove default aliases /AME and /AMSG (issue #1355) + * buflist: use extra variables in option buflist.look.display_conditions (issue #1393) * irc: fix memory leak when removing a server * irc: fix length of user/nick/host in split of messages (issue #1387) * irc: quote NICK command argument sent to the server only if there's a ":" in the nick (issue #1376, issue #1319) diff --git a/src/plugins/buflist/buflist-bar-item.c b/src/plugins/buflist/buflist-bar-item.c index 9216bfedc..c3f108507 100644 --- a/src/plugins/buflist/buflist-bar-item.c +++ b/src/plugins/buflist/buflist-bar-item.c @@ -350,25 +350,7 @@ buflist_bar_item_buflist_cb (const void *pointer, void *data, weechat_hashtable_set (buflist_hashtable_pointers, "irc_channel", ptr_channel); - /* check condition: if false, the buffer is not displayed */ - condition = weechat_string_eval_expression ( - weechat_config_string (buflist_config_look_display_conditions), - buflist_hashtable_pointers, - NULL, /* extra vars */ - buflist_hashtable_options_conditions); - rc = (condition && (strcmp (condition, "1") == 0)); - if (condition) - free (condition); - if (!rc) - continue; - - weechat_arraylist_add (buflist_list_buffers[item_index], ptr_buffer); - - current_buffer = (ptr_buffer == ptr_current_buffer); - - ptr_hotlist = weechat_hdata_pointer (buflist_hdata_buffer, - ptr_buffer, "hotlist"); - + /* name / short name */ ptr_name = weechat_hdata_string (buflist_hdata_buffer, ptr_buffer, "short_name"); if (!ptr_name) @@ -385,11 +367,10 @@ buflist_bar_item_buflist_cb (const void *pointer, void *data, } /* current buffer */ + current_buffer = (ptr_buffer == ptr_current_buffer); weechat_hashtable_set (buflist_hashtable_extra_vars, "current_buffer", (current_buffer) ? "1" : "0"); - if (current_buffer) - line_number_current_buffer = line_number; /* buffer number */ number = weechat_hdata_integer (buflist_hdata_buffer, @@ -410,7 +391,6 @@ buflist_bar_item_buflist_cb (const void *pointer, void *data, } snprintf (str_number2, sizeof (str_number2), str_format_number, number); - prev_number = number; /* buffer merged */ ptr_buffer_prev = weechat_hdata_move (buflist_hdata_buffer, @@ -508,6 +488,8 @@ buflist_bar_item_buflist_cb (const void *pointer, void *data, buflist_config_format_name)); /* hotlist */ + ptr_hotlist = weechat_hdata_pointer (buflist_hdata_buffer, + ptr_buffer, "hotlist"); ptr_hotlist_format = weechat_config_string ( buflist_config_format_hotlist_level_none); ptr_hotlist_priority = hotlist_priority_none; @@ -586,6 +568,26 @@ buflist_bar_item_buflist_cb (const void *pointer, void *data, "format_lag", ""); } + /* check condition: if false, the buffer is not displayed */ + condition = weechat_string_eval_expression ( + weechat_config_string (buflist_config_look_display_conditions), + buflist_hashtable_pointers, + buflist_hashtable_extra_vars, + buflist_hashtable_options_conditions); + rc = (condition && (strcmp (condition, "1") == 0)); + if (condition) + free (condition); + if (!rc) + continue; + + /* add buffer in list */ + weechat_arraylist_add (buflist_list_buffers[item_index], ptr_buffer); + + /* set some other variables */ + if (current_buffer) + line_number_current_buffer = line_number; + prev_number = number; + /* build string */ line = weechat_string_eval_expression ( (current_buffer) ? ptr_format_current : ptr_format,