1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-25 12:26:40 +02:00

script: add control of autoload (enable/disable/toggle) (task #12393)

New option script.scripts.autoload, new options autoload/noautoload/toggleautoload
for command /script, new action "A" (meta-A) on script buffer (toggle autoload).
This commit is contained in:
Sebastien Helleu
2013-02-25 08:46:41 +01:00
parent 87b5096972
commit b60aec975b
35 changed files with 1227 additions and 535 deletions
+26 -2
View File
@@ -60,7 +60,7 @@ struct t_guile_function
/*
* string used to execute action "install":
* when signal "guile_install_script" is received, name of string
* when signal "guile_script_install" is received, name of string
* is added to this string, to be installed later by a timer (when nothing is
* running in script)
*/
@@ -68,12 +68,20 @@ char *guile_action_install_list = NULL;
/*
* string used to execute action "remove":
* when signal "guile_remove_script" is received, name of string
* when signal "guile_script_remove" is received, name of string
* is added to this string, to be removed later by a timer (when nothing is
* running in script)
*/
char *guile_action_remove_list = NULL;
/*
* string used to execute action "autoload":
* when signal "guile_script_autoload" is received, name of string
* is added to this string, to autoload or disable autoload later by a timer
* (when nothing is running in script)
*/
char *guile_action_autoload_list = NULL;
/*
* Flushes stdout.
@@ -815,6 +823,12 @@ weechat_guile_timer_action_cb (void *data, int remaining_calls)
&guile_quiet,
&guile_action_remove_list);
}
else if (data == &guile_action_autoload_list)
{
plugin_script_action_autoload (weechat_guile_plugin,
&guile_quiet,
&guile_action_autoload_list);
}
}
return WEECHAT_RC_OK;
@@ -850,6 +864,14 @@ weechat_guile_signal_script_action_cb (void *data, const char *signal,
&weechat_guile_timer_action_cb,
&guile_action_remove_list);
}
else if (strcmp (signal, "guile_script_autoload") == 0)
{
plugin_script_action_add (&guile_action_autoload_list,
(const char *)signal_data);
weechat_hook_timer (1, 0, 1,
&weechat_guile_timer_action_cb,
&guile_action_autoload_list);
}
}
return WEECHAT_RC_OK;
@@ -971,6 +993,8 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
free (guile_action_install_list);
if (guile_action_remove_list)
free (guile_action_remove_list);
if (guile_action_autoload_list)
free (guile_action_autoload_list);
return WEECHAT_RC_OK;
}
+32 -2
View File
@@ -52,7 +52,7 @@ lua_State *lua_current_interpreter = NULL;
/*
* string used to execute action "install":
* when signal "lua_install_script" is received, name of string
* when signal "lua_script_install" is received, name of string
* is added to this string, to be installed later by a timer (when nothing is
* running in script)
*/
@@ -60,12 +60,20 @@ char *lua_action_install_list = NULL;
/*
* string used to execute action "remove":
* when signal "lua_remove_script" is received, name of string
* when signal "lua_script_remove" is received, name of string
* is added to this string, to be removed later by a timer (when nothing is
* running in script)
*/
char *lua_action_remove_list = NULL;
/*
* string used to execute action "autoload":
* when signal "lua_script_autoload" is received, name of string
* is added to this string, to autoload or disable autoload later by a timer
* (when nothing is running in script)
*/
char *lua_action_autoload_list = NULL;
/*
* Callback called for each key/value in a hashtable.
@@ -769,6 +777,12 @@ weechat_lua_timer_action_cb (void *data, int remaining_calls)
&lua_quiet,
&lua_action_remove_list);
}
else if (data == &lua_action_autoload_list)
{
plugin_script_action_autoload (weechat_lua_plugin,
&lua_quiet,
&lua_action_autoload_list);
}
}
return WEECHAT_RC_OK;
@@ -804,6 +818,14 @@ weechat_lua_signal_script_action_cb (void *data, const char *signal,
&weechat_lua_timer_action_cb,
&lua_action_remove_list);
}
else if (strcmp (signal, "lua_script_autoload") == 0)
{
plugin_script_action_add (&lua_action_autoload_list,
(const char *)signal_data);
weechat_hook_timer (1, 0, 1,
&weechat_lua_timer_action_cb,
&lua_action_autoload_list);
}
}
return WEECHAT_RC_OK;
@@ -852,5 +874,13 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
plugin_script_end (plugin, &lua_scripts, &weechat_lua_unload_all);
lua_quiet = 0;
/* free some data */
if (lua_action_install_list)
free (lua_action_install_list);
if (lua_action_remove_list)
free (lua_action_remove_list);
if (lua_action_autoload_list)
free (lua_action_autoload_list);
return WEECHAT_RC_OK;
}
+32 -2
View File
@@ -50,7 +50,7 @@ int perl_quit_or_upgrade = 0;
/*
* string used to execute action "install":
* when signal "perl_install_script" is received, name of string
* when signal "perl_script_install" is received, name of string
* is added to this string, to be installed later by a timer (when nothing is
* running in script)
*/
@@ -58,12 +58,20 @@ char *perl_action_install_list = NULL;
/*
* string used to execute action "remove":
* when signal "perl_remove_script" is received, name of string
* when signal "perl_script_remove" is received, name of string
* is added to this string, to be removed later by a timer (when nothing is
* running in script)
*/
char *perl_action_remove_list = NULL;
/*
* string used to execute action "autoload":
* when signal "perl_script_autoload" is received, name of string
* is added to this string, to autoload or disable autoload later by a timer
* (when nothing is running in script)
*/
char *perl_action_autoload_list = NULL;
#ifdef NO_PERL_MULTIPLICITY
#undef MULTIPLICITY
#endif
@@ -850,6 +858,12 @@ weechat_perl_timer_action_cb (void *data, int remaining_calls)
&perl_quiet,
&perl_action_remove_list);
}
else if (data == &perl_action_autoload_list)
{
plugin_script_action_autoload (weechat_perl_plugin,
&perl_quiet,
&perl_action_autoload_list);
}
}
return WEECHAT_RC_OK;
@@ -885,6 +899,14 @@ weechat_perl_signal_script_action_cb (void *data, const char *signal,
&weechat_perl_timer_action_cb,
&perl_action_remove_list);
}
else if (strcmp (signal, "perl_script_autoload") == 0)
{
plugin_script_action_add (&perl_action_autoload_list,
(const char *)signal_data);
weechat_hook_timer (1, 0, 1,
&weechat_perl_timer_action_cb,
&perl_action_autoload_list);
}
}
return WEECHAT_RC_OK;
@@ -1003,5 +1025,13 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
PERL_SYS_TERM ();
#endif
/* free some data */
if (perl_action_install_list)
free (perl_action_install_list);
if (perl_action_remove_list)
free (perl_action_remove_list);
if (perl_action_autoload_list)
free (perl_action_autoload_list);
return WEECHAT_RC_OK;
}
+152 -36
View File
@@ -93,8 +93,8 @@ plugin_script_init (struct t_weechat_plugin *weechat_plugin,
int argc, char *argv[],
struct t_plugin_script_init *init)
{
char *string, *completion;
char signal_name[128];
char *string, *completion, signal_name[128];
char *action_signals[] = { "install", "remove", "autoload", NULL };
int length, i, auto_load_scripts;
/* read script configuration */
@@ -192,15 +192,15 @@ plugin_script_init (struct t_weechat_plugin *weechat_plugin,
weechat_hook_signal ("buffer_closed",
init->callback_signal_buffer_closed, NULL);
/* add signal for a script action (install/remove) */
snprintf (signal_name, sizeof (signal_name), "%s_script_install",
weechat_plugin->name);
weechat_hook_signal (signal_name,
init->callback_signal_script_action, NULL);
snprintf (signal_name, sizeof (signal_name), "%s_script_remove",
weechat_plugin->name);
weechat_hook_signal (signal_name,
init->callback_signal_script_action, NULL);
/* add signals for script actions (install/remove/autoload) */
for (i = 0; action_signals[i]; i++)
{
snprintf (signal_name, sizeof (signal_name), "%s_script_%s",
weechat_plugin->name,
action_signals[i]);
weechat_hook_signal (signal_name,
init->callback_signal_script_action, NULL);
}
/* parse arguments */
auto_load_scripts = 1;
@@ -931,7 +931,7 @@ plugin_script_remove_file (struct t_weechat_plugin *weechat_plugin,
* 1. unloads script (if script is loaded)
* 2. removes script file(s)
* 3. moves script file from "install" dir to language dir
* 4. makes link in autoload dir
* 4. makes link in autoload dir (if option "-a" is given)
* 5. loads script.
*/
@@ -946,18 +946,33 @@ plugin_script_action_install (struct t_weechat_plugin *weechat_plugin,
char **argv, *name, *ptr_base_name, *base_name, *new_path, *autoload_path;
char *symlink_path, str_signal[128], *ptr_list;
const char *dir_home, *dir_separator;
int argc, i, length, rc;
int argc, i, length, rc, autoload;
struct t_plugin_script *ptr_script;
if (!*list)
return;
ptr_list = *list;
autoload = 0;
*quiet = 0;
if (strncmp (ptr_list, "-q ", 3) == 0)
while ((ptr_list[0] == ' ') || (ptr_list[0] == '-'))
{
*quiet = 1;
ptr_list += 3;
if (ptr_list[0] == ' ')
ptr_list++;
else
{
switch (ptr_list[1])
{
case 'a': /* no autoload */
autoload = 1;
break;
case 'q': /* quiet mode */
*quiet = 1;
break;
}
ptr_list += 2;
}
}
argv = weechat_string_split (ptr_list, ",", 0, 0, &argc);
@@ -994,29 +1009,32 @@ plugin_script_action_install (struct t_weechat_plugin *weechat_plugin,
if (rename (name, new_path) == 0)
{
/* make link in autoload dir */
length = strlen (dir_home) +
strlen (weechat_plugin->name) + 8 +
strlen (base_name) + 16;
autoload_path = malloc (length);
if (autoload_path)
if (autoload)
{
snprintf (autoload_path, length,
"%s/%s/autoload/%s",
dir_home, weechat_plugin->name,
base_name);
dir_separator = weechat_info_get ("dir_separator", "");
length = 2 + strlen (dir_separator) +
strlen (base_name) + 1;
symlink_path = malloc (length);
if (symlink_path)
length = strlen (dir_home) +
strlen (weechat_plugin->name) + 8 +
strlen (base_name) + 16;
autoload_path = malloc (length);
if (autoload_path)
{
snprintf (symlink_path, length, "..%s%s",
dir_separator, base_name);
rc = symlink (symlink_path, autoload_path);
(void) rc;
free (symlink_path);
snprintf (autoload_path, length,
"%s/%s/autoload/%s",
dir_home, weechat_plugin->name,
base_name);
dir_separator = weechat_info_get ("dir_separator", "");
length = 2 + strlen (dir_separator) +
strlen (base_name) + 1;
symlink_path = malloc (length);
if (symlink_path)
{
snprintf (symlink_path, length, "..%s%s",
dir_separator, base_name);
rc = symlink (symlink_path, autoload_path);
(void) rc;
free (symlink_path);
}
free (autoload_path);
}
free (autoload_path);
}
/* load script */
@@ -1111,6 +1129,104 @@ plugin_script_action_remove (struct t_weechat_plugin *weechat_plugin,
*list = NULL;
}
/*
* Enables/disables autoload for some scripts (using comma separated list).
*/
void
plugin_script_action_autoload (struct t_weechat_plugin *weechat_plugin,
int *quiet,
char **list)
{
char **argv, *name, *ptr_base_name, *base_name, *autoload_path;
char *symlink_path, *ptr_list;
const char *dir_home, *dir_separator;
int argc, i, length, rc, autoload;
if (!*list)
return;
ptr_list = *list;
autoload = 0;
*quiet = 0;
while ((ptr_list[0] == ' ') || (ptr_list[0] == '-'))
{
if (ptr_list[0] == ' ')
ptr_list++;
else
{
switch (ptr_list[1])
{
case 'a': /* no autoload */
autoload = 1;
break;
case 'q': /* quiet mode */
*quiet = 1;
break;
}
ptr_list += 2;
}
}
argv = weechat_string_split (ptr_list, ",", 0, 0, &argc);
if (argv)
{
for (i = 0; i < argc; i++)
{
name = strdup (argv[i]);
if (name)
{
ptr_base_name = basename (name);
base_name = strdup (ptr_base_name);
if (base_name)
{
dir_home = weechat_info_get ("weechat_dir", "");
length = strlen (dir_home) +
strlen (weechat_plugin->name) + 8 +
strlen (base_name) + 16;
autoload_path = malloc (length);
if (autoload_path)
{
snprintf (autoload_path, length,
"%s/%s/autoload/%s",
dir_home, weechat_plugin->name,
base_name);
if (autoload)
{
dir_separator = weechat_info_get ("dir_separator", "");
length = 2 + strlen (dir_separator) +
strlen (base_name) + 1;
symlink_path = malloc (length);
if (symlink_path)
{
snprintf (symlink_path, length, "..%s%s",
dir_separator, base_name);
rc = symlink (symlink_path, autoload_path);
(void) rc;
free (symlink_path);
}
}
else
{
unlink (autoload_path);
}
free (autoload_path);
}
free (base_name);
}
free (name);
}
}
weechat_string_free_split (argv);
}
*quiet = 0;
free (*list);
*list = NULL;
}
/*
* Displays list of scripts.
*/
+3
View File
@@ -145,6 +145,9 @@ extern void plugin_script_action_remove (struct t_weechat_plugin *weechat_plugin
void (*script_unload)(struct t_plugin_script *script),
int *quiet,
char **list);
extern void plugin_script_action_autoload (struct t_weechat_plugin *weechat_plugin,
int *quiet,
char **list);
extern void plugin_script_display_list (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *scripts,
const char *name, int full);
+28 -3
View File
@@ -86,7 +86,7 @@ static struct PyModuleDef moduleDefOutputs = {
/*
* string used to execute action "install":
* when signal "python_install_script" is received, name of string
* when signal "python_script_install" is received, name of string
* is added to this string, to be installed later by a timer (when nothing is
* running in script)
*/
@@ -94,12 +94,20 @@ char *python_action_install_list = NULL;
/*
* string used to execute action "remove":
* when signal "python_remove_script" is received, name of string
* when signal "python_script_remove" is received, name of string
* is added to this string, to be removed later by a timer (when nothing is
* running in script)
*/
char *python_action_remove_list = NULL;
/*
* string used to execute action "autoload":
* when signal "python_script_autoload" is received, name of string
* is added to this string, to autoload or disable autoload later by a timer
* (when nothing is running in script)
*/
char *python_action_autoload_list = NULL;
char python_buffer_output[128];
@@ -1167,13 +1175,20 @@ weechat_python_timer_action_cb (void *data, int remaining_calls)
&python_quiet,
&python_action_remove_list);
}
else if (data == &python_action_autoload_list)
{
plugin_script_action_autoload (weechat_python_plugin,
&python_quiet,
&python_action_autoload_list);
}
}
return WEECHAT_RC_OK;
}
/*
* Callback called when a script action is asked (install/remove a script).
* Callback called when a script action is asked (install/remove/autoload a
* script).
*/
int
@@ -1202,6 +1217,14 @@ weechat_python_signal_script_action_cb (void *data, const char *signal,
&weechat_python_timer_action_cb,
&python_action_remove_list);
}
else if (strcmp (signal, "python_script_autoload") == 0)
{
plugin_script_action_add (&python_action_autoload_list,
(const char *)signal_data);
weechat_hook_timer (1, 0, 1,
&weechat_python_timer_action_cb,
&python_action_autoload_list);
}
}
return WEECHAT_RC_OK;
@@ -1314,6 +1337,8 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
free (python_action_install_list);
if (python_action_remove_list)
free (python_action_remove_list);
if (python_action_autoload_list)
free (python_action_autoload_list);
return WEECHAT_RC_OK;
}
+32 -2
View File
@@ -71,7 +71,7 @@ const char *ruby_current_script_filename = NULL;
/*
* string used to execute action "install":
* when signal "ruby_install_script" is received, name of string
* when signal "ruby_script_install" is received, name of string
* is added to this string, to be installed later by a timer (when nothing is
* running in script)
*/
@@ -79,12 +79,20 @@ char *ruby_action_install_list = NULL;
/*
* string used to execute action "remove":
* when signal "ruby_remove_script" is received, name of string
* when signal "ruby_script_remove" is received, name of string
* is added to this string, to be removed later by a timer (when nothing is
* running in script)
*/
char *ruby_action_remove_list = NULL;
/*
* string used to execute action "autoload":
* when signal "ruby_script_autoload" is received, name of string
* is added to this string, to autoload or disable autoload later by a timer
* (when nothing is running in script)
*/
char *ruby_action_autoload_list = NULL;
VALUE ruby_mWeechat, ruby_mWeechatOutputs;
#define MOD_NAME_PREFIX "WeechatRubyModule"
@@ -987,6 +995,12 @@ weechat_ruby_timer_action_cb (void *data, int remaining_calls)
&ruby_quiet,
&ruby_action_remove_list);
}
else if (data == &ruby_action_autoload_list)
{
plugin_script_action_autoload (weechat_ruby_plugin,
&ruby_quiet,
&ruby_action_autoload_list);
}
}
return WEECHAT_RC_OK;
@@ -1022,6 +1036,14 @@ weechat_ruby_signal_script_action_cb (void *data, const char *signal,
&weechat_ruby_timer_action_cb,
&ruby_action_remove_list);
}
else if (strcmp (signal, "ruby_script_autoload") == 0)
{
plugin_script_action_add (&ruby_action_autoload_list,
(const char *)signal_data);
weechat_hook_timer (1, 0, 1,
&weechat_ruby_timer_action_cb,
&ruby_action_autoload_list);
}
}
return WEECHAT_RC_OK;
@@ -1175,5 +1197,13 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
*/
/*ruby_cleanup (0);*/
/* free some data */
if (ruby_action_install_list)
free (ruby_action_install_list);
if (ruby_action_remove_list)
free (ruby_action_remove_list);
if (ruby_action_autoload_list)
free (ruby_action_autoload_list);
return WEECHAT_RC_OK;
}
+97 -2
View File
@@ -407,6 +407,79 @@ script_action_reload (const char *name, int quiet)
}
}
/*
* Enables/disables autoload for a script.
*
* Argument "autoload" can be:
* 0: disables autoload
* 1: enables autoload
* -1: toggles autoload
*/
void
script_action_autoload (const char *name, int quiet, int autoload)
{
struct t_script_repo *ptr_script;
char str_signal[256], *filename;
int length;
ptr_script = script_repo_search_by_name_ext (name);
if (!ptr_script)
{
if (!quiet)
{
weechat_printf (NULL,
_("%s: script \"%s\" not found"),
SCRIPT_PLUGIN_NAME, name);
}
return;
}
/* check that script is installed */
if (!(ptr_script->status & SCRIPT_STATUS_INSTALLED))
{
if (!quiet)
{
weechat_printf (NULL,
_("%s: script \"%s\" is not installed"),
SCRIPT_PLUGIN_NAME, name);
}
return;
}
/* toggle autoload if value is -1 */
if (autoload < 0)
autoload = (ptr_script->status & SCRIPT_STATUS_AUTOLOADED) ? 0 : 1;
/* ask plugin to autoload (or not) script */
length = 16 + strlen (ptr_script->name_with_extension) + 1;
filename = malloc (length);
if (filename)
{
snprintf (filename, length,
"%s%s%s",
(quiet && weechat_config_boolean (script_config_look_quiet_actions)) ? "-q " : "",
(autoload) ? "-a " : "",
ptr_script->name_with_extension);
snprintf (str_signal, sizeof (str_signal),
"%s_script_autoload",
script_language[ptr_script->language]);
weechat_hook_signal_send (str_signal,
WEECHAT_HOOK_SIGNAL_STRING,
filename);
free (filename);
}
if (!quiet)
{
weechat_printf (NULL,
(autoload) ?
_("%s: autoload enabled for script \"%s\"") :
_("%s: autoload disabled for script \"%s\""),
SCRIPT_PLUGIN_NAME, name);
}
script_repo_update_status (ptr_script);
}
/*
* Installs next script.
*/
@@ -461,13 +534,14 @@ script_action_install_process_cb (void *data, const char *command,
NULL);
if (filename)
{
length = 3 + strlen (filename) + 1;
length = 16 + strlen (filename) + 1;
filename2 = malloc (length);
if (filename2)
{
snprintf (filename2, length,
"%s%s",
"%s%s%s",
(quiet && weechat_config_boolean (script_config_look_quiet_actions)) ? "-q " : "",
(weechat_config_boolean (script_config_scripts_autoload)) ? "-a " : "",
filename);
snprintf (str_signal, sizeof (str_signal),
"%s_script_install",
@@ -1157,6 +1231,27 @@ script_action_run ()
script_action_reload (argv[j], quiet);
}
}
else if (weechat_strcasecmp (argv[0], "autoload") == 0)
{
for (j = 1; j < argc; j++)
{
script_action_autoload (argv[j], quiet, 1);
}
}
else if (weechat_strcasecmp (argv[0], "noautoload") == 0)
{
for (j = 1; j < argc; j++)
{
script_action_autoload (argv[j], quiet, 0);
}
}
else if (weechat_strcasecmp (argv[0], "toggleautoload") == 0)
{
for (j = 1; j < argc; j++)
{
script_action_autoload (argv[j], quiet, -1);
}
}
else if (weechat_strcasecmp (argv[0], "install") == 0)
{
script_found = 0;
+23 -21
View File
@@ -510,9 +510,9 @@ script_buffer_refresh (int clear)
snprintf (str_title, sizeof (str_title),
_("%d/%d scripts (filter: %s) | Sort: %s | "
"Alt+key/input: i=install r=remove l=load L=reload "
"u=unload h=(un)hold v=view script | Input: q=close "
"$=refresh s:x,y=sort words=filter *=reset filter | "
"Mouse: left=select right=install/remove"),
"u=unload A=autoload h=(un)hold v=view script | "
"Input: q=close $=refresh s:x,y=sort words=filter "
"*=reset filter | Mouse: left=select right=install/remove"),
script_repo_count_displayed,
script_repo_count,
(script_repo_filter) ? script_repo_filter : "*",
@@ -706,15 +706,16 @@ int
script_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
const char *input_data)
{
char *actions[][2] = { { "l", "load" },
{ "u", "unload" },
{ "L", "reload" },
{ "i", "install" },
{ "r", "remove" },
{ "h", "hold" },
{ "v", "show" },
{ "d", "showdiff" },
{ NULL, NULL } };
char *actions[][2] = { { "A", "toggleautoload" },
{ "l", "load" },
{ "u", "unload" },
{ "L", "reload" },
{ "i", "install" },
{ "r", "remove" },
{ "h", "hold" },
{ "v", "show" },
{ "d", "showdiff" },
{ NULL, NULL } };
char str_command[64];
int i;
@@ -814,15 +815,16 @@ script_buffer_set_callbacks ()
void
script_buffer_set_keys ()
{
char *keys[][2] = { { "meta-l", "load" },
{ "meta-u", "unload" },
{ "meta-L", "reload" },
{ "meta-i", "install" },
{ "meta-r", "remove" },
{ "meta-h", "hold" },
{ "meta-v", "show" },
{ "meta-d", "showdiff" },
{ NULL, NULL } };
char *keys[][2] = { { "meta-A", "toggleautoload" },
{ "meta-l", "load" },
{ "meta-u", "unload" },
{ "meta-L", "reload" },
{ "meta-i", "install" },
{ "meta-r", "remove" },
{ "meta-h", "hold" },
{ "meta-v", "show" },
{ "meta-d", "showdiff" },
{ NULL, NULL } };
char str_key[64], str_command[64];
int i;
+26 -16
View File
@@ -169,7 +169,10 @@ script_command_script (void *data, struct t_gui_buffer *buffer, int argc,
if ((weechat_strcasecmp (argv[1], "load") == 0)
|| (weechat_strcasecmp (argv[1], "unload") == 0)
|| (weechat_strcasecmp (argv[1], "reload") == 0))
|| (weechat_strcasecmp (argv[1], "reload") == 0)
|| (weechat_strcasecmp (argv[1], "autoload") == 0)
|| (weechat_strcasecmp (argv[1], "noautoload") == 0)
|| (weechat_strcasecmp (argv[1], "toggleautoload") == 0))
{
script_command_action (buffer,
argv[1],
@@ -264,29 +267,33 @@ script_command_init ()
N_("WeeChat scripts manager"),
N_("list [-o|-i] || search <text> || show <script>"
" || load|unload|reload <script> [<script>...]"
" || autoload|noautoload|toggleautoload <script> [<script>...]"
" || install|remove|installremove|hold [-q] <script> [<script>...]"
" || upgrade || update"),
N_(" list: list loaded scripts (all languages)\n"
" -o: send list of loaded scripts to buffer\n"
" -i: copy list of loaded scripts in "
N_(" list: list loaded scripts (all languages)\n"
" -o: send list of loaded scripts to buffer\n"
" -i: copy list of loaded scripts in "
"command line (for sending to buffer)\n"
" search: search scripts by tags or text and "
" 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"
"installremove: install or remove script(s), "
" show: show detailed info about a script\n"
" load: load script(s)\n"
" unload: unload script(s)\n"
" reload: reload script(s)\n"
" autoload: autoload the script\n"
" noautoload: do not autoload the script\n"
"toggleautoload: toggle autoload\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 "
" hold: hold/unhold script(s) (a script held "
"will not be upgraded any more and cannot be "
"removed)\n"
" -q: quiet mode: do not display messages\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 "
@@ -338,6 +345,9 @@ script_command_init ()
" || reload %(python_script)|%(perl_script)|"
"%(ruby_script)|%(tcl_script)|%(lua_script)|"
"%(guile_script)|%*"
" || autoload %(script_scripts_installed)|%*"
" || noautoload %(script_scripts_installed)|%*"
" || toggleautoload %(script_scripts_installed)|%*"
" || install %(script_scripts)|%*"
" || remove %(script_scripts_installed)|%*"
" || installremove %(script_scripts)|%*"
+8
View File
@@ -80,6 +80,7 @@ struct t_config_option *script_config_color_text_bg_selected;
/* script config, scripts section */
struct t_config_option *script_config_scripts_autoload;
struct t_config_option *script_config_scripts_cache_expire;
struct t_config_option *script_config_scripts_dir;
struct t_config_option *script_config_scripts_hold;
@@ -670,6 +671,13 @@ script_config_init ()
return 0;
}
script_config_scripts_autoload = weechat_config_new_option (
script_config_file, ptr_section,
"autoload", "boolean",
N_("autoload scripts installed (make a link in \"autoload\" directory "
"to script in parent directory"),
NULL, 0, 0, "on", NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL);
script_config_scripts_cache_expire = weechat_config_new_option (
script_config_file, ptr_section,
"cache_expire", "integer",
+1
View File
@@ -60,6 +60,7 @@ extern struct t_config_option *script_config_color_text_version_selected;
extern struct t_config_option *script_config_color_text_version_loaded_selected;
extern struct t_config_option *script_config_color_text_bg_selected;
extern struct t_config_option *script_config_scripts_autoload;
extern struct t_config_option *script_config_scripts_cache_expire;
extern struct t_config_option *script_config_scripts_dir;
extern struct t_config_option *script_config_scripts_hold;
+32 -2
View File
@@ -52,7 +52,7 @@ const char *tcl_current_script_filename = NULL;
/*
* string used to execute action "install":
* when signal "tcl_install_script" is received, name of string
* when signal "tcl_script_install" is received, name of string
* is added to this string, to be installed later by a timer (when nothing is
* running in script)
*/
@@ -60,12 +60,20 @@ char *tcl_action_install_list = NULL;
/*
* string used to execute action "remove":
* when signal "tcl_remove_script" is received, name of string
* when signal "tcl_script_remove" is received, name of string
* is added to this string, to be removed later by a timer (when nothing is
* running in script)
*/
char *tcl_action_remove_list = NULL;
/*
* string used to execute action "autoload":
* when signal "tcl_script_autoload" is received, name of string
* is added to this string, to autoload or disable autoload later by a timer
* (when nothing is running in script)
*/
char *tcl_action_autoload_list = NULL;
Tcl_Interp* cinterp;
@@ -728,6 +736,12 @@ weechat_tcl_timer_action_cb (void *data, int remaining_calls)
&tcl_quiet,
&tcl_action_remove_list);
}
else if (data == &tcl_action_autoload_list)
{
plugin_script_action_autoload (weechat_tcl_plugin,
&tcl_quiet,
&tcl_action_autoload_list);
}
}
return WEECHAT_RC_OK;
@@ -763,6 +777,14 @@ weechat_tcl_signal_script_action_cb (void *data, const char *signal,
&weechat_tcl_timer_action_cb,
&tcl_action_remove_list);
}
else if (strcmp (signal, "tcl_script_autoload") == 0)
{
plugin_script_action_add (&tcl_action_autoload_list,
(const char *)signal_data);
weechat_hook_timer (1, 0, 1,
&weechat_tcl_timer_action_cb,
&tcl_action_autoload_list);
}
}
return WEECHAT_RC_OK;
@@ -811,5 +833,13 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
plugin_script_end (plugin, &tcl_scripts, &weechat_tcl_unload_all);
tcl_quiet = 0;
/* free some data */
if (tcl_action_install_list)
free (tcl_action_install_list);
if (tcl_action_remove_list)
free (tcl_action_remove_list);
if (tcl_action_autoload_list)
free (tcl_action_autoload_list);
return WEECHAT_RC_OK;
}