diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2010-02-23 10:51:59 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2010-02-23 10:51:59 +0100 |
commit | 3d3dc1593db988c7649c9f7dc7e4289a576a6c77 (patch) | |
tree | d727c01a55c3d9b20852ad6c4fc2609caf60c969 /src/plugins/scripts/python/weechat-python.c | |
parent | 27bf347e1c1889457e9a7d1b0419cb4d1e03a359 (diff) | |
download | weechat-3d3dc1593db988c7649c9f7dc7e4289a576a6c77.zip |
Allow script commands to reload only one script
Diffstat (limited to 'src/plugins/scripts/python/weechat-python.c')
-rw-r--r-- | src/plugins/scripts/python/weechat-python.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/plugins/scripts/python/weechat-python.c b/src/plugins/scripts/python/weechat-python.c index 446a16257..a2dc8312a 100644 --- a/src/plugins/scripts/python/weechat-python.c +++ b/src/plugins/scripts/python/weechat-python.c @@ -603,6 +603,38 @@ weechat_python_unload_all () } /* + * weechat_python_reload_name: reload a Python script by name + */ + +void +weechat_python_reload_name (const char *name) +{ + struct t_plugin_script *ptr_script; + char *filename; + + ptr_script = script_search (weechat_python_plugin, python_scripts, name); + if (ptr_script) + { + filename = strdup (ptr_script->filename); + if (filename) + { + weechat_python_unload (ptr_script); + weechat_printf (NULL, + weechat_gettext ("%s: script \"%s\" unloaded"), + PYTHON_PLUGIN_NAME, name); + weechat_python_load (filename); + free (filename); + } + } + else + { + weechat_printf (NULL, + weechat_gettext ("%s%s: script \"%s\" not loaded"), + weechat_prefix ("error"), PYTHON_PLUGIN_NAME, name); + } +} + +/* * weechat_python_cmd: callback for "/python" command */ @@ -668,6 +700,11 @@ weechat_python_command_cb (void *data, struct t_gui_buffer *buffer, 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 */ |