From 3d3dc1593db988c7649c9f7dc7e4289a576a6c77 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Tue, 23 Feb 2010 10:51:59 +0100 Subject: Allow script commands to reload only one script --- src/plugins/scripts/perl/weechat-perl.c | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'src/plugins/scripts/perl') diff --git a/src/plugins/scripts/perl/weechat-perl.c b/src/plugins/scripts/perl/weechat-perl.c index 76b4b9948..50ee2845b 100644 --- a/src/plugins/scripts/perl/weechat-perl.c +++ b/src/plugins/scripts/perl/weechat-perl.c @@ -506,6 +506,38 @@ weechat_perl_unload_all () } } +/* + * weechat_perl_reload_name: reload a Perl script by name + */ + +void +weechat_perl_reload_name (const char *name) +{ + struct t_plugin_script *ptr_script; + char *filename; + + ptr_script = script_search (weechat_perl_plugin, perl_scripts, name); + if (ptr_script) + { + filename = strdup (ptr_script->filename); + if (filename) + { + weechat_perl_unload (ptr_script); + weechat_printf (NULL, + weechat_gettext ("%s: script \"%s\" unloaded"), + PERL_PLUGIN_NAME, name); + weechat_perl_load (filename); + free (filename); + } + } + else + { + weechat_printf (NULL, + weechat_gettext ("%s%s: script \"%s\" not loaded"), + weechat_prefix ("error"), PERL_PLUGIN_NAME, name); + } +} + /* * weechat_perl_command_cb: callback for "/perl" command */ @@ -572,6 +604,11 @@ weechat_perl_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 Perl script */ + weechat_perl_reload_name (argv_eol[2]); + } else if (weechat_strcasecmp (argv[1], "unload") == 0) { /* unload Perl script */ -- cgit v1.2.3