1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-01 15:26:37 +02:00

script: add option script.look.quiet_actions (no messages when installing/removing/loading/unloading scripts on script buffer)

This commit is contained in:
Sebastien Helleu
2012-08-21 18:57:49 +02:00
parent cc5118b3b6
commit 129f32ce8e
69 changed files with 1113 additions and 705 deletions
+48 -24
View File
@@ -489,9 +489,12 @@ weechat_guile_unload_name (const char *name)
if (ptr_script)
{
weechat_guile_unload (ptr_script);
weechat_printf (NULL,
weechat_gettext ("%s: script \"%s\" unloaded"),
GUILE_PLUGIN_NAME, name);
if (!guile_quiet)
{
weechat_printf (NULL,
weechat_gettext ("%s: script \"%s\" unloaded"),
GUILE_PLUGIN_NAME, name);
}
}
else
{
@@ -531,9 +534,12 @@ weechat_guile_reload_name (const char *name)
if (filename)
{
weechat_guile_unload (ptr_script);
weechat_printf (NULL,
weechat_gettext ("%s: script \"%s\" unloaded"),
GUILE_PLUGIN_NAME, name);
if (!guile_quiet)
{
weechat_printf (NULL,
weechat_gettext ("%s: script \"%s\" unloaded"),
GUILE_PLUGIN_NAME, name);
}
weechat_guile_load (filename);
free (filename);
}
@@ -554,7 +560,7 @@ int
weechat_guile_command_cb (void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
char *path_script;
char *ptr_name, *path_script;
SCM value;
/* make C compiler happy */
@@ -604,24 +610,40 @@ weechat_guile_command_cb (void *data, struct t_gui_buffer *buffer,
plugin_script_display_list (weechat_guile_plugin, guile_scripts,
argv_eol[2], 1);
}
else if (weechat_strcasecmp (argv[1], "load") == 0)
else if ((weechat_strcasecmp (argv[1], "load") == 0)
|| (weechat_strcasecmp (argv[1], "reload") == 0)
|| (weechat_strcasecmp (argv[1], "unload") == 0))
{
/* load Guile script */
path_script = plugin_script_search_path (weechat_guile_plugin,
argv_eol[2]);
weechat_guile_load ((path_script) ? path_script : argv_eol[2]);
if (path_script)
free (path_script);
}
else if (weechat_strcasecmp (argv[1], "reload") == 0)
{
/* reload one Guile script */
weechat_guile_reload_name (argv_eol[2]);
}
else if (weechat_strcasecmp (argv[1], "unload") == 0)
{
/* unload Guile script */
weechat_guile_unload_name (argv_eol[2]);
ptr_name = argv_eol[2];
if (strncmp (ptr_name, "-q ", 3) == 0)
{
guile_quiet = 1;
ptr_name += 3;
while (ptr_name[0] == ' ')
{
ptr_name++;
}
}
if (weechat_strcasecmp (argv[1], "load") == 0)
{
/* load Guile script */
path_script = plugin_script_search_path (weechat_guile_plugin,
ptr_name);
weechat_guile_load ((path_script) ? path_script : ptr_name);
if (path_script)
free (path_script);
}
else if (weechat_strcasecmp (argv[1], "reload") == 0)
{
/* reload one Guile script */
weechat_guile_reload_name (ptr_name);
}
else if (weechat_strcasecmp (argv[1], "unload") == 0)
{
/* unload Guile script */
weechat_guile_unload_name (ptr_name);
}
guile_quiet = 0;
}
else if (weechat_strcasecmp (argv[1], "eval") == 0)
{
@@ -767,6 +789,7 @@ weechat_guile_timer_action_cb (void *data, int remaining_calls)
guile_scripts,
&weechat_guile_unload,
&weechat_guile_load,
&guile_quiet,
&guile_action_install_list);
}
else if (data == &guile_action_remove_list)
@@ -774,6 +797,7 @@ weechat_guile_timer_action_cb (void *data, int remaining_calls)
plugin_script_action_remove (weechat_guile_plugin,
guile_scripts,
&weechat_guile_unload,
&guile_quiet,
&guile_action_remove_list);
}
}
+48 -24
View File
@@ -461,9 +461,12 @@ weechat_lua_unload_name (const char *name)
if (ptr_script)
{
weechat_lua_unload (ptr_script);
weechat_printf (NULL,
weechat_gettext ("%s: script \"%s\" unloaded"),
LUA_PLUGIN_NAME, name);
if (!lua_quiet)
{
weechat_printf (NULL,
weechat_gettext ("%s: script \"%s\" unloaded"),
LUA_PLUGIN_NAME, name);
}
}
else
{
@@ -490,9 +493,12 @@ weechat_lua_reload_name (const char *name)
if (filename)
{
weechat_lua_unload (ptr_script);
weechat_printf (NULL,
weechat_gettext ("%s: script \"%s\" unloaded"),
LUA_PLUGIN_NAME, name);
if (!lua_quiet)
{
weechat_printf (NULL,
weechat_gettext ("%s: script \"%s\" unloaded"),
LUA_PLUGIN_NAME, name);
}
weechat_lua_load (filename);
free (filename);
}
@@ -526,7 +532,7 @@ int
weechat_lua_command_cb (void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
char *path_script;
char *ptr_name, *path_script;
/* make C compiler happy */
(void) data;
@@ -575,24 +581,40 @@ weechat_lua_command_cb (void *data, struct t_gui_buffer *buffer,
plugin_script_display_list (weechat_lua_plugin, lua_scripts,
argv_eol[2], 1);
}
else if (weechat_strcasecmp (argv[1], "load") == 0)
else if ((weechat_strcasecmp (argv[1], "load") == 0)
|| (weechat_strcasecmp (argv[1], "reload") == 0)
|| (weechat_strcasecmp (argv[1], "unload") == 0))
{
/* load Lua script */
path_script = plugin_script_search_path (weechat_lua_plugin,
argv_eol[2]);
weechat_lua_load ((path_script) ? path_script : argv_eol[2]);
if (path_script)
free (path_script);
}
else if (weechat_strcasecmp (argv[1], "reload") == 0)
{
/* reload one Lua script */
weechat_lua_reload_name (argv_eol[2]);
}
else if (weechat_strcasecmp (argv[1], "unload") == 0)
{
/* unload Lua script */
weechat_lua_unload_name (argv_eol[2]);
ptr_name = argv_eol[2];
if (strncmp (ptr_name, "-q ", 3) == 0)
{
lua_quiet = 1;
ptr_name += 3;
while (ptr_name[0] == ' ')
{
ptr_name++;
}
}
if (weechat_strcasecmp (argv[1], "load") == 0)
{
/* load Lua script */
path_script = plugin_script_search_path (weechat_lua_plugin,
ptr_name);
weechat_lua_load ((path_script) ? path_script : ptr_name);
if (path_script)
free (path_script);
}
else if (weechat_strcasecmp (argv[1], "reload") == 0)
{
/* reload one Lua script */
weechat_lua_reload_name (ptr_name);
}
else if (weechat_strcasecmp (argv[1], "unload") == 0)
{
/* unload Lua script */
weechat_lua_unload_name (ptr_name);
}
lua_quiet = 0;
}
else
{
@@ -723,6 +745,7 @@ weechat_lua_timer_action_cb (void *data, int remaining_calls)
lua_scripts,
&weechat_lua_unload,
&weechat_lua_load,
&lua_quiet,
&lua_action_install_list);
}
else if (data == &lua_action_remove_list)
@@ -730,6 +753,7 @@ weechat_lua_timer_action_cb (void *data, int remaining_calls)
plugin_script_action_remove (weechat_lua_plugin,
lua_scripts,
&weechat_lua_unload,
&lua_quiet,
&lua_action_remove_list);
}
}
+48 -24
View File
@@ -626,9 +626,12 @@ weechat_perl_unload_name (const char *name)
if (ptr_script)
{
weechat_perl_unload (ptr_script);
weechat_printf (NULL,
weechat_gettext ("%s: script \"%s\" unloaded"),
PERL_PLUGIN_NAME, name);
if (!perl_quiet)
{
weechat_printf (NULL,
weechat_gettext ("%s: script \"%s\" unloaded"),
PERL_PLUGIN_NAME, name);
}
}
else
{
@@ -668,9 +671,12 @@ weechat_perl_reload_name (const char *name)
if (filename)
{
weechat_perl_unload (ptr_script);
weechat_printf (NULL,
weechat_gettext ("%s: script \"%s\" unloaded"),
PERL_PLUGIN_NAME, name);
if (!perl_quiet)
{
weechat_printf (NULL,
weechat_gettext ("%s: script \"%s\" unloaded"),
PERL_PLUGIN_NAME, name);
}
weechat_perl_load (filename);
free (filename);
}
@@ -691,7 +697,7 @@ int
weechat_perl_command_cb (void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
char *path_script;
char *ptr_name, *path_script;
/* make C compiler happy */
(void) data;
@@ -740,24 +746,40 @@ weechat_perl_command_cb (void *data, struct t_gui_buffer *buffer,
plugin_script_display_list (weechat_perl_plugin, perl_scripts,
argv_eol[2], 1);
}
else if (weechat_strcasecmp (argv[1], "load") == 0)
else if ((weechat_strcasecmp (argv[1], "load") == 0)
|| (weechat_strcasecmp (argv[1], "reload") == 0)
|| (weechat_strcasecmp (argv[1], "unload") == 0))
{
/* load Perl script */
path_script = plugin_script_search_path (weechat_perl_plugin,
argv_eol[2]);
weechat_perl_load ((path_script) ? path_script : argv_eol[2]);
if (path_script)
free (path_script);
}
else if (weechat_strcasecmp (argv[1], "reload") == 0)
{
/* reload one Perl script */
weechat_perl_reload_name (argv_eol[2]);
}
else if (weechat_strcasecmp (argv[1], "unload") == 0)
{
/* unload Perl script */
weechat_perl_unload_name (argv_eol[2]);
ptr_name = argv_eol[2];
if (strncmp (ptr_name, "-q ", 3) == 0)
{
perl_quiet = 1;
ptr_name += 3;
while (ptr_name[0] == ' ')
{
ptr_name++;
}
}
if (weechat_strcasecmp (argv[1], "load") == 0)
{
/* load Perl script */
path_script = plugin_script_search_path (weechat_perl_plugin,
ptr_name);
weechat_perl_load ((path_script) ? path_script : ptr_name);
if (path_script)
free (path_script);
}
else if (weechat_strcasecmp (argv[1], "reload") == 0)
{
/* reload one Perl script */
weechat_perl_reload_name (ptr_name);
}
else if (weechat_strcasecmp (argv[1], "unload") == 0)
{
/* unload Perl script */
weechat_perl_unload_name (ptr_name);
}
perl_quiet = 0;
}
else
{
@@ -888,6 +910,7 @@ weechat_perl_timer_action_cb (void *data, int remaining_calls)
perl_scripts,
&weechat_perl_unload,
&weechat_perl_load,
&perl_quiet,
&perl_action_install_list);
}
else if (data == &perl_action_remove_list)
@@ -895,6 +918,7 @@ weechat_perl_timer_action_cb (void *data, int remaining_calls)
plugin_script_action_remove (weechat_perl_plugin,
perl_scripts,
&weechat_perl_unload,
&perl_quiet,
&perl_action_remove_list);
}
}
+42 -14
View File
@@ -138,9 +138,9 @@ plugin_script_init (struct t_weechat_plugin *weechat_plugin,
weechat_hook_command (weechat_plugin->name,
N_("list/load/unload scripts"),
N_("list|listfull [<name>]"
" || load <filename>"
" || load [-q] <filename>"
" || autoload"
" || reload|unload [<name>]"),
" || reload|unload [-q] [<name>]"),
N_(" list: list loaded scripts\n"
"listfull: list loaded scripts (verbose)\n"
" load: load a script\n"
@@ -153,7 +153,8 @@ plugin_script_init (struct t_weechat_plugin *weechat_plugin,
"unload all scripts)\n"
"filename: script (file) to load\n"
" name: a script name (name used in call to "
"\"register\" function)\n\n"
"\"register\" function)\n"
" -q: quiet mode: do not display messages\n\n"
"Without argument, this command "
"lists all loaded scripts."),
completion,
@@ -862,6 +863,7 @@ plugin_script_action_add (char **action_list, const char *name)
void
plugin_script_remove_file (struct t_weechat_plugin *weechat_plugin,
const char *name,
int quiet,
int display_error_if_no_script_removed)
{
int num_found, i;
@@ -878,9 +880,12 @@ plugin_script_remove_file (struct t_weechat_plugin *weechat_plugin,
num_found++;
if (unlink (path_script) == 0)
{
weechat_printf (NULL, _("%s: script removed: %s"),
weechat_plugin->name,
path_script);
if (!quiet)
{
weechat_printf (NULL, _("%s: script removed: %s"),
weechat_plugin->name,
path_script);
}
}
else
{
@@ -923,10 +928,11 @@ plugin_script_action_install (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *scripts,
void (*script_unload)(struct t_plugin_script *script),
int (*script_load)(const char *filename),
int *quiet,
char **list)
{
char **argv, *name, *ptr_base_name, *base_name, *new_path, *autoload_path;
char *symlink_path, str_signal[128];
char *symlink_path, str_signal[128], *ptr_list;
const char *dir_home, *dir_separator;
int argc, i, length, rc;
struct t_plugin_script *ptr_script;
@@ -934,7 +940,15 @@ plugin_script_action_install (struct t_weechat_plugin *weechat_plugin,
if (!*list)
return;
argv = weechat_string_split (*list, ",", 0, 0, &argc);
ptr_list = *list;
*quiet = 0;
if (strncmp (ptr_list, "-q ", 3) == 0)
{
*quiet = 1;
ptr_list += 3;
}
argv = weechat_string_split (ptr_list, ",", 0, 0, &argc);
if (argv)
{
for (i = 0; i < argc; i++)
@@ -953,7 +967,8 @@ plugin_script_action_install (struct t_weechat_plugin *weechat_plugin,
(*script_unload) (ptr_script);
/* remove script file(s) */
plugin_script_remove_file (weechat_plugin, base_name, 0);
plugin_script_remove_file (weechat_plugin, base_name,
*quiet, 0);
/* move file from install dir to language dir */
dir_home = weechat_info_get ("weechat_dir", "");
@@ -1016,10 +1031,12 @@ plugin_script_action_install (struct t_weechat_plugin *weechat_plugin,
weechat_string_free_split (argv);
}
*quiet = 0;
snprintf (str_signal, sizeof (str_signal),
"%s_script_installed", weechat_plugin->name);
weechat_hook_signal_send (str_signal, WEECHAT_HOOK_SIGNAL_STRING,
*list);
ptr_list);
free (*list);
*list = NULL;
@@ -1036,16 +1053,25 @@ void
plugin_script_action_remove (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *scripts,
void (*script_unload)(struct t_plugin_script *script),
int *quiet,
char **list)
{
char **argv, str_signal[128];
char **argv, str_signal[128], *ptr_list;
int argc, i;
struct t_plugin_script *ptr_script;
if (!*list)
return;
argv = weechat_string_split (*list, ",", 0, 0, &argc);
ptr_list = *list;
*quiet = 0;
if (strncmp (ptr_list, "-q ", 3) == 0)
{
*quiet = 1;
ptr_list += 3;
}
argv = weechat_string_split (ptr_list, ",", 0, 0, &argc);
if (argv)
{
for (i = 0; i < argc; i++)
@@ -1056,15 +1082,17 @@ plugin_script_action_remove (struct t_weechat_plugin *weechat_plugin,
(*script_unload) (ptr_script);
/* remove script file(s) */
plugin_script_remove_file (weechat_plugin, argv[i], 1);
plugin_script_remove_file (weechat_plugin, argv[i], *quiet, 1);
}
weechat_string_free_split (argv);
}
*quiet = 0;
snprintf (str_signal, sizeof (str_signal),
"%s_script_removed", weechat_plugin->name);
weechat_hook_signal_send (str_signal, WEECHAT_HOOK_SIGNAL_STRING,
*list);
ptr_list);
free (*list);
*list = NULL;
+2
View File
@@ -138,10 +138,12 @@ extern void plugin_script_action_install (struct t_weechat_plugin *weechat_plugi
struct t_plugin_script *scripts,
void (*script_unload)(struct t_plugin_script *script),
int (*script_load)(const char *filename),
int *quiet,
char **list);
extern void plugin_script_action_remove (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *scripts,
void (*script_unload)(struct t_plugin_script *script),
int *quiet,
char **list);
extern void plugin_script_display_list (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *scripts,
+48 -24
View File
@@ -825,9 +825,12 @@ weechat_python_unload_name (const char *name)
if (ptr_script)
{
weechat_python_unload (ptr_script);
weechat_printf (NULL,
weechat_gettext ("%s: script \"%s\" unloaded"),
PYTHON_PLUGIN_NAME, name);
if (!python_quiet)
{
weechat_printf (NULL,
weechat_gettext ("%s: script \"%s\" unloaded"),
PYTHON_PLUGIN_NAME, name);
}
}
else
{
@@ -867,9 +870,12 @@ weechat_python_reload_name (const char *name)
if (filename)
{
weechat_python_unload (ptr_script);
weechat_printf (NULL,
weechat_gettext ("%s: script \"%s\" unloaded"),
PYTHON_PLUGIN_NAME, name);
if (!python_quiet)
{
weechat_printf (NULL,
weechat_gettext ("%s: script \"%s\" unloaded"),
PYTHON_PLUGIN_NAME, name);
}
weechat_python_load (filename);
free (filename);
}
@@ -890,7 +896,7 @@ int
weechat_python_command_cb (void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
char *path_script;
char *ptr_name, *path_script;
/* make C compiler happy */
(void) data;
@@ -939,24 +945,40 @@ weechat_python_command_cb (void *data, struct t_gui_buffer *buffer,
plugin_script_display_list (weechat_python_plugin, python_scripts,
argv_eol[2], 1);
}
else if (weechat_strcasecmp (argv[1], "load") == 0)
else if ((weechat_strcasecmp (argv[1], "load") == 0)
|| (weechat_strcasecmp (argv[1], "reload") == 0)
|| (weechat_strcasecmp (argv[1], "unload") == 0))
{
/* load Python script */
path_script = plugin_script_search_path (weechat_python_plugin,
argv_eol[2]);
weechat_python_load ((path_script) ? path_script : argv_eol[2]);
if (path_script)
free (path_script);
}
else if (weechat_strcasecmp (argv[1], "reload") == 0)
{
/* reload one Python script */
weechat_python_reload_name (argv_eol[2]);
}
else if (weechat_strcasecmp (argv[1], "unload") == 0)
{
/* unload Python script */
weechat_python_unload_name (argv_eol[2]);
ptr_name = argv_eol[2];
if (strncmp (ptr_name, "-q ", 3) == 0)
{
python_quiet = 1;
ptr_name += 3;
while (ptr_name[0] == ' ')
{
ptr_name++;
}
}
if (weechat_strcasecmp (argv[1], "load") == 0)
{
/* load Python script */
path_script = plugin_script_search_path (weechat_python_plugin,
ptr_name);
weechat_python_load ((path_script) ? path_script : ptr_name);
if (path_script)
free (path_script);
}
else if (weechat_strcasecmp (argv[1], "reload") == 0)
{
/* reload one Python script */
weechat_python_reload_name (ptr_name);
}
else if (weechat_strcasecmp (argv[1], "unload") == 0)
{
/* unload Python script */
weechat_python_unload_name (ptr_name);
}
python_quiet = 0;
}
else
{
@@ -1123,6 +1145,7 @@ weechat_python_timer_action_cb (void *data, int remaining_calls)
python_scripts,
&weechat_python_unload,
&weechat_python_load,
&python_quiet,
&python_action_install_list);
}
else if (data == &python_action_remove_list)
@@ -1130,6 +1153,7 @@ weechat_python_timer_action_cb (void *data, int remaining_calls)
plugin_script_action_remove (weechat_python_plugin,
python_scripts,
&weechat_python_unload,
&python_quiet,
&python_action_remove_list);
}
}
+48 -24
View File
@@ -674,9 +674,12 @@ weechat_ruby_unload_name (const char *name)
if (ptr_script)
{
weechat_ruby_unload (ptr_script);
weechat_printf (NULL,
weechat_gettext ("%s: script \"%s\" unloaded"),
RUBY_PLUGIN_NAME, name);
if (!ruby_quiet)
{
weechat_printf (NULL,
weechat_gettext ("%s: script \"%s\" unloaded"),
RUBY_PLUGIN_NAME, name);
}
}
else
{
@@ -703,9 +706,12 @@ weechat_ruby_reload_name (const char *name)
if (filename)
{
weechat_ruby_unload (ptr_script);
weechat_printf (NULL,
weechat_gettext ("%s: script \"%s\" unloaded"),
RUBY_PLUGIN_NAME, name);
if (!ruby_quiet)
{
weechat_printf (NULL,
weechat_gettext ("%s: script \"%s\" unloaded"),
RUBY_PLUGIN_NAME, name);
}
weechat_ruby_load (filename);
free (filename);
}
@@ -739,7 +745,7 @@ int
weechat_ruby_command_cb (void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
char *path_script;
char *ptr_name, *path_script;
/* make C compiler happy */
(void) data;
@@ -788,24 +794,40 @@ weechat_ruby_command_cb (void *data, struct t_gui_buffer *buffer,
plugin_script_display_list (weechat_ruby_plugin, ruby_scripts,
argv_eol[2], 1);
}
else if (weechat_strcasecmp (argv[1], "load") == 0)
else if ((weechat_strcasecmp (argv[1], "load") == 0)
|| (weechat_strcasecmp (argv[1], "reload") == 0)
|| (weechat_strcasecmp (argv[1], "unload") == 0))
{
/* load Ruby script */
path_script = plugin_script_search_path (weechat_ruby_plugin,
argv_eol[2]);
weechat_ruby_load ((path_script) ? path_script : argv_eol[2]);
if (path_script)
free (path_script);
}
else if (weechat_strcasecmp (argv[1], "reload") == 0)
{
/* reload one Ruby script */
weechat_ruby_reload_name (argv_eol[2]);
}
else if (weechat_strcasecmp (argv[1], "unload") == 0)
{
/* unload Ruby script */
weechat_ruby_unload_name (argv_eol[2]);
ptr_name = argv_eol[2];
if (strncmp (ptr_name, "-q ", 3) == 0)
{
ruby_quiet = 1;
ptr_name += 3;
while (ptr_name[0] == ' ')
{
ptr_name++;
}
}
if (weechat_strcasecmp (argv[1], "load") == 0)
{
/* load Ruby script */
path_script = plugin_script_search_path (weechat_ruby_plugin,
ptr_name);
weechat_ruby_load ((path_script) ? path_script : ptr_name);
if (path_script)
free (path_script);
}
else if (weechat_strcasecmp (argv[1], "reload") == 0)
{
/* reload one Ruby script */
weechat_ruby_reload_name (ptr_name);
}
else if (weechat_strcasecmp (argv[1], "unload") == 0)
{
/* unload Ruby script */
weechat_ruby_unload_name (ptr_name);
}
ruby_quiet = 0;
}
else
{
@@ -936,6 +958,7 @@ weechat_ruby_timer_action_cb (void *data, int remaining_calls)
ruby_scripts,
&weechat_ruby_unload,
&weechat_ruby_load,
&ruby_quiet,
&ruby_action_install_list);
}
else if (data == &ruby_action_remove_list)
@@ -943,6 +966,7 @@ weechat_ruby_timer_action_cb (void *data, int remaining_calls)
plugin_script_action_remove (weechat_ruby_plugin,
ruby_scripts,
&weechat_ruby_unload,
&ruby_quiet,
&ruby_action_remove_list);
}
}
+63 -34
View File
@@ -37,7 +37,7 @@
char *script_actions = NULL;
void script_action_install ();
void script_action_install (int quiet);
/*
@@ -118,8 +118,9 @@ script_action_load (const char *name, int quiet)
/* execute command (for example: "/perl load iset.pl") */
snprintf (str_command, sizeof (str_command),
"/%s load %s",
"/%s load %s%s",
script_language[language],
(quiet && weechat_config_boolean (script_config_look_quiet_actions)) ? "-q " : "",
name);
weechat_command (NULL, str_command);
}
@@ -183,8 +184,9 @@ script_action_unload (const char *name, int quiet)
if (ptr_registered_name)
{
snprintf (str_command, sizeof (str_command),
"/%s unload %s",
"/%s unload %s%s",
script_language[language],
(quiet && weechat_config_boolean (script_config_look_quiet_actions)) ? "-q " : "",
ptr_registered_name);
weechat_command (NULL, str_command);
}
@@ -209,8 +211,9 @@ script_action_unload (const char *name, int quiet)
if (strcmp (ptr_registered_name, name) == 0)
{
snprintf (str_command, sizeof (str_command),
"/%s unload %s",
"/%s unload %s%s",
script_language[i],
(quiet && weechat_config_boolean (script_config_look_quiet_actions)) ? "-q " : "",
name);
weechat_command (NULL, str_command);
return;
@@ -287,8 +290,9 @@ script_action_reload (const char *name, int quiet)
if (ptr_registered_name)
{
snprintf (str_command, sizeof (str_command),
"/%s reload %s",
"/%s reload %s%s",
script_language[language],
(quiet && weechat_config_boolean (script_config_look_quiet_actions)) ? "-q " : "",
ptr_registered_name);
weechat_command (NULL, str_command);
}
@@ -313,8 +317,9 @@ script_action_reload (const char *name, int quiet)
if (strcmp (ptr_registered_name, name) == 0)
{
snprintf (str_command, sizeof (str_command),
"/%s reload %s",
"/%s reload %s%s",
script_language[i],
(quiet && weechat_config_boolean (script_config_look_quiet_actions)) ? "-q " : "",
name);
weechat_command (NULL, str_command);
return;
@@ -340,10 +345,9 @@ int
script_action_installnext_timer_cb (void *data, int remaining_calls)
{
/* make C compiler happy */
(void) data;
(void) remaining_calls;
script_action_install ();
script_action_install ((data) ? 1 : 0);
return WEECHAT_RC_OK;
}
@@ -357,11 +361,11 @@ script_action_install_process_cb (void *data, const char *command,
int return_code, const char *out,
const char *err)
{
char *pos, *filename, str_signal[256];
char *pos, *filename, *filename2, str_signal[256];
int quiet, length;
struct t_repo_script *ptr_script;
/* make C compiler happy */
(void) data;
quiet = (data) ? 1 : 0;
if (return_code >= 0)
{
@@ -386,18 +390,29 @@ script_action_install_process_cb (void *data, const char *command,
filename = script_config_get_script_download_filename (ptr_script);
if (filename)
{
snprintf (str_signal, sizeof (str_signal),
"%s_script_install",
script_language[ptr_script->language]);
weechat_hook_signal_send (str_signal,
WEECHAT_HOOK_SIGNAL_STRING,
filename);
length = 3 + strlen (filename) + 1;
filename2 = malloc (length);
if (filename2)
{
snprintf (filename2, length,
"%s%s",
(quiet && weechat_config_boolean (script_config_look_quiet_actions)) ? "-q " : "",
filename);
snprintf (str_signal, sizeof (str_signal),
"%s_script_install",
script_language[ptr_script->language]);
weechat_hook_signal_send (str_signal,
WEECHAT_HOOK_SIGNAL_STRING,
filename2);
free (filename2);
}
free (filename);
}
/* schedule install of next script */
weechat_hook_timer (10, 0, 1,
&script_action_installnext_timer_cb, NULL);
&script_action_installnext_timer_cb,
(quiet) ? (void *)1 : (void *)0);
}
}
}
@@ -410,7 +425,7 @@ script_action_install_process_cb (void *data, const char *command,
*/
void
script_action_install ()
script_action_install (int quiet)
{
struct t_repo_script *ptr_script, *ptr_script_to_install;
char *filename, *url;
@@ -446,17 +461,20 @@ script_action_install ()
url = malloc (length);
if (url)
{
weechat_printf (NULL,
_("%s: downloading script \"%s\"..."),
SCRIPT_PLUGIN_NAME,
ptr_script_to_install->name_with_extension);
if (!weechat_config_boolean (script_config_look_quiet_actions))
{
weechat_printf (NULL,
_("%s: downloading script \"%s\"..."),
SCRIPT_PLUGIN_NAME,
ptr_script_to_install->name_with_extension);
}
snprintf (url, length, "url:%s",
ptr_script_to_install->url);
weechat_hashtable_set (options, "file_out", filename);
weechat_hook_process_hashtable (url, options, 30000,
&script_action_install_process_cb,
NULL);
(quiet) ? (void *)1 : (void *)0);
free (url);
}
weechat_hashtable_free (options);
@@ -474,7 +492,8 @@ void
script_action_remove (const char *name, int quiet)
{
struct t_repo_script *ptr_script;
char str_signal[256];
char str_signal[256], *filename;
int length;
ptr_script = script_repo_search_by_name_ext (name);
if (ptr_script)
@@ -499,12 +518,22 @@ script_action_remove (const char *name, int quiet)
}
else
{
snprintf (str_signal, sizeof (str_signal),
"%s_script_remove",
script_language[ptr_script->language]);
weechat_hook_signal_send (str_signal,
WEECHAT_HOOK_SIGNAL_STRING,
ptr_script->name_with_extension);
length = 3 + strlen (ptr_script->name_with_extension) + 1;
filename = malloc (length);
if (filename)
{
snprintf (filename, length,
"%s%s",
(quiet && weechat_config_boolean (script_config_look_quiet_actions)) ? "-q " : "",
ptr_script->name_with_extension);
snprintf (str_signal, sizeof (str_signal),
"%s_script_remove",
script_language[ptr_script->language]);
weechat_hook_signal_send (str_signal,
WEECHAT_HOOK_SIGNAL_STRING,
filename);
free (filename);
}
}
}
else
@@ -717,7 +746,7 @@ script_action_run ()
}
}
if (script_found)
script_action_install ();
script_action_install (quiet);
}
else if (weechat_strcasecmp (argv[0], "remove") == 0)
{
@@ -758,7 +787,7 @@ script_action_run ()
}
}
if (script_found)
script_action_install ();
script_action_install (quiet);
}
else if (weechat_strcasecmp (argv[0], "hold") == 0)
{
@@ -798,7 +827,7 @@ script_action_run ()
}
}
if (script_found)
script_action_install ();
script_action_install (quiet);
else
{
weechat_printf (NULL,
+37 -16
View File
@@ -46,10 +46,21 @@ script_command_action (struct t_gui_buffer *buffer, const char *action,
char str_action[4096];
long value;
char *error;
int quiet;
if (arguments)
{
/* action with arguments on command line */
quiet = 0;
if (strncmp (arguments, "-q ", 3) == 0)
{
quiet = 1;
arguments += 3;
while (arguments[0] == ' ')
{
arguments++;
}
}
error = NULL;
value = strtol (arguments, &error, 10);
if (error && !error[0])
@@ -58,15 +69,21 @@ script_command_action (struct t_gui_buffer *buffer, const char *action,
if (ptr_script)
{
snprintf (str_action, sizeof (str_action),
"%s %s", action, ptr_script->name_with_extension);
script_action_schedule (str_action, need_repository, 0);
"%s%s %s",
(quiet) ? "-q " : "",
action,
ptr_script->name_with_extension);
script_action_schedule (str_action, need_repository, quiet);
}
}
else
{
snprintf (str_action, sizeof (str_action),
"%s %s", action, arguments);
script_action_schedule (str_action, need_repository, 0);
"%s%s %s",
(quiet) ? "-q " : "",
action,
arguments);
script_action_schedule (str_action, need_repository, quiet);
}
}
else if (script_buffer && (buffer == script_buffer))
@@ -260,23 +277,26 @@ script_command_init ()
N_("WeeChat scripts manager"),
N_("list || search <text> || show <script>"
" || load|unload|reload <script> [<script>...]"
" || install|remove|hold <script> [<script>...]"
" || install|remove|installremove|hold [-q] <script> [<script>...]"
" || upgrade || update"),
N_(" list: list loaded scripts (all languages)\n"
" search: search scripts by tags or text and "
N_(" list: list loaded scripts (all languages)\n"
" search: search scripts by tags or text and "
"display result on scripts buffer\n"
" show: show detailed info about a script\n"
" load: load script(s)\n"
" unload: unload script(s)\n"
" reload: reload script(s)\n"
" install: install/upgrade script(s)\n"
" remove: remove script(s)\n"
" hold: hold/unhold script(s) (a script held "
" show: show detailed info about a script\n"
" load: load script(s)\n"
" unload: unload script(s)\n"
" reload: reload script(s)\n"
" install: install/upgrade script(s)\n"
" remove: remove script(s)\n"
"installremove: install or remove script(s), "
"depending on current state\n"
" hold: hold/unhold script(s) (a script held "
"will not be upgraded any more and cannot be "
"removed)\n"
" upgrade: upgrade all installed scripts which "
" -q: quiet mode: do not display messages\n"
" upgrade: upgrade all installed scripts which "
"are obsolete (new version available)\n"
" update: update local scripts cache\n\n"
" update: update local scripts cache\n\n"
"Without argument, this command opens a buffer "
"with list of scripts.\n\n"
"On script buffer, the possible status for each "
@@ -329,6 +349,7 @@ script_command_init ()
"%(guile_script)|%*"
" || install %(script_scripts)|%*"
" || remove %(script_scripts_installed)|%*"
" || installremove %(script_scripts)|%*"
" || hold %(script_scripts)|%*"
" || update"
" || upgrade",
+9
View File
@@ -40,6 +40,7 @@ struct t_config_section *script_config_section_scripts = NULL;
/* script config, look section */
struct t_config_option *script_config_look_columns;
struct t_config_option *script_config_look_quiet_actions;
struct t_config_option *script_config_look_sort;
struct t_config_option *script_config_look_translate_description;
struct t_config_option *script_config_look_use_keys;
@@ -358,6 +359,14 @@ script_config_init ()
"%W=max_weechat)"),
NULL, 0, 0, "%s %n %V %v %u | %d | %t", NULL, 0,
NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
script_config_look_quiet_actions = weechat_config_new_option (
script_config_file, ptr_section,
"quiet_actions", "boolean",
N_("quiet actions on script buffer: do not display messages on core "
"buffer when scripts are installed/removed/loaded/unloaded (only "
"errors are displayed)"),
NULL, 0, 0, "on", NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL);
script_config_look_sort = weechat_config_new_option (
script_config_file, ptr_section,
"sort", "string",
+1
View File
@@ -25,6 +25,7 @@
struct t_repo_script;
extern struct t_config_option *script_config_look_columns;
extern struct t_config_option *script_config_look_quiet_actions;
extern struct t_config_option *script_config_look_sort;
extern struct t_config_option *script_config_look_translate_description;
extern struct t_config_option *script_config_look_use_keys;
+48 -24
View File
@@ -420,9 +420,12 @@ weechat_tcl_unload_name (const char *name)
if (ptr_script)
{
weechat_tcl_unload (ptr_script);
weechat_printf (NULL,
weechat_gettext ("%s: script \"%s\" unloaded"),
TCL_PLUGIN_NAME, name);
if (!tcl_quiet)
{
weechat_printf (NULL,
weechat_gettext ("%s: script \"%s\" unloaded"),
TCL_PLUGIN_NAME, name);
}
}
else
{
@@ -462,9 +465,12 @@ weechat_tcl_reload_name (const char *name)
if (filename)
{
weechat_tcl_unload (ptr_script);
weechat_printf (NULL,
weechat_gettext ("%s: script \"%s\" unloaded"),
TCL_PLUGIN_NAME, name);
if (!tcl_quiet)
{
weechat_printf (NULL,
weechat_gettext ("%s: script \"%s\" unloaded"),
TCL_PLUGIN_NAME, name);
}
weechat_tcl_load (filename);
free (filename);
}
@@ -485,7 +491,7 @@ int
weechat_tcl_command_cb (void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
char *path_script;
char *ptr_name, *path_script;
/* make C compiler happy */
(void) data;
@@ -534,24 +540,40 @@ weechat_tcl_command_cb (void *data, struct t_gui_buffer *buffer,
plugin_script_display_list (weechat_tcl_plugin, tcl_scripts,
argv_eol[2], 1);
}
else if (weechat_strcasecmp (argv[1], "load") == 0)
else if ((weechat_strcasecmp (argv[1], "load") == 0)
|| (weechat_strcasecmp (argv[1], "reload") == 0)
|| (weechat_strcasecmp (argv[1], "unload") == 0))
{
/* load Tcl script */
path_script = plugin_script_search_path (weechat_tcl_plugin,
argv_eol[2]);
weechat_tcl_load ((path_script) ? path_script : argv_eol[2]);
if (path_script)
free (path_script);
}
else if (weechat_strcasecmp (argv[1], "reload") == 0)
{
/* reload one Tcl script */
weechat_tcl_reload_name (argv_eol[2]);
}
else if (weechat_strcasecmp (argv[1], "unload") == 0)
{
/* unload Tcl script */
weechat_tcl_unload_name (argv_eol[2]);
ptr_name = argv_eol[2];
if (strncmp (ptr_name, "-q ", 3) == 0)
{
tcl_quiet = 1;
ptr_name += 3;
while (ptr_name[0] == ' ')
{
ptr_name++;
}
}
if (weechat_strcasecmp (argv[1], "load") == 0)
{
/* load Tcl script */
path_script = plugin_script_search_path (weechat_tcl_plugin,
ptr_name);
weechat_tcl_load ((path_script) ? path_script : ptr_name);
if (path_script)
free (path_script);
}
else if (weechat_strcasecmp (argv[1], "reload") == 0)
{
/* reload one Tcl script */
weechat_tcl_reload_name (ptr_name);
}
else if (weechat_strcasecmp (argv[1], "unload") == 0)
{
/* unload Tcl script */
weechat_tcl_unload_name (ptr_name);
}
tcl_quiet = 0;
}
else
{
@@ -682,6 +704,7 @@ weechat_tcl_timer_action_cb (void *data, int remaining_calls)
tcl_scripts,
&weechat_tcl_unload,
&weechat_tcl_load,
&tcl_quiet,
&tcl_action_install_list);
}
else if (data == &tcl_action_remove_list)
@@ -689,6 +712,7 @@ weechat_tcl_timer_action_cb (void *data, int remaining_calls)
plugin_script_action_remove (weechat_tcl_plugin,
tcl_scripts,
&weechat_tcl_unload,
&tcl_quiet,
&tcl_action_remove_list);
}
}