diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2018-01-15 22:00:15 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2018-01-15 22:00:15 +0100 |
commit | 8fbbe8b0d509df26ff86ca8cd7fe4b2205c6d15e (patch) | |
tree | 3dd9f08f31f4c1fb513119a57f4ff33a45b51556 /src/plugins | |
parent | 21e63e7958c499b79a63612d7344ad4d53bd4284 (diff) | |
download | weechat-8fbbe8b0d509df26ff86ca8cd7fe4b2205c6d15e.zip |
scripts: add option "eval_keep_context" in script plugins
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/guile/weechat-guile.c | 8 | ||||
-rw-r--r-- | src/plugins/javascript/weechat-js.cpp | 2 | ||||
-rw-r--r-- | src/plugins/lua/weechat-lua.c | 8 | ||||
-rw-r--r-- | src/plugins/perl/weechat-perl.c | 8 | ||||
-rw-r--r-- | src/plugins/php/weechat-php.c | 2 | ||||
-rw-r--r-- | src/plugins/plugin-script-config.c | 16 | ||||
-rw-r--r-- | src/plugins/plugin-script.h | 1 | ||||
-rw-r--r-- | src/plugins/python/weechat-python.c | 8 | ||||
-rw-r--r-- | src/plugins/ruby/weechat-ruby.c | 8 | ||||
-rw-r--r-- | src/plugins/tcl/weechat-tcl.c | 2 |
10 files changed, 63 insertions, 0 deletions
diff --git a/src/plugins/guile/weechat-guile.c b/src/plugins/guile/weechat-guile.c index 1c663a02e..304fe906b 100644 --- a/src/plugins/guile/weechat-guile.c +++ b/src/plugins/guile/weechat-guile.c @@ -50,6 +50,7 @@ struct t_plugin_script_data guile_data; struct t_config_file *guile_config_file = NULL; struct t_config_option *guile_config_look_check_license = NULL; +struct t_config_option *guile_config_look_eval_keep_context = NULL; int guile_quiet = 0; @@ -749,6 +750,12 @@ weechat_guile_eval (struct t_gui_buffer *buffer, int send_to_buffer_as_input, guile_eval_exec_commands = 0; guile_eval_buffer = NULL; + if (!weechat_config_boolean (guile_config_look_eval_keep_context)) + { + weechat_guile_unload (guile_script_eval); + guile_script_eval = NULL; + } + return 1; } @@ -1187,6 +1194,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) guile_data.config_file = &guile_config_file; guile_data.config_look_check_license = &guile_config_look_check_license; + guile_data.config_look_eval_keep_context = &guile_config_look_eval_keep_context; guile_data.scripts = &guile_scripts; guile_data.last_script = &last_guile_script; guile_data.callback_command = &weechat_guile_command_cb; diff --git a/src/plugins/javascript/weechat-js.cpp b/src/plugins/javascript/weechat-js.cpp index 00d5e9890..72e1217e0 100644 --- a/src/plugins/javascript/weechat-js.cpp +++ b/src/plugins/javascript/weechat-js.cpp @@ -47,6 +47,7 @@ struct t_plugin_script_data js_data; struct t_config_file *js_config_file = NULL; struct t_config_option *js_config_look_check_license = NULL; +struct t_config_option *js_config_look_eval_keep_context = NULL; int js_quiet = 0; @@ -918,6 +919,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) js_data.config_file = &js_config_file; js_data.config_look_check_license = &js_config_look_check_license; + js_data.config_look_eval_keep_context = &js_config_look_eval_keep_context; js_data.scripts = &js_scripts; js_data.last_script = &last_js_script; js_data.callback_command = &weechat_js_command_cb; diff --git a/src/plugins/lua/weechat-lua.c b/src/plugins/lua/weechat-lua.c index eca71c60a..1fe13133f 100644 --- a/src/plugins/lua/weechat-lua.c +++ b/src/plugins/lua/weechat-lua.c @@ -48,6 +48,7 @@ struct t_plugin_script_data lua_data; struct t_config_file *lua_config_file = NULL; struct t_config_option *lua_config_look_check_license = NULL; +struct t_config_option *lua_config_look_eval_keep_context = NULL; int lua_quiet = 0; @@ -849,6 +850,12 @@ weechat_lua_eval (struct t_gui_buffer *buffer, int send_to_buffer_as_input, lua_eval_exec_commands = 0; lua_eval_buffer = NULL; + if (!weechat_config_boolean (lua_config_look_eval_keep_context)) + { + weechat_lua_unload (lua_script_eval); + lua_script_eval = NULL; + } + return 1; } @@ -1218,6 +1225,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) lua_data.config_file = &lua_config_file; lua_data.config_look_check_license = &lua_config_look_check_license; + lua_data.config_look_eval_keep_context = &lua_config_look_eval_keep_context; lua_data.scripts = &lua_scripts; lua_data.last_script = &last_lua_script; lua_data.callback_command = &weechat_lua_command_cb; diff --git a/src/plugins/perl/weechat-perl.c b/src/plugins/perl/weechat-perl.c index 4381d7cc8..e5b702651 100644 --- a/src/plugins/perl/weechat-perl.c +++ b/src/plugins/perl/weechat-perl.c @@ -45,6 +45,7 @@ struct t_plugin_script_data perl_data; struct t_config_file *perl_config_file = NULL; struct t_config_option *perl_config_look_check_license = NULL; +struct t_config_option *perl_config_look_eval_keep_context = NULL; int perl_quiet = 0; @@ -841,6 +842,12 @@ weechat_perl_eval (struct t_gui_buffer *buffer, int send_to_buffer_as_input, perl_eval_exec_commands = 0; perl_eval_buffer = NULL; + if (!weechat_config_boolean (perl_config_look_eval_keep_context)) + { + weechat_perl_unload (perl_script_eval); + perl_script_eval = NULL; + } + return 1; } @@ -1259,6 +1266,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) perl_data.config_file = &perl_config_file; perl_data.config_look_check_license = &perl_config_look_check_license; + perl_data.config_look_eval_keep_context = &perl_config_look_eval_keep_context; perl_data.scripts = &perl_scripts; perl_data.last_script = &last_perl_script; perl_data.callback_command = &weechat_perl_command_cb; diff --git a/src/plugins/php/weechat-php.c b/src/plugins/php/weechat-php.c index 379867a2e..8e45e2992 100644 --- a/src/plugins/php/weechat-php.c +++ b/src/plugins/php/weechat-php.c @@ -43,6 +43,7 @@ struct t_plugin_script_data php_data; struct t_config_file *php_config_file = NULL; struct t_config_option *php_config_look_check_license = NULL; +struct t_config_option *php_config_look_eval_keep_context = NULL; int php_quiet = 0; @@ -1254,6 +1255,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) php_data.config_file = &php_config_file; php_data.config_look_check_license = &php_config_look_check_license; + php_data.config_look_eval_keep_context = &php_config_look_eval_keep_context; php_data.scripts = &php_scripts; php_data.last_script = &last_php_script; php_data.callback_command = &weechat_php_command_cb; diff --git a/src/plugins/plugin-script-config.c b/src/plugins/plugin-script-config.c index 9bbd1bc95..380780094 100644 --- a/src/plugins/plugin-script-config.c +++ b/src/plugins/plugin-script-config.c @@ -20,6 +20,7 @@ */ #include <stdlib.h> +#include <stdio.h> #include "weechat-plugin.h" #include "plugin-script.h" @@ -38,6 +39,7 @@ plugin_script_config_init (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script_data *plugin_data) { struct t_config_section *ptr_section; + char str_description[4096]; *(plugin_data->config_file) = weechat_config_new (weechat_plugin->name, NULL, NULL, NULL); @@ -67,6 +69,20 @@ plugin_script_config_init (struct t_weechat_plugin *weechat_plugin, "is different from the plugin license, a warning is displayed"), NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + snprintf (str_description, sizeof (str_description), + N_("keep context between two calls to /%s eval " + "(or info \"%s_eval\"); a hidden script is used to eval " + "script code; if this option is disabled, this hidden script " + "is unloaded after each eval: this uses less memory, but is " + "slower"), + weechat_plugin->name, + weechat_plugin->name); + *(plugin_data->config_look_eval_keep_context) = weechat_config_new_option ( + *(plugin_data->config_file), ptr_section, + "eval_keep_context", "boolean", + str_description, + NULL, 0, 0, "on", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); return 1; } diff --git a/src/plugins/plugin-script.h b/src/plugins/plugin-script.h index 0d6ad4ac6..936d67452 100644 --- a/src/plugins/plugin-script.h +++ b/src/plugins/plugin-script.h @@ -74,6 +74,7 @@ struct t_plugin_script_data /* variables */ struct t_config_file **config_file; struct t_config_option **config_look_check_license; + struct t_config_option **config_look_eval_keep_context; struct t_plugin_script **scripts; struct t_plugin_script **last_script; diff --git a/src/plugins/python/weechat-python.c b/src/plugins/python/weechat-python.c index 4d5f58003..8c89f84f7 100644 --- a/src/plugins/python/weechat-python.c +++ b/src/plugins/python/weechat-python.c @@ -48,6 +48,7 @@ struct t_plugin_script_data python_data; struct t_config_file *python_config_file = NULL; struct t_config_option *python_config_look_check_license = NULL; +struct t_config_option *python_config_look_eval_keep_context = NULL; int python_quiet = 0; @@ -1094,6 +1095,12 @@ weechat_python_eval (struct t_gui_buffer *buffer, int send_to_buffer_as_input, python_eval_exec_commands = 0; python_eval_buffer = NULL; + if (!weechat_config_boolean (python_config_look_eval_keep_context)) + { + weechat_python_unload (python_script_eval); + python_script_eval = NULL; + } + return 1; } @@ -1534,6 +1541,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) python_data.config_file = &python_config_file; python_data.config_look_check_license = &python_config_look_check_license; + python_data.config_look_eval_keep_context = &python_config_look_eval_keep_context; python_data.scripts = &python_scripts; python_data.last_script = &last_python_script; python_data.callback_command = &weechat_python_command_cb; diff --git a/src/plugins/ruby/weechat-ruby.c b/src/plugins/ruby/weechat-ruby.c index 5386f7759..a5bc4d0de 100644 --- a/src/plugins/ruby/weechat-ruby.c +++ b/src/plugins/ruby/weechat-ruby.c @@ -69,6 +69,7 @@ struct t_plugin_script_data ruby_data; struct t_config_file *ruby_config_file = NULL; struct t_config_option *ruby_config_look_check_license = NULL; +struct t_config_option *ruby_config_look_eval_keep_context = NULL; int ruby_quiet = 0; int ruby_hide_errors = 0; @@ -894,6 +895,12 @@ weechat_ruby_eval (struct t_gui_buffer *buffer, int send_to_buffer_as_input, ruby_eval_exec_commands = 0; ruby_eval_buffer = NULL; + if (!weechat_config_boolean (ruby_config_look_eval_keep_context)) + { + weechat_ruby_unload (ruby_script_eval); + ruby_script_eval = NULL; + } + return 1; } @@ -1367,6 +1374,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) ruby_data.config_file = &ruby_config_file; ruby_data.config_look_check_license = &ruby_config_look_check_license; + ruby_data.config_look_eval_keep_context = &ruby_config_look_eval_keep_context; ruby_data.scripts = &ruby_scripts; ruby_data.last_script = &last_ruby_script; ruby_data.callback_command = &weechat_ruby_command_cb; diff --git a/src/plugins/tcl/weechat-tcl.c b/src/plugins/tcl/weechat-tcl.c index fd228c791..7af80f514 100644 --- a/src/plugins/tcl/weechat-tcl.c +++ b/src/plugins/tcl/weechat-tcl.c @@ -48,6 +48,7 @@ struct t_plugin_script_data tcl_data; struct t_config_file *tcl_config_file = NULL; struct t_config_option *tcl_config_look_check_license = NULL; +struct t_config_option *tcl_config_look_eval_keep_context = NULL; int tcl_quiet = 0; @@ -924,6 +925,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) tcl_data.config_file = &tcl_config_file; tcl_data.config_look_check_license = &tcl_config_look_check_license; + tcl_data.config_look_eval_keep_context = &tcl_config_look_eval_keep_context; tcl_data.scripts = &tcl_scripts; tcl_data.last_script = &last_tcl_script; tcl_data.callback_command = &weechat_tcl_command_cb; |