summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/weechat.c1
-rw-r--r--src/core/weechat.h1
-rw-r--r--src/plugins/guile/weechat-guile.c6
-rw-r--r--src/plugins/javascript/weechat-js.cpp6
-rw-r--r--src/plugins/lua/weechat-lua.c6
-rw-r--r--src/plugins/perl/weechat-perl.c6
-rw-r--r--src/plugins/php/weechat-php.c6
-rw-r--r--src/plugins/plugin-api-info.c30
-rw-r--r--src/plugins/plugin-script.c21
-rw-r--r--src/plugins/plugin-script.h1
-rw-r--r--src/plugins/plugin.c30
-rw-r--r--src/plugins/python/weechat-python.c6
-rw-r--r--src/plugins/ruby/weechat-ruby.c6
-rw-r--r--src/plugins/tcl/weechat-tcl.c6
14 files changed, 95 insertions, 37 deletions
diff --git a/src/core/weechat.c b/src/core/weechat.c
index eb24822c0..d91a3300a 100644
--- a/src/core/weechat.c
+++ b/src/core/weechat.c
@@ -132,6 +132,7 @@ int weechat_no_gcrypt = 0; /* remove init/deinit of gcrypt */
struct t_weelist *weechat_startup_commands = NULL; /* startup commands */
/* (option -r) */
int weechat_auto_connect = 1; /* auto-connect to servers */
+int weechat_auto_load_scripts = 1; /* auto-load scripts */
/*
diff --git a/src/core/weechat.h b/src/core/weechat.h
index 900662499..47d395c89 100644
--- a/src/core/weechat.h
+++ b/src/core/weechat.h
@@ -126,6 +126,7 @@ extern int weechat_no_gnutls;
extern int weechat_no_gcrypt;
extern struct t_weelist *weechat_startup_commands;
extern int weechat_auto_connect;
+extern int weechat_auto_load_scripts;
extern void weechat_term_check ();
extern void weechat_shutdown (int return_code, int crash);
diff --git a/src/plugins/guile/weechat-guile.c b/src/plugins/guile/weechat-guile.c
index 48d9d3c67..3be050095 100644
--- a/src/plugins/guile/weechat-guile.c
+++ b/src/plugins/guile/weechat-guile.c
@@ -1239,6 +1239,10 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
{
char str_version[128];
+ /* make C compiler happy */
+ (void) argc;
+ (void) argv;
+
weechat_guile_plugin = plugin;
/* set interpreter name and version */
@@ -1296,7 +1300,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
guile_data.unload_all = &weechat_guile_unload_all;
guile_quiet = 1;
- plugin_script_init (weechat_guile_plugin, argc, argv, &guile_data);
+ plugin_script_init (weechat_guile_plugin, &guile_data);
guile_quiet = 0;
plugin_script_display_short_list (weechat_guile_plugin,
diff --git a/src/plugins/javascript/weechat-js.cpp b/src/plugins/javascript/weechat-js.cpp
index cda9f5aad..a33b2d1be 100644
--- a/src/plugins/javascript/weechat-js.cpp
+++ b/src/plugins/javascript/weechat-js.cpp
@@ -924,6 +924,10 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
{
char str_interpreter[64];
+ /* make C compiler happy */
+ (void) argc;
+ (void) argv;
+
weechat_js_plugin = plugin;
/* set interpreter name and version */
@@ -950,7 +954,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
js_data.unload_all = &weechat_js_unload_all;
js_quiet = 1;
- plugin_script_init (plugin, argc, argv, &js_data);
+ plugin_script_init (plugin, &js_data);
js_quiet = 0;
plugin_script_display_short_list (weechat_js_plugin, js_scripts);
diff --git a/src/plugins/lua/weechat-lua.c b/src/plugins/lua/weechat-lua.c
index 1a247bfab..f9338120c 100644
--- a/src/plugins/lua/weechat-lua.c
+++ b/src/plugins/lua/weechat-lua.c
@@ -1237,6 +1237,10 @@ weechat_lua_signal_script_action_cb (const void *pointer, void *data,
int
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
{
+ /* make C compiler happy */
+ (void) argc;
+ (void) argv;
+
weechat_lua_plugin = plugin;
/* set interpreter name and version */
@@ -1271,7 +1275,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
lua_data.unload_all = &weechat_lua_unload_all;
lua_quiet = 1;
- plugin_script_init (weechat_lua_plugin, argc, argv, &lua_data);
+ plugin_script_init (weechat_lua_plugin, &lua_data);
lua_quiet = 0;
plugin_script_display_short_list (weechat_lua_plugin,
diff --git a/src/plugins/perl/weechat-perl.c b/src/plugins/perl/weechat-perl.c
index 063fe75bd..1759a4810 100644
--- a/src/plugins/perl/weechat-perl.c
+++ b/src/plugins/perl/weechat-perl.c
@@ -1253,6 +1253,10 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
PERL_SYS_INIT3 (&a, (char ***)&perl_args_local, (char ***)&perl_env);
#endif /* PERL_SYS_INIT3 */
+ /* make C compiler happy */
+ (void) argc;
+ (void) argv;
+
weechat_perl_plugin = plugin;
/* set interpreter name and version */
@@ -1304,7 +1308,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
perl_data.unload_all = &weechat_perl_unload_all;
perl_quiet = 1;
- plugin_script_init (weechat_perl_plugin, argc, argv, &perl_data);
+ plugin_script_init (weechat_perl_plugin, &perl_data);
perl_quiet = 0;
plugin_script_display_short_list (weechat_perl_plugin,
diff --git a/src/plugins/php/weechat-php.c b/src/plugins/php/weechat-php.c
index 07f3da4a1..747768b51 100644
--- a/src/plugins/php/weechat-php.c
+++ b/src/plugins/php/weechat-php.c
@@ -1302,6 +1302,10 @@ php_weechat_log_message (char *message)
int
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
{
+ /* make C compiler happy */
+ (void) argc;
+ (void) argv;
+
weechat_php_plugin = plugin;
/* set interpreter name and version */
@@ -1341,7 +1345,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
PG(report_zend_debug) = 0; /* Turn off --enable-debug output */
php_quiet = 1;
- plugin_script_init (weechat_php_plugin, argc, argv, &php_data);
+ plugin_script_init (weechat_php_plugin, &php_data);
php_quiet = 0;
plugin_script_display_short_list (weechat_php_plugin,
diff --git a/src/plugins/plugin-api-info.c b/src/plugins/plugin-api-info.c
index 3546491f8..cde37b597 100644
--- a/src/plugins/plugin-api-info.c
+++ b/src/plugins/plugin-api-info.c
@@ -449,6 +449,27 @@ plugin_api_info_auto_connect_cb (const void *pointer, void *data,
}
/*
+ * Returns WeeChat info "auto_load_scripts".
+ */
+
+char *
+plugin_api_info_auto_load_scripts_cb (const void *pointer, void *data,
+ const char *info_name,
+ const char *arguments)
+{
+ char value[32];
+
+ /* make C compiler happy */
+ (void) pointer;
+ (void) data;
+ (void) info_name;
+ (void) arguments;
+
+ snprintf (value, sizeof (value), "%d", weechat_auto_load_scripts);
+ return strdup (value);
+}
+
+/*
* Returns WeeChat info "charset_terminal".
*/
@@ -1964,9 +1985,14 @@ plugin_api_info_init ()
NULL, &plugin_api_info_weechat_daemon_cb, NULL, NULL);
hook_info (NULL, "auto_connect",
N_("1 if automatic connection to servers is enabled, "
- "0 if it has been disabled by the user (option \"-a\" or "
- "\"--no-connect\")"),
+ "0 if it has been disabled by the user "
+ "(option \"-a\" or \"--no-connect\")"),
NULL, &plugin_api_info_auto_connect_cb, NULL, NULL);
+ hook_info (NULL, "auto_load_scripts",
+ N_("1 if scripts are automatically loaded, "
+ "0 if the auto-load has been disabled by the user "
+ "(option \"-s\" or \"--no-script\")"),
+ NULL, &plugin_api_info_auto_load_scripts_cb, NULL, NULL);
hook_info (NULL, "charset_terminal",
N_("terminal charset"),
NULL, &plugin_api_info_charset_terminal_cb, NULL, NULL);
diff --git a/src/plugins/plugin-script.c b/src/plugins/plugin-script.c
index 533483d03..14404d1c9 100644
--- a/src/plugins/plugin-script.c
+++ b/src/plugins/plugin-script.c
@@ -158,16 +158,14 @@ plugin_script_create_dirs (struct t_weechat_plugin *weechat_plugin)
* - hooks config
* - creates directories in WeeChat home
* - hooks command, completion, hdata, infolist, signals
- * - parses arguments
* - auto-loads scripts.
*/
void
plugin_script_init (struct t_weechat_plugin *weechat_plugin,
- int argc, char *argv[],
struct t_plugin_script_data *plugin_data)
{
- char string[512], *completion;
+ char string[512], *completion, *info_auto_load_scripts;
char *action_signals[] = { "install", "remove", "autoload", NULL };
int i, auto_load_scripts;
@@ -273,16 +271,13 @@ plugin_script_init (struct t_weechat_plugin *weechat_plugin,
&plugin_script_info_version_cb,
weechat_plugin, NULL);
- /* parse arguments */
- auto_load_scripts = 1;
- for (i = 0; i < argc; i++)
- {
- if ((strcmp (argv[i], "-s") == 0)
- || (strcmp (argv[i], "--no-script") == 0))
- {
- auto_load_scripts = 0;
- }
- }
+ /* check if auto-load of scripts is enabled */
+ info_auto_load_scripts = weechat_info_get ("auto_load_scripts", NULL);
+ auto_load_scripts = (info_auto_load_scripts
+ && (strcmp (info_auto_load_scripts, "1") == 0)) ?
+ 1 : 0;
+ if (info_auto_load_scripts)
+ free (info_auto_load_scripts);
/* autoload scripts */
if (auto_load_scripts)
diff --git a/src/plugins/plugin-script.h b/src/plugins/plugin-script.h
index d54751299..e4b3081c0 100644
--- a/src/plugins/plugin-script.h
+++ b/src/plugins/plugin-script.h
@@ -116,7 +116,6 @@ struct t_plugin_script_data
extern void plugin_script_display_interpreter (struct t_weechat_plugin *plugin,
int indent);
extern void plugin_script_init (struct t_weechat_plugin *weechat_plugin,
- int argc, char *argv[],
struct t_plugin_script_data *plugin_data);
extern int plugin_script_valid (struct t_plugin_script *scripts,
struct t_plugin_script *script);
diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c
index f816ecd6e..ea4b9fb5a 100644
--- a/src/plugins/plugin.c
+++ b/src/plugins/plugin.c
@@ -274,20 +274,18 @@ plugin_check_autoload (const char *filename)
*/
void
-plugin_get_args (struct t_weechat_plugin *plugin,
- int argc, char **argv,
+plugin_get_args (int argc, char **argv,
int *plugin_argc, char ***plugin_argv,
- int *no_connect)
+ int *no_connect, int *no_script)
{
- int i, temp_argc, length_plugin_name;
+ int i, temp_argc;
char **temp_argv;
temp_argc = 0;
temp_argv = NULL;
*no_connect = 0;
-
- length_plugin_name = strlen (plugin->name);
+ *no_script = 0;
if (argc > 0)
{
@@ -302,10 +300,11 @@ plugin_get_args (struct t_weechat_plugin *plugin,
*no_connect = 1;
}
else if ((strcmp (argv[i], "-s") == 0)
- || (strcmp (argv[i], "--no-script") == 0)
- || ((strncmp (argv[i], plugin->name,
- length_plugin_name) == 0)
- && (argv[i][length_plugin_name] == ':')))
+ || (strcmp (argv[i], "--no-script") == 0))
+ {
+ *no_script = 1;
+ }
+ else if (argv[i][0] != '-')
{
temp_argv[temp_argc++] = argv[i];
}
@@ -336,7 +335,8 @@ int
plugin_call_init (struct t_weechat_plugin *plugin, int argc, char **argv)
{
t_weechat_init_func *init_func;
- int plugin_argc, no_connect, rc, old_auto_connect;
+ int no_connect, rc, old_auto_connect, no_script, old_auto_load_scripts;
+ int plugin_argc;
char **plugin_argv;
if (plugin->initialized)
@@ -348,12 +348,15 @@ plugin_call_init (struct t_weechat_plugin *plugin, int argc, char **argv)
return 0;
/* get arguments for the plugin */
- plugin_get_args (plugin, argc, argv,
- &plugin_argc, &plugin_argv, &no_connect);
+ plugin_get_args (argc, argv,
+ &plugin_argc, &plugin_argv, &no_connect, &no_script);
old_auto_connect = weechat_auto_connect;
weechat_auto_connect = (no_connect) ? 0 : 1;
+ old_auto_load_scripts = weechat_auto_load_scripts;
+ weechat_auto_load_scripts = (no_script) ? 0 : 1;
+
/* init plugin */
if (weechat_debug_core >= 1)
{
@@ -377,6 +380,7 @@ plugin_call_init (struct t_weechat_plugin *plugin, int argc, char **argv)
}
weechat_auto_connect = old_auto_connect;
+ weechat_auto_load_scripts = old_auto_load_scripts;
if (plugin_argv)
free (plugin_argv);
diff --git a/src/plugins/python/weechat-python.c b/src/plugins/python/weechat-python.c
index c06b4eb43..8a5883327 100644
--- a/src/plugins/python/weechat-python.c
+++ b/src/plugins/python/weechat-python.c
@@ -1465,6 +1465,10 @@ weechat_python_signal_script_action_cb (const void *pointer, void *data,
int
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
{
+ /* make C compiler happy */
+ (void) argc;
+ (void) argv;
+
weechat_python_plugin = plugin;
/* set interpreter name and version */
@@ -1532,7 +1536,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
python_data.unload_all = &weechat_python_unload_all;
python_quiet = 1;
- plugin_script_init (weechat_python_plugin, argc, argv, &python_data);
+ plugin_script_init (weechat_python_plugin, &python_data);
python_quiet = 0;
plugin_script_display_short_list (weechat_python_plugin,
diff --git a/src/plugins/ruby/weechat-ruby.c b/src/plugins/ruby/weechat-ruby.c
index 09be2f202..fde6d95a5 100644
--- a/src/plugins/ruby/weechat-ruby.c
+++ b/src/plugins/ruby/weechat-ruby.c
@@ -1340,6 +1340,10 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
"end\n"
};
+ /* make C compiler happy */
+ (void) argc;
+ (void) argv;
+
weechat_ruby_plugin = plugin;
/* set interpreter name and version */
@@ -1413,7 +1417,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
ruby_data.unload_all = &weechat_ruby_unload_all;
ruby_quiet = 1;
- plugin_script_init (weechat_ruby_plugin, argc, argv, &ruby_data);
+ plugin_script_init (weechat_ruby_plugin, &ruby_data);
ruby_quiet = 0;
plugin_script_display_short_list (weechat_ruby_plugin,
diff --git a/src/plugins/tcl/weechat-tcl.c b/src/plugins/tcl/weechat-tcl.c
index bc22e7127..1e53932c5 100644
--- a/src/plugins/tcl/weechat-tcl.c
+++ b/src/plugins/tcl/weechat-tcl.c
@@ -922,6 +922,10 @@ weechat_tcl_signal_script_action_cb (const void *pointer, void *data,
int
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
{
+ /* make C compiler happy */
+ (void) argc;
+ (void) argv;
+
weechat_tcl_plugin = plugin;
/* set interpreter name and version */
@@ -951,7 +955,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
tcl_data.unload_all = &weechat_tcl_unload_all;
tcl_quiet = 1;
- plugin_script_init (weechat_tcl_plugin, argc, argv, &tcl_data);
+ plugin_script_init (weechat_tcl_plugin, &tcl_data);
tcl_quiet = 0;
plugin_script_display_short_list (weechat_tcl_plugin,