summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--doc/en/weechat_plugin_api.en.txt56
-rw-r--r--doc/fr/weechat_plugin_api.fr.txt57
-rw-r--r--doc/it/weechat_plugin_api.it.txt87
-rw-r--r--src/gui/gui-buffer.c70
-rw-r--r--src/gui/gui-buffer.h4
-rw-r--r--src/gui/gui-filter.c32
-rw-r--r--src/plugins/plugin.c1
-rw-r--r--src/plugins/scripts/lua/weechat-lua-api.c37
-rw-r--r--src/plugins/scripts/perl/weechat-perl-api.c34
-rw-r--r--src/plugins/scripts/python/weechat-python-api.c37
-rw-r--r--src/plugins/scripts/ruby/weechat-ruby-api.c38
-rw-r--r--src/plugins/scripts/tcl/weechat-tcl-api.c38
-rw-r--r--src/plugins/weechat-plugin.h5
14 files changed, 453 insertions, 46 deletions
diff --git a/ChangeLog b/ChangeLog
index 8198d22fa..c85de8ca5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,7 @@
WeeChat ChangeLog
=================
Sébastien Helleu <flashcode@flashtux.org>
-v0.3.5-dev, 2011-03-10
+v0.3.5-dev, 2011-03-11
Version 0.3.5 (under dev!)
@@ -35,6 +35,7 @@ Version 0.3.5 (under dev!)
* core: dynamically allocate color pairs (extended colors can be used without
being added with command "/color")
* core: allow background for nick colors (using ":")
+* api: add new function buffer_match_list
* irc: add new option irc.look.smart_filter_nick
* irc: ignore join if nick is not self nick and if channel buffer does not exist
(bug #32667)
diff --git a/doc/en/weechat_plugin_api.en.txt b/doc/en/weechat_plugin_api.en.txt
index 7edfa13f9..d92036720 100644
--- a/doc/en/weechat_plugin_api.en.txt
+++ b/doc/en/weechat_plugin_api.en.txt
@@ -8881,6 +8881,62 @@ str = weechat.buffer_string_replace_local_var(my_buffer, "test with $toto")
# str contains "test with abc"
----------------------------------------
+weechat_buffer_match_list
+^^^^^^^^^^^^^^^^^^^^^^^^^
+
+_New in version 0.3.5._
+
+Check if buffer matches a list of buffers.
+
+Prototype:
+
+[source,C]
+----------------------------------------
+int weechat_buffer_match_list (struct t_gui_buffer *buffer, const char *string);
+----------------------------------------
+
+Arguments:
+
+* 'buffer': buffer pointer
+* 'string': comma-separated list of buffers:
+** "*" means all buffers
+** name beginning with "!" is excluded
+** name can start or end with "*" to match many buffers
+
+Return value:
+
+* 1 if buffer matches list of buffers, 0 otherwise
+
+C example:
+
+[source,C]
+----------------------------------------
+struct t_gui_buffer *buffer = weechat_buffer_search ("irc", "freenode.#weechat");
+if (buffer)
+{
+ weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "*")); /* 1 */
+ weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "*,!*#weechat*")); /* 0 */
+ weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "irc.freenode.*")); /* 1 */
+ weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "irc.oftc.*,python.*")); /* 0 */
+}
+----------------------------------------
+
+Script (Python):
+
+[source,python]
+----------------------------------------
+# prototype
+match = weechat.buffer_match_list(buffer, string)
+
+# example
+buffer = weechat.buffer_search("irc", "freenode.#weechat")
+if buffer:
+ weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "*")) # 1
+ weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "*,!*#weechat*")) # 0
+ weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "irc.freenode.*")) # 1
+ weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "irc.oftc.*,python.*")) # 0
+----------------------------------------
+
[[windows]]
Windows
~~~~~~~
diff --git a/doc/fr/weechat_plugin_api.fr.txt b/doc/fr/weechat_plugin_api.fr.txt
index 0c87378c3..cfaebacf1 100644
--- a/doc/fr/weechat_plugin_api.fr.txt
+++ b/doc/fr/weechat_plugin_api.fr.txt
@@ -9025,6 +9025,63 @@ str = weechat.buffer_string_replace_local_var(my_buffer, "test avec $toto")
# str contient "test avec abc"
----------------------------------------
+weechat_buffer_match_list
+^^^^^^^^^^^^^^^^^^^^^^^^^
+
+_Nouveau dans la version 0.3.5._
+
+Vérifie si le tampon correspond à la liste de tampons.
+
+Prototype :
+
+[source,C]
+----------------------------------------
+int weechat_buffer_match_list (struct t_gui_buffer *buffer, const char *string);
+----------------------------------------
+
+Paramètres :
+
+* 'buffer' : pointeur vers le tampon
+* 'string' : liste de tampons, séparés par des virgules :
+** "*" signigie tous les tampons
+** un nom commençant par "!" est exclu
+** un nom peut commencer ou se terminer par "*" pour correspondre à plusieurs
+ tampons
+
+Valeur de retour :
+
+* 1 si le tampon correspond à la liste de tampons, 0 sinon
+
+Exemple en C :
+
+[source,C]
+----------------------------------------
+struct t_gui_buffer *buffer = weechat_buffer_search ("irc", "freenode.#weechat");
+if (buffer)
+{
+ weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "*")); /* 1 */
+ weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "*,!*#weechat*")); /* 0 */
+ weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "irc.freenode.*")); /* 1 */
+ weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "irc.oftc.*,python.*")); /* 0 */
+}
+----------------------------------------
+
+Script (Python) :
+
+[source,python]
+----------------------------------------
+# prototype
+match = weechat.buffer_match_list(buffer, string)
+
+# exemple
+buffer = weechat.buffer_search("irc", "freenode.#weechat")
+if buffer:
+ weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "*")) # 1
+ weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "*,!*#weechat*")) # 0
+ weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "irc.freenode.*")) # 1
+ weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "irc.oftc.*,python.*")) # 0
+----------------------------------------
+
[[windows]]
Fenêtres
~~~~~~~~
diff --git a/doc/it/weechat_plugin_api.it.txt b/doc/it/weechat_plugin_api.it.txt
index 97ccf821b..ee9708b61 100644
--- a/doc/it/weechat_plugin_api.it.txt
+++ b/doc/it/weechat_plugin_api.it.txt
@@ -1290,7 +1290,7 @@ _Novità nella versione 0.3.2._
Codifica una stringa in base64.
-Prototype:
+Prototipo:
[source,C]
----------------------------------------
@@ -1361,7 +1361,7 @@ _Novità nella versione 0.3.2._
Verifica che il primo carattere della stringa sia un carattere comando
(il comando carattere predefinito è '/').
-Prototype:
+Prototipo:
[source,C]
----------------------------------------
@@ -1389,7 +1389,7 @@ Script (Python):
[source,python]
----------------------------------------
-# prototype
+# prototipo
is_cmdchar = weechat.string_is_command_char(string)
# esempi
@@ -1405,7 +1405,7 @@ _Novità nella versione 0.3.2._
Restituisce il puntatore al testo in input per il buffer (puntatore all'interno
dell'argomento "string"), oppure NULL se è un comando.
-Prototype:
+Prototipo:
[source,C]
----------------------------------------
@@ -1433,7 +1433,7 @@ Script (Python):
[source,python]
----------------------------------------
-# prototype
+# prototipo
str = weechat.string_input_for_buffer(string)
# esempi
@@ -2947,7 +2947,7 @@ struct t_hashtable *weechat_hashtable_new (int size,
const void *key2));
----------------------------------------
-Arguments:
+Argomenti:
* 'size': dimensione dell'array interno per memorizzare le chiavi con hash, un
valore più alto usa più memoria, ma ha migliori performance. (questo *non* è
@@ -3007,7 +3007,7 @@ int weechat_hashtable_set_with_size (struct t_hashtable *hashtable,
const void *value, int value_size);
----------------------------------------
-Arguments:
+Argomenti:
* 'hashtable': puntatore alla tabella hash
* 'key': puntatore alla chiave
@@ -3222,7 +3222,7 @@ _Novità nella versione 0.3.4._
Restituisce il valore stringa della proprietà di una tabella hash.
-Prototype:
+Prototipo:
[source,C]
----------------------------------------
@@ -4039,7 +4039,7 @@ void weechat_config_search_section_option (struct t_config_file *config_file,
struct t_config_option **option_found);
----------------------------------------
-Arguments:
+Argomenti:
* 'config_file': puntatore al file di configurazione
* 'section': puntatore alla sezione
@@ -7924,7 +7924,7 @@ _Novità nella versione 0.3.4._
Hook su una informazione (la callback prende e restituisce una tabella hash).
-Prototype:
+Prototipo:
[source,C]
----------------------------------------
@@ -7981,7 +7981,7 @@ Script (Python):
[source,python]
----------------------------------------
-# prototype
+# prototipo
hook = weechat.hook_info_hashtable(info_name, description, args_description,
output_description, callback, callback_data)
@@ -8942,6 +8942,65 @@ str = weechat.buffer_string_replace_local_var(my_buffer, "test with $toto")
# str contains "test with abc"
----------------------------------------
+weechat_buffer_match_list
+^^^^^^^^^^^^^^^^^^^^^^^^^
+
+_Novità nella versione 0.3.5._
+
+// TRANSLATION MISSING
+Check if buffer matches a list of buffers.
+
+Prototipo:
+
+[source,C]
+----------------------------------------
+int weechat_buffer_match_list (struct t_gui_buffer *buffer, const char *string);
+----------------------------------------
+
+Argomenti:
+
+* 'buffer': puntatore al buffer
+// TRANSLATION MISSING
+* 'string': comma-separated list of buffers:
+** "*" means all buffers
+** name beginning with "!" is excluded
+** name can start or end with "*" to match many buffers
+
+Valore restituito:
+
+// TRANSLATION MISSING
+* 1 if buffer matches list of buffers, 0 otherwise
+
+Esempio in C:
+
+[source,C]
+----------------------------------------
+struct t_gui_buffer *buffer = weechat_buffer_search ("irc", "freenode.#weechat");
+if (buffer)
+{
+ weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "*")); /* 1 */
+ weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "*,!*#weechat*")); /* 0 */
+ weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "irc.freenode.*")); /* 1 */
+ weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "irc.oftc.*,python.*")); /* 0 */
+}
+----------------------------------------
+
+Script (Python):
+
+[source,python]
+----------------------------------------
+# prototipo
+match = weechat.buffer_match_list(buffer, string)
+
+# esempio
+buffer = weechat.buffer_search("irc", "freenode.#weechat")
+if buffer:
+ weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "*")) # 1
+ weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "*,!*#weechat*")) # 0
+ weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "irc.freenode.*")) # 1
+ weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "irc.oftc.*,python.*")) # 0
+----------------------------------------
+
[[windows]]
Finestre
~~~~~~~~
@@ -9663,7 +9722,7 @@ Argomenti:
"0" = gruppo nascosto, "1" = gruppo visibile
|========================================
-C examples:
+Esempio in C:
[source,C]
----------------------------------------
@@ -10563,7 +10622,7 @@ struct t_hashtable *weechat_info_get_hashtable (const char *info_name,
struct t_hashtable *hashtable);
----------------------------------------
-Arguments:
+Argomenti:
* 'info_name': nome della info da leggere
include::autogen/plugin_api/infos_hashtable.txt[]
@@ -10608,7 +10667,7 @@ Script (Python):
[source,python]
----------------------------------------
-# prototype
+# prototipo
dict = weechat.info_get_hashtable(info_name, dict_in)
# esempio
diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c
index 8e0f7cf08..8c9cc4bb5 100644
--- a/src/gui/gui-buffer.c
+++ b/src/gui/gui-buffer.c
@@ -618,6 +618,76 @@ gui_buffer_string_replace_local_var (struct t_gui_buffer *buffer,
}
/*
+ * gui_buffer_full_name_match_list: return 1 if full name of buffer matches
+ * list of buffers
+ */
+
+int
+gui_buffer_full_name_match_list (const char *full_name,
+ int num_buffers, char **buffers)
+{
+ int i, match;
+ char *ptr_name;
+
+ match = 0;
+
+ for (i = 0; i < num_buffers; i++)
+ {
+ ptr_name = buffers[i];
+ if (ptr_name[0] == '!')
+ ptr_name++;
+ if (string_match (full_name, ptr_name, 0))
+ {
+ if (buffers[i][0] == '!')
+ return 0;
+ else
+ match = 1;
+ }
+ }
+
+ return match;
+}
+
+/*
+ * gui_buffer_match_list: return 1 if buffer matches list of buffers
+ * list is a string with list of buffers, where
+ * exclusion is possible with char '!', and "*" means
+ * all buffers
+ * Examples:
+ * "*"
+ * "*,!*#weechat*"
+ * "irc.freenode.*"
+ * "irc.freenode.*,irc.oftc.#channel"
+ * "irc.freenode.#weechat,irc.freenode.#other"
+ */
+
+int
+gui_buffer_match_list (struct t_gui_buffer *buffer, const char *string)
+{
+ char **buffers, buffer_full_name[512];
+ int num_buffers, match;
+
+ if (!string || !string[0])
+ return 0;
+
+ match = 0;
+
+ buffers = string_split (string, ",", 0, 0, &num_buffers);
+ if (buffers)
+ {
+ snprintf (buffer_full_name, sizeof (buffer_full_name), "%s.%s",
+ (!buffer->plugin && buffer->plugin_name_for_upgrade) ?
+ buffer->plugin_name_for_upgrade : plugin_get_name (buffer->plugin),
+ buffer->name);
+ match = gui_buffer_full_name_match_list (buffer_full_name,
+ num_buffers, buffers);
+ string_free_split (buffers);
+ }
+
+ return match;
+}
+
+/*
* gui_buffer_set_plugin_for_upgrade: set plugin pointer for buffers with a
* given name (used after /upgrade)
*/
diff --git a/src/gui/gui-buffer.h b/src/gui/gui-buffer.h
index 25e944948..b21cc393a 100644
--- a/src/gui/gui-buffer.h
+++ b/src/gui/gui-buffer.h
@@ -220,6 +220,10 @@ extern struct t_gui_buffer *gui_buffer_new (struct t_weechat_plugin *plugin,
extern int gui_buffer_valid (struct t_gui_buffer *buffer);
extern char *gui_buffer_string_replace_local_var (struct t_gui_buffer *buffer,
const char *string);
+extern int gui_buffer_full_name_match_list (const char *full_name,
+ int num_buffers, char **buffers);
+extern int gui_buffer_match_list (struct t_gui_buffer *buffer,
+ const char *string);
extern void gui_buffer_set_plugin_for_upgrade (char *name,
struct t_weechat_plugin *plugin);
extern int gui_buffer_property_in_list (char *properties[], char *property);
diff --git a/src/gui/gui-filter.c b/src/gui/gui-filter.c
index 865fb7590..032fd4f9a 100644
--- a/src/gui/gui-filter.c
+++ b/src/gui/gui-filter.c
@@ -68,34 +68,6 @@ gui_filter_line_has_tag_no_filter (struct t_gui_line *line)
}
/*
- * gui_filter_match_buffer: return 1 if filters matches full name of buffer
- */
-
-int
-gui_filter_match_buffer (struct t_gui_filter *filter, const char *full_name)
-{
- int i, match;
- char *ptr_name;
-
- match = 0;
- for (i = 0; i < filter->num_buffers; i++)
- {
- ptr_name = filter->buffers[i];
- if (ptr_name[0] == '!')
- ptr_name++;
- if (string_match (full_name, ptr_name, 0))
- {
- if (filter->buffers[i][0] == '!')
- return 0;
- else
- match = 1;
- }
- }
-
- return match;
-}
-
-/*
* gui_filter_check_line: return 1 if a line should be displayed, or
* 0 if line is hidden (tag or regex found)
*/
@@ -119,7 +91,9 @@ gui_filter_check_line (struct t_gui_line *line, const char *buffer_full_name)
if (ptr_filter->enabled)
{
/* check buffer */
- if (gui_filter_match_buffer (ptr_filter, buffer_full_name))
+ if (gui_buffer_full_name_match_list (buffer_full_name,
+ ptr_filter->num_buffers,
+ ptr_filter->buffers))
{
if ((strcmp (ptr_filter->tags, "*") == 0)
|| (gui_line_match_tags (line,
diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c
index 771872023..771488656 100644
--- a/src/plugins/plugin.c
+++ b/src/plugins/plugin.c
@@ -619,6 +619,7 @@ plugin_load (const char *filename)
new_plugin->buffer_set = &gui_buffer_set;
new_plugin->buffer_set_pointer = &gui_buffer_set_pointer;
new_plugin->buffer_string_replace_local_var = &gui_buffer_string_replace_local_var;
+ new_plugin->buffer_match_list = &gui_buffer_match_list;
new_plugin->window_get_integer = &gui_window_get_integer;
new_plugin->window_get_string = &gui_window_get_string;
diff --git a/src/plugins/scripts/lua/weechat-lua-api.c b/src/plugins/scripts/lua/weechat-lua-api.c
index ba88f24db..f0b64af5d 100644
--- a/src/plugins/scripts/lua/weechat-lua-api.c
+++ b/src/plugins/scripts/lua/weechat-lua-api.c
@@ -5244,6 +5244,42 @@ weechat_lua_api_buffer_string_replace_local_var (lua_State *L)
}
/*
+ * weechat_lua_api_buffer_match_list: return 1 if buffer matches list of buffers
+ */
+
+static int
+weechat_lua_api_buffer_match_list (lua_State *L)
+{
+ const char *buffer, *string;
+ int n, value;
+
+ /* make C compiler happy */
+ (void) L;
+
+ if (!lua_current_script || !lua_current_script->name)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "buffer_match_list");
+ LUA_RETURN_INT(0);
+ }
+
+ n = lua_gettop (lua_current_interpreter);
+
+ if (n < 2)
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "buffer_match_list");
+ LUA_RETURN_INT(0);
+ }
+
+ buffer = lua_tostring (lua_current_interpreter, -2);
+ string = lua_tostring (lua_current_interpreter, -1);
+
+ value = weechat_buffer_match_list (script_str2ptr (buffer),
+ string);
+
+ LUA_RETURN_INT(value);
+}
+
+/*
* weechat_lua_api_current_window: get current window
*/
@@ -7769,6 +7805,7 @@ const struct luaL_reg weechat_lua_api_funcs[] = {
{ "buffer_get_pointer", &weechat_lua_api_buffer_get_pointer },
{ "buffer_set", &weechat_lua_api_buffer_set },
{ "buffer_string_replace_local_var", &weechat_lua_api_buffer_string_replace_local_var },
+ { "buffer_match_list", &weechat_lua_api_buffer_match_list },
{ "current_window", &weechat_lua_api_current_window },
{ "window_get_integer", &weechat_lua_api_window_get_integer },
{ "window_get_string", &weechat_lua_api_window_get_string },
diff --git a/src/plugins/scripts/perl/weechat-perl-api.c b/src/plugins/scripts/perl/weechat-perl-api.c
index c652aabab..6ea96f1bc 100644
--- a/src/plugins/scripts/perl/weechat-perl-api.c
+++ b/src/plugins/scripts/perl/weechat-perl-api.c
@@ -4766,6 +4766,39 @@ XS (XS_weechat_api_buffer_string_replace_local_var)
}
/*
+ * weechat::buffer_match_list: return 1 if buffer matches list of buffers
+ */
+
+XS (XS_weechat_api_buffer_match_list)
+{
+ char *buffer, *string;
+ int value;
+ dXSARGS;
+
+ /* make C compiler happy */
+ (void) cv;
+
+ if (!perl_current_script || !perl_current_script->name)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "buffer_match_list");
+ PERL_RETURN_INT(0);
+ }
+
+ if (items < 2)
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "buffer_match_list");
+ PERL_RETURN_INT(0);
+ }
+
+ buffer = SvPV (ST (0), PL_na);
+ string = SvPV (ST (1), PL_na);
+
+ value = weechat_buffer_match_list (script_str2ptr (buffer), string);
+
+ PERL_RETURN_INT(value);
+}
+
+/*
* weechat::current_window: get current window
*/
@@ -6707,6 +6740,7 @@ weechat_perl_api_init (pTHX)
newXS ("weechat::buffer_get_pointer", XS_weechat_api_buffer_get_pointer, "weechat");
newXS ("weechat::buffer_set", XS_weechat_api_buffer_set, "weechat");
newXS ("weechat::buffer_string_replace_local_var", XS_weechat_api_buffer_string_replace_local_var, "weechat");
+ newXS ("weechat::buffer_match_list", XS_weechat_api_buffer_match_list, "weechat");
newXS ("weechat::current_window", XS_weechat_api_current_window, "weechat");
newXS ("weechat::window_get_integer", XS_weechat_api_window_get_integer, "weechat");
newXS ("weechat::window_get_string", XS_weechat_api_window_get_string, "weechat");
diff --git a/src/plugins/scripts/python/weechat-python-api.c b/src/plugins/scripts/python/weechat-python-api.c
index e306d00fc..58dd89af1 100644
--- a/src/plugins/scripts/python/weechat-python-api.c
+++ b/src/plugins/scripts/python/weechat-python-api.c
@@ -4853,7 +4853,7 @@ weechat_python_api_buffer_unmerge (PyObject *self, PyObject *args)
}
/*
- * weechat_python_api_buffer_get_integer get a buffer property as integer
+ * weechat_python_api_buffer_get_integer: get a buffer property as integer
*/
static PyObject *
@@ -5022,6 +5022,40 @@ weechat_python_api_buffer_string_replace_local_var (PyObject *self, PyObject *ar
}
/*
+ * weechat_python_api_buffer_match_list: return 1 if buffer matches list of
+ * buffers
+ */
+
+static PyObject *
+weechat_python_api_buffer_match_list (PyObject *self, PyObject *args)
+{
+ char *buffer, *string;
+ int value;
+
+ /* make C compiler happy */
+ (void) self;
+
+ if (!python_current_script || !python_current_script->name)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "buffer_match_list");
+ PYTHON_RETURN_INT(0);
+ }
+
+ buffer = NULL;
+ string = NULL;
+
+ if (!PyArg_ParseTuple (args, "ss", &buffer, &string))
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "buffer_match_list");
+ PYTHON_RETURN_INT(0);
+ }
+
+ value = weechat_buffer_match_list (script_str2ptr (buffer), string);
+
+ PYTHON_RETURN_INT(value);
+}
+
+/*
* weechat_python_api_current_window: get current window
*/
@@ -7040,6 +7074,7 @@ PyMethodDef weechat_python_funcs[] =
{ "buffer_get_pointer", &weechat_python_api_buffer_get_pointer, METH_VARARGS, "" },
{ "buffer_set", &weechat_python_api_buffer_set, METH_VARARGS, "" },
{ "buffer_string_replace_local_var", &weechat_python_api_buffer_string_replace_local_var, METH_VARARGS, "" },
+ { "buffer_match_list", &weechat_python_api_buffer_match_list, METH_VARARGS, "" },
{ "current_window", &weechat_python_api_current_window, METH_VARARGS, "" },
{ "window_get_integer", &weechat_python_api_window_get_integer, METH_VARARGS, "" },
{ "window_get_string", &weechat_python_api_window_get_string, METH_VARARGS, "" },
diff --git a/src/plugins/scripts/ruby/weechat-ruby-api.c b/src/plugins/scripts/ruby/weechat-ruby-api.c
index cc97b5785..af75cad78 100644
--- a/src/plugins/scripts/ruby/weechat-ruby-api.c
+++ b/src/plugins/scripts/ruby/weechat-ruby-api.c
@@ -5437,6 +5437,43 @@ weechat_ruby_api_buffer_string_replace_local_var (VALUE class, VALUE buffer, VAL
}
/*
+ * weechat_ruby_api_buffer_match_list: return 1 if buffer matches list of buffers
+ */
+
+static VALUE
+weechat_ruby_api_buffer_match_list (VALUE class, VALUE buffer, VALUE string)
+{
+ char *c_buffer, *c_string;
+ int value;
+
+ /* make C compiler happy */
+ (void) class;
+
+ if (!ruby_current_script || !ruby_current_script->name)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "buffer_match_list");
+ RUBY_RETURN_INT(0);
+ }
+
+ if (NIL_P (buffer) || NIL_P (string))
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "buffer_match_list");
+ RUBY_RETURN_INT(0);
+ }
+
+ Check_Type (buffer, T_STRING);
+ Check_Type (string, T_STRING);
+
+ c_buffer = StringValuePtr (buffer);
+ c_string = StringValuePtr (string);
+
+ value = weechat_buffer_match_list (script_str2ptr (c_buffer),
+ c_string);
+
+ RUBY_RETURN_INT(value);
+}
+
+/*
* weechat_ruby_api_current_window: get current window
*/
@@ -7706,6 +7743,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
rb_define_module_function (ruby_mWeechat, "buffer_get_pointer", &weechat_ruby_api_buffer_get_pointer, 2);
rb_define_module_function (ruby_mWeechat, "buffer_set", &weechat_ruby_api_buffer_set, 3);
rb_define_module_function (ruby_mWeechat, "buffer_string_replace_local_var", &weechat_ruby_api_buffer_string_replace_local_var, 2);
+ rb_define_module_function (ruby_mWeechat, "buffer_match_list", &weechat_ruby_api_buffer_match_list, 2);
rb_define_module_function (ruby_mWeechat, "current_window", &weechat_ruby_api_current_window, 0);
rb_define_module_function (ruby_mWeechat, "window_get_integer", &weechat_ruby_api_window_get_integer, 2);
rb_define_module_function (ruby_mWeechat, "window_get_string", &weechat_ruby_api_window_get_string, 2);
diff --git a/src/plugins/scripts/tcl/weechat-tcl-api.c b/src/plugins/scripts/tcl/weechat-tcl-api.c
index f5db112d3..9f870efb9 100644
--- a/src/plugins/scripts/tcl/weechat-tcl-api.c
+++ b/src/plugins/scripts/tcl/weechat-tcl-api.c
@@ -5328,6 +5328,42 @@ weechat_tcl_api_buffer_string_replace_local_var (ClientData clientData, Tcl_Inte
}
/*
+ * weechat_tcl_api_buffer_match_list: return 1 if buffers matches list of buffers
+ */
+
+static int
+weechat_tcl_api_buffer_match_list (ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[])
+{
+ Tcl_Obj *objp;
+ char *buffer, *string;
+ int result;
+ int i;
+
+ /* make C compiler happy */
+ (void) clientData;
+
+ if (!tcl_current_script || !tcl_current_script->name)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "buffer_match_list");
+ TCL_RETURN_INT(0);
+ }
+
+ if (objc < 3)
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "buffer_match_list");
+ TCL_RETURN_INT(0);
+ }
+
+ buffer = Tcl_GetStringFromObj (objv[1], &i);
+ string = Tcl_GetStringFromObj (objv[2], &i);
+
+ result = weechat_buffer_match_list (script_str2ptr (buffer), string);
+
+ TCL_RETURN_INT(result);
+}
+
+/*
* weechat_tcl_api_current_window: get current window
*/
@@ -7650,6 +7686,8 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
weechat_tcl_api_buffer_set, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::buffer_string_replace_local_var",
weechat_tcl_api_buffer_string_replace_local_var, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
+ Tcl_CreateObjCommand (interp, "weechat::buffer_match_list",
+ weechat_tcl_api_buffer_match_list, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::current_window",
weechat_tcl_api_current_window, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::window_get_integer",
diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h
index c5a8433d1..92b6c40b2 100644
--- a/src/plugins/weechat-plugin.h
+++ b/src/plugins/weechat-plugin.h
@@ -45,7 +45,7 @@ struct timeval;
*/
/* API version (used to check that plugin has same API and can be loaded) */
-#define WEECHAT_PLUGIN_API_VERSION "20110302-01"
+#define WEECHAT_PLUGIN_API_VERSION "20110311-01"
/* macros for defining plugin infos */
#define WEECHAT_PLUGIN_NAME(__name) \
@@ -597,6 +597,7 @@ struct t_weechat_plugin
const char *property, void *pointer);
char *(*buffer_string_replace_local_var) (struct t_gui_buffer *buffer,
const char *string);
+ int (*buffer_match_list) (struct t_gui_buffer *buffer, const char *string);
/* windows */
int (*window_get_integer) (struct t_gui_window *window,
@@ -1255,6 +1256,8 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
weechat_plugin->buffer_set_pointer(__buffer, __property, __pointer)
#define weechat_buffer_string_replace_local_var(__buffer, __string) \
weechat_plugin->buffer_string_replace_local_var(__buffer, __string)
+#define weechat_buffer_match_list(__buffer, __string) \
+ weechat_plugin->buffer_match_list(__buffer, __string)
/* windows */
#define weechat_window_get_integer(__window, __property) \